Loading...
Skip to Content

My go-to nuget packages

The nuget packages I find myself using in most of not all projects.

I find myself using a few key nuget packages in most, if not all, project. Some well known, some not so much.

So I thought I would document the ones I use often. It would be great to hear about any I have missed, and any on my list you haven't used, but might in the future.

Data Access

Dapper

When working with SQL databases, Dapper has been my go-to for a while, it is a powerful, easy to use Micro-ORM that supports several database technologies. Dapper is performance focussed (more information on performance is available on the Dapper Github Page), and a high level of control over the SQL, it has always been an obvious choice for me.

FluentMigrator

FluentMigrator is a database migration framework for .NET. What does that mean? Simply put database schema's (and seed data) can be version controlled. You create migrations which are C# classes that derive from the Migration base class and have a Migration attribute with a unique version number attached to them. When you run FluentMigrator, you tell it which version to migrate to and it will run all necessary migrations in order to bring your database up to that version.

Newtonsoft.Json

I think everyone knows what Newtonsoft is... 🙂

JSON ➡ objects, objects ➡ JSON

Newtonsoft is a JSON framework for .NET, but mostly I use it serialize and deserialize .NET objects.


Business Logic

Automapper

When working with CMS platforms you'll often find that the (domain) models provided don't fit and you'll want to convert them to view models. This is also a good idea as it can make replatforming easier. Automapper is a rule based object-object mapper, and it really takes the grunt work out of object to object mapping.

Mediatr

Mediatr is a simple decoupled request/response message processor. They can be simple one to one request/response where one request type has a single request handler, or they can be notifications where a single notification (request) can have multiple notification handlers.

CacheManager.net

I've used this nuget pacakge for a few years now, and found it makes maintaining and managing caching policies much easier, it is a cache framework that supports numerous cache providers, with several advanced features like backplaning (secondary distributed cache layer).

Swashbuckle

Any project involving APIs should have this package in, it can be used to generate swagger files, and also if required (I'd recommend) the Swagger UI.

Hangfire

Hangfire is persistent background process framework, with scheduled tasks, fire and forget tasks and delayed tasks. I often use this for 'big jobs' that are slow running like import/sync jobs. It uses a SQL DB for persistance, and has a easy to use interface for passed/failed/re-runnning jobs. The one thing to remember with Hangfire is that the web server needs to be 'always on'.


Utility Packages

HtmlAgilityPack

This is a parser for HTML, which makes the querying (XPATH) and manipulation of HTML much easier, I often use this with the output of Rich Text Editors to enrich/hydrate the HTML.

Humanizer

I think this is used in some way, shape or form in most of the projects I work on, it is quite useful for turn URL slugs into readable formats for quick breadcrumbs, or truncating text.

Schema.NET

I use this to help create the structured data for Google/Bing, the package contains C# POCO classes that can be turned into Schema.org JSON-LD objects in the <head> section of the HTML.


Testing

Nunit

Nunit is the most popular unit testin, NUnit is open source software and NUnit 3.0 is released under the MIT license.
Note: the NUnit3TestAdapter is also required to run the tests in Visual Studio.

Moq

Moq is a mocking library for .NET, it uses Linq expression trees and lambda expressions, you can setup methods, properties, this is often used to mock out methods the called from the method under test, it ensures that the tests only test the one method, and not the ones injected in.

Bogus

Used along with Moq, I often use this to generate test data for unit testing. You can create 'rules' for individual properties on a class, then create a fake object.


Logging

Serilog

When not bound by a CMS SDK, I much prefer to use Serilog as it is a lot more flexible, more powerful, and built to support structured event data. With numerous sinks it can store the logs in many formats on many platforms.


One to watch

Hyperion

Hyperion is still in beta, but when stable I think it will proof very useful. Hyperion is a high performance polymorphic serializer for .NET. It is actually used on this site to serialise polymorphic view models for caching in Redis.


Andy Blyth

Andy Blyth, an Optimizely MVP (OMVP) and Technical Architect at 26 DX with a keen interest in martial arts, occasionally ventures into blogging when memory serves.

 
Andy Blyth