Skip to content

Speakable names for top-level statements #54877

@jcouv

Description

@jcouv

We'll treat this as a bug (not a language feature) and document the breaking change.

Top-level statements will be emitted into a type named Program:

partial class Program
{
    public static ... <Main>$(...)
    {
        /* top-level statements */
    }
}

https://github.com/dotnet/csharplang/blob/main/meetings/2021/LDM-2021-07-12.md#speakable-names-for-top-level-statements

Motivating scenario from ASP.NET:

//Test Application (xunit for example):
[Fact] 
public async Task HelloWorld()
{
    var webApplicationFactory = new WebApplicationFactory<Program>(); // type -> assembly -> entry point
    var content = await webApplicationFactory.Client.GetStringAsync(http://localhost/);
    Assert.Equal("Hello World", content);
}

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions