← All recipes
Moderne licensed

Use factory method for abstract cryptographic types

Recipe IDOpenRewrite.Recipes.CSharp.Migration.Dotnet.Net6.UseCryptoFactoryMethodsArtifactOpenRewrite.Recipes.CSharp.Migration.Dotnet

Replace new AbstractCryptoType() with AbstractCryptoType.Create() for abstract cryptographic types like SHA256, Aes, RandomNumberGenerator, etc. These types are abstract and cannot be instantiated directly; callers must use the static Create() factory method.

Single recipecsharpdotnetSYSLIB0023SYSLIB0022SYSLIB0021cryptographyProprietary

Usage

This recipe has no required configuration options. You’ll need the Moderne CLI configured before running the command below.

mod run . --recipe OpenRewrite.Recipes.CSharp.Migration.Dotnet.Net6.UseCryptoFactoryMethods

If the recipe isn’t available locally, install it with:

mod config recipes nuget install OpenRewrite.Recipes.CSharp.Migration.Dotnet