
Open Source .NET libraries that make your life easier - thomasvm
http://thomasvm.github.io/blog/2015/03/17/open-source-net-libraries-that-make-your-life-easier/
======
Cakez0r
To add to the author's list:

* I seem to install Json.net in every .NET project I create (json serializer - thanks James Newton-King!)

* NLog for logging. It's fantastic.

* Dapper is also excellent (Micro ORM) (and anything written by Marc Gravell is generally top-notch - see protobuf-net, miniprofiler, StackExchange.Redis)

* Automapper, to avoid writing boilerplate code to convert between similarly shaped types (E.G. DTOs to DB models).

* RestSharp makes talking to RESTful apis easier.

* Microsoft's Unity is a great IOC framework, although most people seem to use NInject.

~~~
Someone1234
How does Automapper compare to Entity Framework?

We use Elmah instead of Nlog, which is also fine. Looks like NLog is a bit
more flexible than Elmah is. But Elmah is KISS which is nice.

~~~
tvjunky
I think you're asking about Dapper (ORM) which could be compared to Entity
Framework. The two major things to think about if comparing would be
simplicity and speed. Dapper is simple to setup and use. It uses standard SQL
and it's very fast. On the other hand, this is not a fair comparison. EF is
has many more features and options. Use the right tool for the right job
depending on requirements. Elmah and NLog are not apples to apples either.
Elmah make dealing with "Unhandled" exceptions very simple. Nlog is for
application logging (Trace, Info) and exception management (A try catch
scenario).

~~~
nightski
In fact it is not uncommon for me to use both Dapper and EF on the same
project. Usually I'll use Dapper for the query/reporting side and EF for the
domain model/update side. (Used to use nHibernate, but it seems to have really
stagnated unfortunately)

~~~
Hakeashar
Even then, for query _building_ I found EF (or any LINQ provider for SQL) to
be easier solution than string concatenation. Well, at least for relatively
simple queries with pagination and stuff. For filters, Dynamic.Linq would be
helpful here.

On the other side, if you need to work extensively with stored procedures or
you have complicated or custom SQL to run, Dapper (or Insight.Database -
[https://github.com/jonwagner/Insight.Database](https://github.com/jonwagner/Insight.Database),
a library which I found really nice to use) will be your best friend.

~~~
nightski
It's true. What I _really_ would like is a micro-orm like Dapper with support
for using LINQ to dynamically build queries. But I suppose this is essentially
EF with AsNoTracking, which I have yet to play around with and test
performance wise.

~~~
Hakeashar
AsNoTracking makes the materialization indeed faster, but EF always has a cost
associated with it, both for initial use (set up of the context etc, which is
noticeable) as well as every other query after that (expression tree parsing
etc, not as noticeable especially for recurring queries).

I hope it's one of the pain points they will address and solve during their
rewrite to EF7 at one point.

That being said, my opinion is that unless you have _really_ strict
performance and/or latency requirements, EF should be good enough. At least
for simpler queries and in 'longer-running' applications :)

~~~
otis_inf
My testing showed that AsNoTracking is faster than dapper. But indeed the
tests were purely focused on materialization and not query parsing: linq query
parsing takes a lot of time, so with lots of predicates etc. you'll see much
slower performance with EF compared to other ORMs with query systems other
than Linq (except NHibernate, that's slow regardless)

See:
[https://github.com/FransBouma/RawDataAccessBencher](https://github.com/FransBouma/RawDataAccessBencher)

------
xyz-x
Some that I build (and use):

* albacore for cross platform builds with ruby [https://github.com/Albacore/albacore/](https://github.com/Albacore/albacore/) C++.Net, VB, C#, F#

* suave.io [http://suave.io](http://suave.io) F#

* logary for structured logging and metrics and health-checks [http://logary.github.io/](http://logary.github.io/) C# and F#

* Chiron for F# JSON parsing

* logibit.hawk for F# API Hawk verification [https://github.com/logibit/logibit.hawk/](https://github.com/logibit/logibit.hawk/)

* Http.fs instead of RestSharp for F#

* FsSql for ADO.Net interaction

------
amageed
Some additional ones I haven't seen mentioned so far:

* FluentValidation: excellent validation library, keeps validation rules grouped together and easy to keep track of - [https://github.com/JeremySkinner/FluentValidation](https://github.com/JeremySkinner/FluentValidation)

* AutoFixture: great for the "Arrange" phase of unit tests. Populates object graphs with test data, highly customizable. There's a bit of a learning curve. Pairs nicely with xUnit but can be used with any TDD library - [https://github.com/AutoFixture/AutoFixture](https://github.com/AutoFixture/AutoFixture)

* Shouldly: a different approach to unit test assertions using "Should" that I find more readable. Also had friendlier error messages when assertions failed - [https://github.com/shouldly/shouldly](https://github.com/shouldly/shouldly)

Shameless plug of my own library:

* Regextra: aims to solve some common regex related scenarios. Features a Passphrase Regex Builder to generate a pattern for passphrase criteria, and also supports named templates and a few utility methods - [https://github.com/amageed/Regextra](https://github.com/amageed/Regextra)

~~~
bunderbunder
I've been considering abandoning AutoFixture for FsCheck.

Partially because that's what AutoFixture's maintainer seems to have done
recently. Mostly because FsCheck adds a number of additional features such as
automatically reducing failing test cases down to the the simplest failing
example it can find that make it very powerful for more complex cases.

One downside, though, is that the C# interfaces are somewhat neglected. It's
really a lot nicer to use from F#.

[https://fsharp.github.io/FsCheck/](https://fsharp.github.io/FsCheck/)

------
chton
In addition to the great ones already listed on the link and in the comments
here, I'd like to list 2 of my favorites:

* Simple.Data: [https://github.com/markrendle/Simple.Data](https://github.com/markrendle/Simple.Data) , the smallest and simplest ORM you'll ever use.

* Hyperletter: [https://github.com/Jiddler/Hyperletter](https://github.com/Jiddler/Hyperletter) , a very easy way to do inter-process communication. Great for writing distributed software over http, but can be just as useful locally.

------
manigandham
Check out Akka.Net - [http://getakka.net/](http://getakka.net/)

This is a port of the Akka framework from Java to the .Net platform. It's an
actor model framework which works incredibly well for building highly
concurrent and distributed applications. They just hit version 1.0 and are out
of beta and are backed by a commercial company Petabridge.

Highly recommended.

------
zihotki
I used to use NLog for logging until I've discovered Serilog (
[http://serilog.net/](http://serilog.net/) ) - simple .NET logging with fully-
structured events.

~~~
samirahmed
Serilog to me is a much more modern logging solution. Allows us to pipe logs
to table storage/sqlserver/loggly/logentries/docdb/azure event hub ... its the
backbone of our app - really just awesome

~~~
tvjunky
would you be interested in sharing your setup or pointers toward a good
solution with Serilog? I found that something other than a basic setup
requires a good chuck of effort to get going. For example, configuration (all
code) and IOC.

------
Schandlich
Humanizer Fantastic string, number, and datetime manipulation library
[http://www.nuget.org/packages/Humanizer/](http://www.nuget.org/packages/Humanizer/)

Units.Net I love this for measurement and weight conversions
[http://www.nuget.org/packages/UnitsNet/](http://www.nuget.org/packages/UnitsNet/)

And, of course, a shameless plug of my own library Fibber An indiscriminate
data generator that will generate random data for all properties in a given
class based on the property's type vs. its name
[https://github.com/Schandlich/Fibber](https://github.com/Schandlich/Fibber)
[http://www.nuget.org/packages/Fibber/](http://www.nuget.org/packages/Fibber/)

~~~
luibelgo
Fibber looks great, how does it compare to AutoFixture?

~~~
Schandlich
Thanks!

I can honestly say I had not heard about AutoFixture until today. Haha.

They look similar. The only difference I can really see is that I prefer my
syntax a little better for type fixtures:

.For<string>("whatever"); vs fixture.TypeMappings[typeof(string)] = s =>
"whatever";

I also allow a seed to be set for ensure "consistent random data".

But there are some features of AutoFixture that I definitely want to look at.

I created Fibber more for mocking data sources when I was creating Web Api
services; and AutoPoco was just too much configuration. Unit testing was not
the main purpose of the library.

------
willu
Surprised no one has mentioned Nancy:
[https://github.com/NancyFx/Nancy](https://github.com/NancyFx/Nancy) I can't
imagine building APIs without it now.

~~~
diverightin63
I find NancyFX really interesting, but I can't really see a reason to stray
away from Web API2 besides Mono support. Any specific reasons you prefer
Nancy?

~~~
marpstar
I've been wondering this, too. I've been using MVC since version 2 and am very
comfortable with it and Web API, but a startup I've been doing side-work for
is using Nancy. Nancy does seem lighter weight, and includes TinyIoC for
dependency injection out-of-the-box, but I too don't see a real killer use
case for Nancy.

------
sarciszewski
Here's another one that will make your life easier:
[https://github.com/adamcaudill/libsodium-
net](https://github.com/adamcaudill/libsodium-net)

Now you have no excuses for rolling your own broken crypto.

------
talles
This (article + HN comments) will be extremely handy for me in the future (I'm
a .NET dev).

Knowing that'll need some of those libraries later I decided to compile into a
list here: [https://github.com/tallesl/.NET-
libraries](https://github.com/tallesl/.NET-libraries)

------
saosebastiao
With .NET going open source, I'd like to see what is out there for web
services. Are there any linux-compatible .NET web servers/routers that I can
use that have a similar feature set and performance to the Spray/Scala stack?
C# or F#, but preferably F#. I've tried a couple (suave, nancy), but some
simple benchmarks showed they were about half as scalable as spray.

~~~
chadzawistowski
Were those simple benchmarks running on Mono? .Net is certainly _going_ open-
source, but it hasn't arrived yet. It might be worth rerunning those
benchmarks once .Net proper is available for *nix.

~~~
saosebastiao
Yes they were on the latest version of Mono, which in my experience outside of
web programming is just as fast as the JVM. I think the gap has more to do
with the libraries than the VM, but I'd be willing to wait it out to see. I'm
not migrating soon anyway...although it would be nice to know how far out it
is.

~~~
Hakeashar
Lately I checked the Perlin noise performance test that was linked to on
reddit
([http://www.reddit.com/r/programming/comments/31mzu1/go_vs_ru...](http://www.reddit.com/r/programming/comments/31mzu1/go_vs_rust_vs_d_vs_crystal_etc_perlin_noise/)).

Summary:

Benchmark: C# (Mono) - 1052.041381 ms, Java - 597.9874 ms

My machine: C# (Windows) - ~475 ms, Java - ~552 ms

Even considering that Mono is using maximum precision available (so instead of
floats it's using doubles), when I swapped all floats to doubles it still ran
in ~525 ms on my box.

So while Mono might be 'getting there', sometimes it's still lagging behind.
It's just something to keep in mind :)

------
tonyedgecombe
TopShelf looks interesting, I have written quite a few Windows services over
the years and there have always been lots of gaps in the MS offering.

~~~
wooUK
I've just rolled out a service using TopShelf having not used it previously.
It really does simplify things. The best bit for me is being able to just hit
F5 and having the thing run as a console application. No need to manually
attach to processes for debugging.

~~~
chiph
This technique lets you debug your service as if it were a console app - just
pass in -a on the command line.

In your Main method:

    
    
                if (args.Length > 0 && args[0] == "-a")
                {
                    // Running as an application
                    MyService ms = new MyService();
                    ms.DoStart();
                    Console.WriteLine("Press Enter to Stop");
                    Console.ReadLine();
                    ms.DoStop();
                } else {
                    // Running as a service
                    ServiceBase[] servicesToRun = { new MyService() };
                    ServiceBase.Run(servicesToRun);
                }
    

And in the MyService class that derives from ServiceBase:

    
    
            protected override void OnStart(string[] args)
            {
                DoStart();
            }
    
            protected override void OnStop()
            {
                DoStop();
            }
    
            internal void DoStart()
            {
                // Start your service thread here
            }
    
            internal void DoStop()
            {
                // Tell your service thread to stop here
            }

~~~
iaskwhy
I use something similar to debug a WCF project:

    
    
      private static void Main()
      {
        var serviceHandler = new ServiceHandler();
    
        if (Environment.UserInteractive)
        {
          serviceHandler.OnStart(null);
          Console.WriteLine("Service started! Press <ENTER> to terminate service.");
          Console.ReadLine();
          serviceHandler.OnStop();
          Console.WriteLine("Service stopped!");
          return;
        }
        
        Run(serviceHandler);
      }

------
candl
I've recently discovered Linq2Db. Works great for CRUD in conjunction with
Dapper.
[https://github.com/linq2db/linq2db](https://github.com/linq2db/linq2db) It
also comes with handy T4 templates to generate models.

~~~
pbz
I've been using it for long time now. Very fast, light, and stable. Thanks
Igor!!

------
Halienja
For those interested, here are the licenses each project is available under:
(courtesy Evairfairy)

Hangfire \--------

LGPL3 [https://tldrlegal.com/license/gnu-lesser-general-public-
lice...](https://tldrlegal.com/license/gnu-lesser-general-public-
license-v3-\(lgpl-3\))

Postal \------

MIT [https://tldrlegal.com/license/mit-
license#summary](https://tldrlegal.com/license/mit-license#summary)

Formo \-----

MIT [https://tldrlegal.com/license/mit-
license#summary](https://tldrlegal.com/license/mit-license#summary)

CsvHelper \---------

MS-PL [https://tldrlegal.com/license/microsoft-public-
license-(ms-p...](https://tldrlegal.com/license/microsoft-public-license-\(ms-
pl\)) Apache [https://tldrlegal.com/license/apache-
license-2.0-(apache-2.0...](https://tldrlegal.com/license/apache-
license-2.0-\(apache-2.0\))

Topshelf \--------

Apache [https://tldrlegal.com/license/apache-
license-2.0-(apache-2.0...](https://tldrlegal.com/license/apache-
license-2.0-\(apache-2.0\))

------
otis_inf
See:
[https://github.com/Microsoft/dotnet](https://github.com/Microsoft/dotnet)

This is an extensive list of (non-MS) OSS libs and tools for .NET , complete
with descriptions. The URL might suggest this is the .NET source, it's a set
of text documents with URLs to OSS libs/tools.

~~~
odinserj
Really nice list, especially under
[https://github.com/Microsoft/dotnet/blob/master/dotnet-
devel...](https://github.com/Microsoft/dotnet/blob/master/dotnet-developer-
projects.md)

------
untog
It's been years since I worked in C#, and now I want to try out most of these
libraries. I'm genuinely impressed by the ecosystem out there.

------
akiselev
One of my recent favorite libraries lately is DynamicData [1] which is Rx for
collections. It allows you to use LINQ operators to create lots of different
collections from a single "observable cache". An example from the github page:

    
    
        var list = new ObservableCollectionExtended<TradeProxy>();
        var myoperation = somedynamicdatasource
                            .Filter(trade=>trade.Status == TradeStatus.Live) 
                            .Transform(trade => new TradeProxy(trade))
                            .Sort(SortExpressionComparer<TradeProxy>.Descending(t => t.Timestamp))
                            .ObserveOnDispatcher()
                            .Bind(list) 
                            .DisposeMany()
                            .Subscribe()
    

This takes the collection at _somedynamicdatasource_ , transforms the contents
to TradeProxy objects, sorts it, and binds it to _list_. Any time that an
object is added or removed in _somedynamicdatasource_ , _list_ will be updated
to match. This library has over 50 operators including dynamic filters
(changing the filter causes the bound collection to be reevaluated), boolean
operators (only update the resulting collection if the object is in both
source collections or only one), etc.

[1]
[https://github.com/RolandPheasant/DynamicData](https://github.com/RolandPheasant/DynamicData)

------
maresca
I'd like to add one that's great for turning the web into a query-able
database: HtmlAgilityPack. HtmlAgilityPack + Linq is amazing.

~~~
Hakeashar
For working with HTML (parsing, extracting), I'd like to add HtmlTypeProvider
from F# Data as one of the options. :)

------
twunde
I have to say that for someone starting to transition to .net, this is a great
post. Posts like these are what I expect from the Ruby/Python/Node/PHP
communities but the lack of them and lack of good learning opportunities had
made me hesitant to use .net in the past. Thanks a lot, you've just made me
feel a whole lot better about the .net community as a whole.

~~~
mandeepj
Please visit regularly asp.net\community , codeplex.com . There is ton of
stuff there

------
luibelgo
Fasterflect, must-have reflection library
[https://fasterflect.codeplex.com](https://fasterflect.codeplex.com)

Insight.Database, in my opinion much better than Dapper
[https://github.com/jonwagner/Insight.Database](https://github.com/jonwagner/Insight.Database)

------
deevus
One of my must haves that I'd definitely recommend is T4MVC[0]

    
    
        T4MVC is a T4 template for ASP.NET MVC apps that creates strongly typed helpers that eliminate the use of literal strings in many places.
    

[0]: [https://github.com/T4MVC/T4MVC](https://github.com/T4MVC/T4MVC)

~~~
DenisM
Wow. I have suffered so much without it, unnecessarily! How can this not be
built into the ASP.NET MVC framework?

------
nreece
Few more:

* ServiceStack - full-featured Services Framework [https://github.com/ServiceStack/ServiceStack](https://github.com/ServiceStack/ServiceStack)

* ServiceStack.OrmLite - Fast, Simple, Typed ORM for .NET [https://github.com/ServiceStack/ServiceStack.OrmLite](https://github.com/ServiceStack/ServiceStack.OrmLite)

* BCrypt.Net - A .Net port of jBCrypt implemented in C# [http://bcrypt.codeplex.com/](http://bcrypt.codeplex.com/)

* Stripe.net - .net api for Stripe [https://github.com/jaymedavis/stripe.net](https://github.com/jaymedavis/stripe.net)

* TuesPechkin - .NET Wrapper for the wkhtmltopdf library (to generate PDFs) [https://github.com/tuespetre/TuesPechkin](https://github.com/tuespetre/TuesPechkin)

------
RomanPushkin
My personal list:

* RestfulRouting [http://restfulrouting.com/](http://restfulrouting.com/) \- must have

* Turbolinks for .net [https://github.com/kazimanzurrashid/aspnetmvcturbolinks](https://github.com/kazimanzurrashid/aspnetmvcturbolinks)

* Flash messages for .net [https://github.com/khalidabuhakmeh/MvcFlash](https://github.com/khalidabuhakmeh/MvcFlash)

* Fixie, unit testing [https://github.com/fixie/fixie](https://github.com/fixie/fixie)

* Entity Framework testing tool [http://effort.codeplex.com/](http://effort.codeplex.com/)

* Automapper, AutoFixture, FluentValidation - mentioned already

* StructureMap - IoC

------
partisan
Does anyone have recommendations for frameworks or libraries for implementing
CQRS and distributed processing of large sets of data through DDD?

I've found some different options including Lokad, NServiceBus, MassTransit,
MPAPI, but would love to hear what, if any, tools HN users are utilizing.

~~~
pvivera
I started use Circus. New and in active development. Greg Young mentioned at
GOTO talk last year
([https://www.youtube.com/watch?v=8JKjvY4etTY&t=2712](https://www.youtube.com/watch?v=8JKjvY4etTY&t=2712))

[https://github.com/d60/Cirqus/](https://github.com/d60/Cirqus/)

~~~
partisan
Thank you. I hadn't heard of this one, so thanks for linking this and the
video.

------
willu
One more I'll add to the mix that has come in handy several times: CsQuery
jQuery port.
[https://github.com/jamietre/CsQuery](https://github.com/jamietre/CsQuery)

------
numo16
Some that I've been enjoying lately:

\- SpecsFor: Some nice BDD wrappers around NUnit and Moq
[http://specsfor.com/](http://specsfor.com/) \- Glimpse: A great diagnostic
console tool for ASP.NET applications
[http://getglimpse.com/](http://getglimpse.com/) \- FluentMigrator: Awesome DB
migration framework
[https://github.com/schambers/fluentmigrator](https://github.com/schambers/fluentmigrator)

------
chrismissal
re: Formo

Last summer and into the fall, I had plans for Formo 2.0, which included a lot
more flexibility and customization capabilities (json config, http context
config, environment variables, etc). When I learned about aspnet5's
configuration I essentially stopped development on Formo. The big reason being
that they're building in such a way that I imagined Formo would be used.
(Which makes me quite happy)

For that reason, the project is largely "finished", but it's still stable and
alive.

------
borismod
Great list. I found BizArk.Core powerful console application entry point
library very useful. It provides command line arguments parsing based on class
and properties atributes
[https://bizark.codeplex.com/wikipage?title=Console%20applica...](https://bizark.codeplex.com/wikipage?title=Console%20application%20with%20command-
line%20parsing%20and%20validation&referringTitle=Documentation)

------
latkin
Great list, but could use more F# love!

Lots of cool/useful open source projects are always popping up in the F#
community -
[http://fsharp.org/community/projects/](http://fsharp.org/community/projects/)

Favs of mine from that list: Visual F# Power Tools, FSharp.Data.SqlClient,
FsEye, Fantomas, R type provider

------
henrikschroder
Reading through the list I realized that we have implemented every single one
of these things for ourselves over years of coding.

------
_camaya
You guys should check these ones:

* Hangfire([http://hangfire.io/](http://hangfire.io/)): for background jobs.

* Polly([https://github.com/michael-wolfenden/Polly](https://github.com/michael-wolfenden/Polly)): For exception handling policies.

Edit: formatting.

~~~
untog
Hangfire is the first library in the post.

~~~
_camaya
My fault, I just read the comments here :)

------
zippy1981
I can't believe no one mentioned EPPlus for manipulating excel spreadsheets.

FastJSON is my favorite non JSON.NET Json serializer.

------
junto
As an alternative to CsvHelper I can recommend FileHelpers by Marcos Meli:
[http://filehelpers.sourceforge.net/](http://filehelpers.sourceforge.net/)

Don't be put off by the dated SourceForge location. It is pure awesome for
getting data in and out of CSV format.

~~~
chiph
How well does it handle the oddball cases? Not that you could call CSV a
rigorously-defined spec, but we have a vendor that sends us a file where they
sometimes don't escape double-quotes correctly.

~~~
junto
That is where I've found it's strengths to be. I've used it to process
affiliate feed data. The quality is pretty poor and it has been pretty robust.

------
Tanako
About Object Mappers

* AutoMapper is a great mapper, but too slow [http://automapper.org/](http://automapper.org/)

* TinyMapper is extremely quick [http://tinymapper.net/](http://tinymapper.net/)

------
georgeck
A collection of awesome .NET libraries, tools, frameworks and software
(curated by community) [https://github.com/quozd/awesome-
dotnet](https://github.com/quozd/awesome-dotnet)

------
vyrotek
Hangfire looks great. I'm currently running all my jobs through Azure
Scheduler. Would anyone know what the pros & cons are between these two job
schedulers? Are there certain requirements or architectures that favor one or
the other?

~~~
pdiddy
Perhaps this is obvious but if you aren't running your own server, your web
app (and Hangfire along with it) can stop running during a period of
inactivity. Obviously this is not a problem with Azure scheduler.

I use Hangfire and then simply have Azure Scheduler ping my site regularly.

------
wehadfun
Will check out top shelf and love the list.

------
lnlyplnt
very handy!

