Migrate to .NET 9

Proprietary

Migrate 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.

OpenRewrite.Recipes.CSharp.Migration.Dotnet.Net9.UpgradeToDotNet9
mod run . --recipe=OpenRewrite.Recipes.CSharp.Migration.Dotnet.Net9.UpgradeToDotNet9

Install it once, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.

Recipe list

It runs these recipes, in this order.

  1. Migrate to .NET 8
  2. Change .NET target framework
  3. Upgrade NuGet package version
  4. Upgrade NuGet package version
  5. Upgrade NuGet package version
  6. Upgrade NuGet package version
  7. Upgrade NuGet package version
  8. Ensure csproj attestation
  9. Use Volatile.Read/Write (SYSLIB0054)
  10. Use X509CertificateLoader (SYSLIB0057)
  11. Use MapStaticAssets()
  12. Delete method argument
  13. Find LINQ ambiguities introduced by .NET 9 IAsyncEnumerable extensions
  14. Find AuthenticationManager usage (SYSLIB0009)
  15. Find BinaryFormatter usage (removed in .NET 9)
  16. Find BinaryReader.ReadString behavior change
  17. Find EnumConverter constructor validation change
  18. Find HttpListenerRequest.UserAgent nullable change
  19. Find InMemoryDirectoryInfo rootDir prepend change
  20. Find IncrementingPollingCounter async callback change
  21. Find JsonSerializer.Deserialize nullable JsonDocument change
  22. Find RuntimeHelpers.GetSubArray return type change
  23. Find SafeEvpPKeyHandle.DuplicateHandle up-ref change
  24. Find ServicePointManager usage (SYSLIB0014)
  25. Find obsolete X509Certificate2/X509Certificate constructors (SYSLIB0057)
  26. Find ZipArchive.CreateEntry with CompressionLevel (bit flag change)
  27. Find ZipArchiveEntry name/comment UTF-8 encoding change
  28. Find HttpClientHandler usage (HttpClientFactory default change)
  29. Find synchronous ExecuteUpdate/ExecuteDelete (EF Core 9)
  30. Find Swashbuckle usage (ASP.NET Core 9 built-in OpenAPI)
  31. Migrate Swashbuckle to built-in OpenAPI
  32. Find implicit authentication default scheme (ASP.NET Core 9)
  33. Use LINQ CountBy()
  34. Use Task.CompletedTask
  35. Remove ConfigureAwait(false)
  36. Use System.Threading.Lock for lock fields
  37. Use LINQ AggregateBy()
  38. Use LINQ Index()
  39. Use Frozen collections instead of Immutable
  40. Use \e escape sequence
  41. Find non-generic JsonStringEnumConverter
  42. Find IDistributedCache usage (HybridCache in .NET 9)