Skip to content

Latest commit

 

History

History
216 lines (124 loc) · 9.26 KB

README.md

File metadata and controls

216 lines (124 loc) · 9.26 KB

A curated list of .NET Libraries

This repository contains a curated list of modern, open-source .NET libraries which are of general use, particularly in the context of an ASP.NET Core web application.

Each section lists a recommended library or libraries, optionally followed by one or more good alternatives.

Table of Contents

Background Jobs

Recommended

Hangfire is a mature and powerful background job manager which requires minimal setup. Using Redis rather than a SQL database as the backing storage improves throughput. The official Redis support requires a paid 'pro' license, but the open-source StackExchange.Hangfire.Redis repo provides a free alternative.

Alternatives

Caching

Since ASP.NET Core applications run in a persistent process, non-distributed caching can be implemented without external infrastructure dependencies. Bitfaster.Caching offers a good set of features and high performance. CacheTower offers a multi-layered caching system, which could be useful if caching large amounts of expensive queries which do not fit easily in memory.

Recommended

Alternatives

For a distributed Redis cache, one can use StackExchange.Redis together with the Microsoft.Extensions.Caching.StackExchangeRedis IDistributedCache implementation (see here).

  • StackExchange.Redis (GitHub)

Compile-time Dependency Injection

ASP.NET Core has built-in dependency injection feature which is sufficient for most use-cases. However, the following source generator libraries promise increased performance.

Sadly, owing to the design of ASP.NET Core, it is not yet possible to fully integrate compile-time libraries and thereby fully replace the built-in runtime dependency injection mechanics:

Recommended

Alternatives

Console Applications

Recommended

  • ConsoleAppFramework (GitHub)

Alternatives

System.CommandLine is sufficient for very simple scenarios.

Email Templating

Scriban is a high-performance templating engine which can used not only for email templating, but many other purposes besides. Fluid claims to be even faster than Scriban.

Encryption

Recommended

ETL

Recommended

Event/Message Bus

CAP supports the transactional outbox pattern, which can be helpful for reliability. MessagePipe is by Cysharp, who is famous for high-performance libraries. Rebus has been around for a long time and is battle-tested and well-documented.

Recommended

Alternatives

File Storage

Recommended

FluentStorage is an abstraction for blob storage across multiple cloud providers (and local files). It is well-documented.

GUI applications

Recommended

Logging

Recommended

Alternatives

  • gelf-extensions-logging (GitHub)

Markdown to HTML

Mediator pattern

Recommended

  • Mediator (source generator) (GitHub)

Alternatives

ORM and Database Access

Recommended

Entity Framework is an incredibly powerful ORM which provides advanced, strongly-typed querying capabilities, good performance - particularly since a host of improvements were made in EF Core 6 - and inbuilt support for the unit of work pattern. EFCore.BulkExtensions can be used to improve performance when dealing with bulk CUD operations, the impact of which becomes noticeable when dealing with operations on 100s or 1000s of entities. If a second-level cache is required, EF Core Second Level Cache Interceptor can be used.

In advanced scenarios, when more than one database transaction may be required per web request, the DbContextScope library is useful. This allows for more fine-grained control over the lifetime of the DbContext than simply injecting the DbContext as a scoped dependency. For more information, see Mehdi El Gueddari's 2014 article here.

To allow for primary keys that can be generated in application code and can be more efficiently sorted than standard GUIDs (particularly in databases which do not support non-clustered primary keys), consider ULIDs or COMB GUIDs.

Alternatives

The following are lighter-weight alternatives which do not offer the full functionality of Entity Framework Core:

Marten is a powerful library which allows PostgreSQL to be used as a hybrid/NoSQL database:

PDF generation

There aren't many PDF generators that don't rely on headless browser rendering of HTML (regardless of programming language; cf. e.g. mpdf in PHP, although the source code looks hard-to-maintain). However, the non-browser approach yields much better performance. QuestPDF is one such library on .NET.

Recommended

Reverse Proxy/API Gateway

Recommended

Testing

Recommended

A good combination of libraries for implementing tests is xUnit as the test framework, NSubstitute for test doubles, Bogus for the generation of fake data and FluentAssertions for assertions.

Alternatives

Workflows

Recommended