Some C# tools and frameworks

There are a couple of C# tools and frameworks that I have tried out over time and would like to share some information about. While the information is pretty basic, I hope it will pique your curiosity and be useful to you. 


System.IO.[File or Directory] and unit tests do not go hand in hand. System.IO.Abstractions provides interfaces and an implementation you can use to build testable software with file interaction. If you want to unit test your file reading / writing / browsing, System.IO.Abstraction will help you. 


If you are conducting a unit test without using mocks, you might be writing way too much code. There are many mocking frameworks out there, but the one I prefer is NSubsititute. The code is simple, easy to read and easy to learn. And it comes with great documentation.


I believe every .Net developer knows Resharper, at least by name. I developed in Visual Studio without Resharper for a couple of years but once I started using Resharper, it became almost impossible to go back to Visual Studio without Resharper.


NCrunch runs your unit test in the background and shows results using green/red dots. Like Resharper, this tool is addictive. A free 30-day trial is available; however, be careful, you might end up feeling the urge to buy it. 


This is a framework that allows you to copy the content of an object to another object using a single code line, thus saving a lot of time and a lot of code lines. I recently discovered that integration is possible with Entity Framework; you will find a good explanation here: I like to add these extension methods to make the code even more readable:

public static T MapTo<T>(this object source)
  return (T)Mapper.Map(source, source.GetType(), typeof(T));

public static T MapTo<T>(this object source, T destination)
  if (source != null)
    Mapper.Map(source, destination, source.GetType(), destination.GetType());
  return destination;

So instead of writing this :

var targetObj = Mapper.Map<TargetType>(sourceObject);

You can write :

var targetObj = sourceObject.MapTo<TargetType>();



I don’t like how Entity Framework handles database migration and how I have to do extra stuff in the model to fit the migration. FluentMigrator has solved my problem. FluentMigrator does one thing and one thing right: database migration. I’m now using Entity Framework only for querying database and I have a separate project for database migration with FluentMigrator. 


I tried a few scripting tools to create a deployment project, but Fake is by far the simplest one to use. The scripting language is F#. You don’t have to know F# to create a Fake script, but it does help. If you want to learn a little about F#, go over the “Get Started” section in the Try F# site:


Every Windows service has a repeated task to do, either once a day, on the first Monday of each month or according to a more complex scheduling pattern. Quartz takes care of this and also manages your thread. It takes a bit of time to learn how to use Quartz, but when you get the hang of it, it’s a great tool to have.


In .Net, instead of using Asp.Net MVC or Asp.Net Web Api, there is ServiceStack, there used to be FubuMVC and Simple.Web but both were discontinued. NancyFx is also available. I could write a complete article on NancyFx; however, tons of information can be found about it online since there is a great NancyFx community out there. I find NancyFx easier to learn than any Asp.Net [whatever] technologies. It’s been around for a while and its popularity keeps growing. To write a REST API, I prefer NancyFX over Asp.Net Web Api.

There are many tools and frameworks out there in .Net; it’s worth taking the time to test and evaluate a few of them.