Visual studio feeds

All Visual Studio blogs in one place


Enter your email address:

Delivered by FeedBurner

Increase your website traffic with



Anti-spam: How many eyes has a typical person?

Follow us on FB


Creating ReSharper Live Templates & distribute them using NuGet

AddThis Social Bookmark Button
In one of my recent projects I created some ReSharper Live Templates in order for other developers to easily create some code using a predefined class template. Live templates can significantly speed up the implementation of such classes, because developers only need to provide some minimal information (such as the class name and maybe some generic type parameters and such). There’s also less room for accidental copy-pasting. Yeah, pressing CTRL+V after CTRL-C should be mapped to some macro that makes Visual Studio crash! :) Example use case But seriously, file templates can come in quite handy. Consider the following
piece of code that needs to be converted into a ReSharper file template. It represents a custom Comparer implementation for a given contract that has a unique key. It's exported using a custom MEF export attribute that exposes some metadata. Such design is quite common for instance when some application dynamically loads assemblies containing such comparers and needs to find the best matching comparer for a given contract. [Export(typeof(MyContractComparer))] [ContractComparer(typeof(MyContract))] public partial class MyContractComparer : KeyComparer { protected override Expression> KeyProperty { get { return contract => contract.Id; } } } Imagine that various of those classes need to be implemented, with potentially a different base type and...(Read whole news on source site)

Home : Blog List : Algoritmi sani in codice sano : Creating ReSharper Live Templates & distribute them using NuGet