4

Cadru 4.5

 3 years ago
source link: https://scottdorman.blog/2020/09/13/cadru-4-5/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Cadru 4.5

  • 2020-09-13
  • 6 minutes to read
  • edit

It’s hard to believe that just over seven years ago, I first released Cadru as an open-source framework. In that time, there have been a few updates, but none as ambitious as the 4.0 preview. The main goal of that release, which was about three years ago, was to add support for .NET Standard and split up the project into smaller, and more focused, packages.

It feels like the 4.0 release has been in perpetual preview mode, with changes made periodically over that time. The most significant changes, though, have been in this past week and support the new Cadru 4.5 release.

.NET Standard support

All of the projects, except one, have been updated to .NET Standard 2.1. This is a departure from the original idea of making Cadru support the broadest reach possible by targeting a “lowest common denominator” of portable APIs. With the upcoming November release of .NET 5, it was time to bring Cadru into a more modern code base and make other improvements that are only available with newer language features. These changes will also allow me to update to .NET 5 more easily.

As of right now, Cadru.Postal, is still on .NET 4.5. It’s due to be rewritten to support the Razor SDK, but until then, it has to stay behind.

C# 8.0 language features

Updating to .NET Standard also brought with it an update to using C# 8.0 language features. One of those improvements is nullable reference types, enabling developers to make meaningful statements about the nullability of a reference type:

  • A reference isn’t supposed to be null.
  • A reference may be null.

By supporting nullable reference types now, the eventual update to .NET 5, where nullable reference types are the “new normal”, will be that much easier.

Some of the other language features that were adopted are:

  • switch expressions, which allowed me to make some rather unwieldy switch statements much more concise and readable
  • The null-coalescing assignment operator ??=
  • The notnull and unmanaged generic constraints
  • Improved pattern matching using the is operator (introduced in C# 7.0). This is a really powerful operator, and I think there are many more places where I can use it for more simplification and correctness improvements.

New projects and retired old ones

There have been improvements in the project organization, including splitting things up into more projects, which also means that there are more NuGet packages. These are smaller, more focused packages that should allow for better flexibility in choosing what features you need.

  • Cadru.AspNetCore - Provides ASP.NET Core middleware and other extensions for request and/response logging.
  • Cadru.AspNetCore.Mvc - Provides additional support for working with ASP.NET Core, such as custom view location expanders, support for IMetadataAware, and rendering enumerated types as SelectLists based on a UiHint attribute, and extensions to make working with state management a bit simpler.
  • Cadru.AspNetCore.Mvc.TagHelpers - Provides additional ASP.NET Core TagHelpers.
  • Cadru.Build.Tasks - Provides additional MSBuild tasks and is used to support assembly-build-versioning.
  • Cadru.Caching - Provides a standard implementation for creating and using cache keys.
  • Cadru.Collections - Provides additional collection classes and extensions.
  • Cadru.Contracts - Provides static classes for representing program contracts as preconditions in a way that’s compatible with System.Diagnostics.Contracts.
  • Cadru.Core - Provides common extensions and new APIs for the .NET Framework.
  • Cadru.Data - Provides a standard way to read Excel data and fixed width files.
  • Cadru.Data.Annotations - Provides common data annotation attributes.
  • Cadru.Data.Dapper - Provides a common database context and predicates for use with Dapper.
  • Cadru.Environment - Provides support for determining framework versions, IIS version, and feature detection.
  • Cadru.Extensions.FileProviders - Additional file providers and support for working with physical files and directories.
  • Cadru.Net.Http - Provides transient error detection strategies for adding retry logic into your HttpClient calls and a UrlBuilder to help simplify building complex URLs.
  • Cadru.Net.NetworkInformation - Provides access to network information and notification of network status changes.
  • Cadru.Polly - Provides support for working with Polly policies, including a strategy for resilient database queries.
  • Cadru.Postal - Provides classes for generating email using ASP.NET MVC Razor views.
  • Cadru.Scim - Support for creating System for Cross-domain Identity Management (SCIM) filters.
  • Cadru.UnitTest.Framework - Provides additional assert capabilities for MS Test.

While that’s a lot of packages, there are a few other changes to note:

  • Cadru.TransientFaultHandling - This package has been retired and should be replaced with *Cadru.Polly.
  • Cadru.Net - This package is renamed to *Cadru.Net.Http
  • Cadru.Core.Windows - This package is retired, and features migrated to Cadru.Environment, Cadru.IO, and Cadru.Net.NetworkInformation as appropriate.
  • Cadru.IO - This package will eventually be retired and replaced with Cadru.Extensions.FileProviders.

What’s next for Cadru?

The most significant update planned will be support for .NET 5 when it releases in November. Until then, there are a handful of known tasks still left. See the Cadru 5.0 milestone for more details. There are only a few issues in there right now, but I will be adding more over time.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK