News for hackers. Stuff that matters.
Re:Open Source .NET libraries that make your life easier by Cakez0r on Friday April 10, 2015 @09:28AM (#9354105)
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.

Re:Open Source .NET libraries that make your life easier by Griever on Friday April 10, 2015 @09:51AM (#9354226)
Excellent list. Another addition I would make is another contribution from Stack Exchange, this time from Kevin Montrose. It's a high-performance JSON serializer/deserializer called Jil. https://github.com/kevin-montrose/Jil

I've been using it on most of my newer projects this year and I have to say I much prefer it over the (still excellent) Json.net.

Re:Open Source .NET libraries that make your life easier by topbanana on Friday April 10, 2015 @11:41AM (#9355041)
> * Microsoft's Unity is a great IOC framework, although most people seem to use NInject

Autofac is my favorite. Once built, containers are immutable, there is deterministic disposal of components in 'lifetime scopes', and delegate factories make it much easier to instantiate classes with a mixture of services and data.

Re:Open Source .NET libraries that make your life easier by kjhughes on Friday April 10, 2015 @03:18PM (#9356538)
Thanks for these. Adding a couple others:

* EPPlus for reading or creating Excel spreadsheets without using Excel (such as on a server). http://epplus.codeplex.com/

* RTFConverter for parsing RTF. http://www.codeproject.com/Articles/27431/Writing-Your-Own-R...

These are good enough to drive the decision to use C#/.NET for projects needing these capabilities.

Re:Open Source .NET libraries that make your life easier by keithly on Friday April 10, 2015 @04:39PM (#9356974)
I found SpreadsheetLight much more performant than EPPlus. http://spreadsheetlight.com/download/
Re:Open Source .NET libraries that make your life easier by NicoJuicy on Friday April 10, 2015 @07:54PM (#9357742)
I prefer DoddleReport for creating reports from a dynamic source to Excel, PDF, OpenExcell, txt or csv :)

They also have a great MVC integration

Re:Open Source .NET libraries that make your life easier by odinserj on Friday April 10, 2015 @11:46AM (#9355074)
Dapper is a really awesome library when you want to write complex queries (full of table hints, output clauses, merges and other advanced stuff), but don't want to write enormous amount of code for adding parameters and reading result sets.
Re:Open Source .NET libraries that make your life easier by rjbwork on Friday April 10, 2015 @12:27PM (#9355383)
Personally, I think it's great even for crud...It's an order of magnitude faster than things like EF/LINQ2SQL
Re:Open Source .NET libraries that make your life easier by odinserj on Friday April 10, 2015 @01:29PM (#9355811)
I've also used BLToolkit, and it is pretty fast too, plus it has Linq support to build strongly-typed queries that sometimes better than raw SQL queries. But when it comes to table hints, Linq and other stuff does not help. So, it always depends :)
Re:Open Source .NET libraries that make your life easier by radicalbyte on Friday April 10, 2015 @02:38PM (#9356266)
BLToolkit and the replacement (linq2db) are great. Excellent performance and it has some excellent developers contributing.
Re:Open Source .NET libraries that make your life easier by aggieben on Friday April 10, 2015 @01:01PM (#9355621)
Agreed. And really it's pretty simple to get it working and start using it even for straight crud - much easier than EF or other heavy ORMs, I think.
Re:Open Source .NET libraries that make your life easier by bratsche on Friday April 10, 2015 @12:06PM (#9355209)
> RestSharp makes talking to RESTful apis easier.

Another interesting library for doing REST APIs is Refit: https://github.com/paulcbetts/refit

Re:Open Source .NET libraries that make your life easier by Hakeashar on Friday April 10, 2015 @04:10PM (#9356834)
Damn, thanks for pointing me in that direction. It's exactly what I've been looking for.

Technically, I implemented some of that stuff myself because I needed REST client that would work with PCLs and be a bit 'nicer' to use than just juggling strings/routes everywhere, so using annotations and wrapping Microsoft's HttpClient was obvious and relatively easy way out.

Anyway, I'll probably just phase out my own solution and start using the library.

[EDIT]

After checking it out, RefitStubs.cs file seems a little bit clunky, but the library as a whole looks solid enough. I'll look further into it.

Re:Open Source .NET libraries that make your life easier by xpaulbettsx on Saturday April 11, 2015 @12:33AM (#9358505)
RefitStubs is necessary because on certain platforms (iOS, WinRT), you cannot JIT and therefore can't use something like Castle Core to generate a class
Re:Open Source .NET libraries that make your life easier by Hakeashar on Saturday April 11, 2015 @07:12AM (#9359104)
I figured as much. Unfortunately there's no Emit for AOT where you could do something like: https://github.com/jonwagner/Insight.Database/blob/master/In...

On the other hand, I wonder if it wouldn't be easier to ship a T4 template? I know for sure that would integrate with VS (both the IDE and build process) without any issues, not sure about Xamarin Studio...

Re:Open Source .NET libraries that make your life easier by NicoJuicy on Friday April 10, 2015 @07:57PM (#9357752)
I'd add ImageResizer for resizing images ( and in MVC resizing them in a restfull way...). You can also localcache them or cache external images (resized). You can also store them in the cloud and add effects to the images.

Many things are possible : http://imageresizing.net/

It isn't possible in Asp.Net 5 (vNext) though :( - because of the cross platform integration.

Also, https://github.com/jamietre/CsQuery is pretty nice for parsing webpages and using CSS Selectors (jquery style)

With CsQuery, you could use aBot ( https://github.com/sjdirect/abot ) for crawling ;)

Re:Open Source .NET libraries that make your life easier by dasboth on Friday April 10, 2015 @11:12AM (#9354851)
Was going to post Dapper, Automapper and RestSharp myself.

I use ELMAH for logging but I'll give NLog a look!

Re:Open Source .NET libraries that make your life easier by mandlar on Friday April 10, 2015 @11:24AM (#9354933)
I also can recommend StackExchange Exceptional and Opserver from the StackExchange crew for logging: https://github.com/opserver/Opserver
Re:Open Source .NET libraries that make your life easier by NicoJuicy on Friday April 10, 2015 @07:55PM (#9357746)
Would give a headsup for Elmah and the MVC integration... It's pretty easy and awesome.
Re:Open Source .NET libraries that make your life easier by eropple on Friday April 10, 2015 @10:58AM (#9354748)
> NLog for logging. It's fantastic.

I use NLog, but I access it through the Common.Logging facade. This is helpful when I need to bolt my code into an environment where NLog kind of sucks, like Xamarin.Android.

Re:Open Source .NET libraries that make your life easier by russgray on Friday April 10, 2015 @01:42PM (#9355897)
If you're in a position to use it, I much prefer Anotar with Fody https://github.com/Fody/Anotar

Commons.Logging always felt clunky in comparison.

Re:Open Source .NET libraries that make your life easier by GordonS on Friday April 10, 2015 @04:35PM (#9356953)
I prefer Timber myself https://github.com/cocowalla/Timber

In particular, it makes logging to the Windows event log much easier

Re:Open Source .NET libraries that make your life easier by Someone1234 on Friday April 10, 2015 @10:11AM (#9354387)
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.

Re:Open Source .NET libraries that make your life easier by tvjunky on Friday April 10, 2015 @10:22AM (#9354471)
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).
Re:Open Source .NET libraries that make your life easier by nightski on Friday April 10, 2015 @10:36AM (#9354583)
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)
Re:Open Source .NET libraries that make your life easier by Hakeashar on Friday April 10, 2015 @11:26AM (#9354941)
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, a library which I found really nice to use) will be your best friend.

Re:Open Source .NET libraries that make your life easier by nightski on Friday April 10, 2015 @12:02PM (#9355185)
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.
Re:Open Source .NET libraries that make your life easier by Hakeashar on Friday April 10, 2015 @12:16PM (#9355293)
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 :)

Re:Open Source .NET libraries that make your life easier by otis_inf on Friday April 10, 2015 @04:19PM (#9356876)
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

Re:Open Source .NET libraries that make your life easier by Cakez0r on Friday April 10, 2015 @11:09AM (#9354820)
Entity Framework isn't really similar to any of the things I listed. I tried to only include components you might use as part of a larger system, rather than technology stack choices.

Dapper distills the converting database rows to objects. It's a micro ORM, which means it doesn't try to abstract SQL like a monolithic ORM (NHibernate, EntityFramework) would do. Example:

        public TagModel GetTag(long id)
        {
            using (var conn = m_connector.GetConnection())
            {
                return conn.Query<TagModel>("SELECT TOP 1 * FROM Tags WHERE Id = @Id", new { Id = id }).FirstOrDefault();
            }
        }
Re:Open Source .NET libraries that make your life easier by louhike on Friday April 10, 2015 @10:16AM (#9354427)
AutoMapper does not really compare to EF. AutoMapper is used to copy automatically data between two objects of different classes (like a.UtilisateurName = b.Utilisateur.Name). It uses Reflection for that. I will try to link automatically properties by their names. The two classes do not have to have the same format. It works if one the classes is the flattened version of the other.

It might not be really clear, sorry. Try to look on their website https://github.com/AutoMapper/AutoMapper/wiki/Getting-starte....

Re:Open Source .NET libraries that make your life easier by _camaya on Friday April 10, 2015 @10:16AM (#9354430)
Automapper and Entity Framework are two absolutely different things. The first one in a mappings library and the other one is a full ORM.

Automapper basically allows you to convert a DB Model to a DTO or a ViewModel.

Re:Open Source .NET libraries that make your life easier by mariusmg on Friday April 10, 2015 @10:08AM (#9354359)
Never understood the point of Automapper when you can write explicit/implicit user defined typed conversions in C#.
Re:Open Source .NET libraries that make your life easier by _camaya on Friday April 10, 2015 @10:14AM (#9354410)
could you elaborate a bit more on that?
Re:Open Source .NET libraries that make your life easier by UK-AL on Friday April 10, 2015 @10:22AM (#9354472)
https://msdn.microsoft.com/en-us/library/z5z9kes2.aspx

Doesn't completely replace automapper