We all have a few trusty packages we install right away when starting a new project, installed reflexively as a side effect of hard-fought knowledge from coding in the real world. But, while there’s a lot of collective experience on NuGet, some decide to venture off the path. Those brave enough to explore new ways of developing software may be inclined to share their knowledge, helping others learn from their journey. Since most software typically has similar characteristics and problems we need to solve, many new packages retread existing solutions. In this post, through my exploration of NuGet.org, we’ll talk about Five of the most common NuGet packages you’ll find when looking for packages.
1. Logging Packages
Unless you’re perfect, and many of us are not, you’ll need a way to understand issues as they occur in your application. Logging packages can range from enhancing the console output experience, structure logging, and even logging to multiple destinations. However, logging is vital to most systems and can help identify issues faster. As of writing this post, the .NET community is seeing a push toward OpenTelemetry. The .NET team has built OpenTelemetry APIs into future versions of .NET, but it still requires some effort to interact with the tracing APIs. Additionally, OpenTelemetry does not currently support logging, but developers are actively discussing its future in OpenTelemtry. While adding OpenTelemetry as an out-of-the-box experience may seem like a move away from logging packages, many folks will still want an abstraction between their code and logging APIs.
Notable logging packages include Serilog, NLog, Application Insights, log4net, and Microsoft’s logging abstractions. See more logging packages at NuGet using the “logging” keyword.
2. Validation Packages
Validation is one of those features already included with the .NET base class library under the
System.Data.Annotations namespace. Developers commonly use Data annotations with Entity Framework, the data access library, but you can use it in other scenarios, including as part of the ASP.NET Core MVC validation pipeline. The variety of validation packages on NuGet.org can differ in their scope and objective. For example, some validation packages are broad in scope, allowing you to validate any entities you may create in your applications. One example is FluentValidation, commonly seen as a replacement for data annotations. Other packages allow you to validate access tokens, JSON by schema, or sync existing validation between server and client.
3. Data Access Packages
At the dawn of .NET, Microsoft SQL Server and Oracle reigned supreme as the two defacto data storage mechanisms. Today, developers have a plethora of choices for storing their data. From PostgreSQL, MySQL, MongoDB, Eventstore, and other options. In addition to storage engines, many folks are experimenting with how to store data from traditional relational models, NoSQL, event stores, and other approaches. These opinions around data storage have created an exciting ecosystem of data access within the .NET community, which has helped developers build applications.
If you’re interested in Data Access packages, popular ones include Entity Framework Core, Dapper, and Marten. You can also look at low-level drivers for SQL Server, PostgreSQL, and MongoDB.
4. Software Developer Kit Packages
The rise of the cloud has changed the focus of third-party dependencies from solving local problems to shipping those problems somewhere else, presumably to a third-party web service. As a result, one of the most prevalent packages you’ll find on NuGet is wrappers to web APIs. These packages don’t provide value in themselves but instead give developers a way to discover the surface API of the dependency they’ve chosen. These packages can help you understand a complex cloud service like AWS or Azure or do quick work of integrating your application with services like Discord and Slack. The parent organization typically maintains these packages to gain more customers and ease developers into the ecosystem.
5. Helper Packages
These kinds of packages litter the NuGet.org search results. They typically are a bundle of extension methods, classes, and other helpful code snippets packaged for easy consumption. Not surprisingly, what you find in these packages is similar. What is in these packages is usually up to what the creator deems repetitive and annoying in their codebases. A few standard helper methods in these packages include string manipulation, paging helpers, serialization configuration, and file access. While these packages are helpful in most cases, they typically signal a gap in the underlying .NET base class library. The issues these packages may hint at are missing functionality or obtuse APIs that require some smoothing over with wrapping methods. An issue with these packages is they typically operate by extension method, providing natural-feeling functionality on top of existing classes, but adding more than one of these dependencies to your project can quickly pollute your code completion options.
Honorable Mention - Frameworks
Once developers find an approach they like, they want to spread their knowledge far and wide. So rather than focusing on small bits of functionality, it’s about time these individuals built a framework of patterns, practices, and approaches. Bordering on religion, these packages attempt to guide you to build successful applications. Some folks swear by these framework libraries, while others find them bloated and cumbersome. As always, it depends on your use case. My concern with these packages is authors typically break down their frameworks into parts. These parts can range from a few packages to hundreds. The success of these packages depends on the original author and the community that forms around it. Choose wisely, as you may find yourself the only one at the framework party.
There you have it. There are many great options on NuGet.org when it comes to solving your particular problems. You’re rarely the first to discover a problem, and many folks have likely already solved it for you. As I scanned the package repository, these were the common ones I ran into during my perusal. If there are other packages you commonly find on NuGet.org, please reach out to me on Twitter @buhakmeh and tell me about them. I’d love to hear from you, and thanks for reading.