← All recipes
Moderne licensed

Convert static Main entry point to top-level statements

Recipe IDOpenRewrite.Recipes.CSharp.Migration.Dotnet.Net5.ConvertMainToTopLevelStatementsArtifactOpenRewrite.Recipes.CSharp.Migration.Dotnet

Converts a class Program { static Main(...) { ... } } entry point to C# 9 top-level statements: the body of Main is lifted to the file level and the Program class and any enclosing namespace are removed. Scoped to the unambiguous single-type/single-Main case.

Single recipecsharpdotnetmigrationtop-level-statementsProprietary

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.Net5.ConvertMainToTopLevelStatements

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

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