Migrate to .NET 9
Recipe ID
OpenRewrite.Recipes.CSharp.Migration.Dotnet.Net9.UpgradeToDotNet9ArtifactOpenRewrite.Recipes.CSharp.Migration.DotnetMigrate C# projects to .NET 9, applying necessary API changes. Includes all .NET 7 and .NET 8 migration steps. See https://learn.microsoft.com/en-us/dotnet/core/compatibility/9.0.
Composite recipecsharpdotnetmigrationProprietary
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.Net9.UpgradeToDotNet9If the recipe isn’t available locally, install it with:
mod config recipes nuget install OpenRewrite.Recipes.CSharp.Migration.DotnetDefinition
This recipe runs the following recipes in order.
- Migrate to .NET 8
OpenRewrite.Recipes.CSharp.Migration.Dotnet.Net8.UpgradeToDotNet8 - Change .NET target framework
OpenRewrite.CSharp.Recipes.ChangeDotNetTargetFramework - Upgrade NuGet package version
OpenRewrite.CSharp.Recipes.UpgradeNuGetPackageVersion - Upgrade NuGet package version
OpenRewrite.CSharp.Recipes.UpgradeNuGetPackageVersion - Upgrade NuGet package version
OpenRewrite.CSharp.Recipes.UpgradeNuGetPackageVersion - Upgrade NuGet package version
OpenRewrite.CSharp.Recipes.UpgradeNuGetPackageVersion - Upgrade NuGet package version
OpenRewrite.CSharp.Recipes.UpgradeNuGetPackageVersion - Ensure csproj attestation
OpenRewrite.CSharp.Recipes.EnsureCsprojAttestation - Use Volatile.Read/Write (SYSLIB0054)
OpenRewrite.Recipes.CSharp.Migration.Dotnet.Net9.UseVolatileReadWrite - Use X509CertificateLoader (SYSLIB0057)
OpenRewrite.Recipes.CSharp.Migration.Dotnet.Net9.UseX509CertificateLoader - Use MapStaticAssets()
OpenRewrite.Recipes.CSharp.Migration.Dotnet.Net9.UseMapStaticAssets - Delete method argument
OpenRewrite.Recipes.CSharp.Migration.Dotnet.DeleteMethodArgument - Find LINQ ambiguities introduced by .NET 9
IAsyncEnumerableextensionsOpenRewrite.Recipes.CSharp.Migration.Dotnet.Net9.FindAsyncEnumerableLinqAmbiguity - Find
AuthenticationManagerusage (SYSLIB0009)OpenRewrite.Recipes.CSharp.Migration.Dotnet.Net9.FindAuthenticationManager - Find
BinaryFormatterusage (removed in .NET 9)OpenRewrite.Recipes.CSharp.Migration.Dotnet.Net9.FindBinaryFormatter - Find
BinaryReader.ReadStringbehavior changeOpenRewrite.Recipes.CSharp.Migration.Dotnet.Net9.FindBinaryReaderReadString - Find
EnumConverterconstructor validation changeOpenRewrite.Recipes.CSharp.Migration.Dotnet.Net9.FindEnumConverter - Find
HttpListenerRequest.UserAgentnullable changeOpenRewrite.Recipes.CSharp.Migration.Dotnet.Net9.FindHttpListenerRequestUserAgent - Find
InMemoryDirectoryInforootDir prepend changeOpenRewrite.Recipes.CSharp.Migration.Dotnet.Net9.FindInMemoryDirectoryInfo - Find
IncrementingPollingCounterasync callback changeOpenRewrite.Recipes.CSharp.Migration.Dotnet.Net9.FindIncrementingPollingCounter - Find
JsonSerializer.DeserializenullableJsonDocumentchangeOpenRewrite.Recipes.CSharp.Migration.Dotnet.Net9.FindJsonDocumentNullable - Find
RuntimeHelpers.GetSubArrayreturn type changeOpenRewrite.Recipes.CSharp.Migration.Dotnet.Net9.FindRuntimeHelpersGetSubArray - Find
SafeEvpPKeyHandle.DuplicateHandleup-ref changeOpenRewrite.Recipes.CSharp.Migration.Dotnet.Net9.FindSafeEvpPKeyHandleDuplicate - Find
ServicePointManagerusage (SYSLIB0014)OpenRewrite.Recipes.CSharp.Migration.Dotnet.Net9.FindServicePointManager - Find obsolete
X509Certificate2/X509Certificateconstructors (SYSLIB0057)OpenRewrite.Recipes.CSharp.Migration.Dotnet.Net9.FindX509CertificateConstructors - Find
ZipArchive.CreateEntrywithCompressionLevel(bit flag change)OpenRewrite.Recipes.CSharp.Migration.Dotnet.Net9.FindZipArchiveCompressionLevel - Find
ZipArchiveEntryname/comment UTF-8 encoding changeOpenRewrite.Recipes.CSharp.Migration.Dotnet.Net9.FindZipArchiveEntryEncoding - Find
HttpClientHandlerusage (HttpClientFactory default change)OpenRewrite.Recipes.CSharp.Migration.Dotnet.Net9.FindHttpClientHandlerCast - Find synchronous ExecuteUpdate/ExecuteDelete (EF Core 9)
OpenRewrite.Recipes.CSharp.Migration.Dotnet.Net9.FindExecuteUpdateSync - Find Swashbuckle usage (ASP.NET Core 9 built-in OpenAPI)
OpenRewrite.Recipes.CSharp.Migration.Dotnet.Net9.FindSwashbuckle - Migrate Swashbuckle to built-in OpenAPI
OpenRewrite.Recipes.CSharp.Migration.Dotnet.Net9.MigrateSwashbuckleToOpenApi - Find implicit authentication default scheme (ASP.NET Core 9)
OpenRewrite.Recipes.CSharp.Migration.Dotnet.Net9.FindImplicitAuthenticationDefault - Use LINQ CountBy()
OpenRewrite.Recipes.CSharp.Migration.Dotnet.Net9.UseLinqCountBy - Use Task.CompletedTask
OpenRewrite.Recipes.CSharp.Migration.Dotnet.Net9.UseTaskCompletedTask - Remove ConfigureAwait(false)
OpenRewrite.Recipes.CSharp.Migration.Dotnet.Net9.RemoveConfigureAwaitFalse - Use System.Threading.Lock for lock fields
OpenRewrite.Recipes.CSharp.Migration.Dotnet.Net9.UseLockObject - Use LINQ AggregateBy()
OpenRewrite.Recipes.CSharp.Migration.Dotnet.Net9.UseLinqAggregateBy - Use LINQ Index()
OpenRewrite.Recipes.CSharp.Migration.Dotnet.Net9.UseLinqIndex - Use Frozen collections instead of Immutable
OpenRewrite.Recipes.CSharp.Migration.Dotnet.Net9.UseFrozenCollections - Use \e escape sequence
OpenRewrite.Recipes.CSharp.Migration.Dotnet.Net9.UseEscapeSequenceE - Find non-generic JsonStringEnumConverter
OpenRewrite.Recipes.CSharp.Migration.Dotnet.Net9.FindJsonStringEnumConverter - Find IDistributedCache usage (HybridCache in .NET 9)
OpenRewrite.Recipes.CSharp.Migration.Dotnet.Net9.FindDistributedCache