Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Async main doc #18081

Merged
merged 2 commits into from
Apr 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions docs/features/async-main.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Async Task Main
## [dotnet/csharplang proposal](https://github.com/dotnet/csharplang/blob/master/proposals/async-main.md)

## Technical Details

* The compiler must recognize `Task` and `Task<int>` as valid entrypoint return types in addition to `void` and `int`.
* The compiler must allow `async` to be placed on a main method that returns a `Task` or a `Task<T>` (but not void).
* The compiler must generate a shim method `$EntrypointMain` that mimics the arguments of the user-defined main.
* `static async Task Main(...)` -> `static void $EntrypointMain(...)`
* `static async Task<int> Main(...)` -> `static int $EntrypointMain(...)`
* The parameters between the user-defined main and the generated main should match exactly.
* The body of the generated main should be `return Main(args...).GetAwaiter().GetResult();`
56 changes: 56 additions & 0 deletions docs/features/async-main.test.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
Main areas to test:
* Signature acceptance / rejection
* Method body creation

# Signature acceptance / rejection

## Single Mains
Classes that contain only a single "main" method

### Single legal main
* Past: Ok
* New 7: Ok
* New 7.1 Ok

### Single async (void) main
* Past: ERR (Async can't be main)
* New 7: ERR (Update to get this to work)
* New 7.1: Ok

### Single async (Task) main
* Past: ERR (No entrypoints found), WARN (has the wrong signature to be an entry point)
* New 7: ERR (Update to get this to work)
* New 7.1 Ok

### Single async (Task<int>) main
* Past: ERR (No entrypoints found), WARN (has the wrong signature)
* New 7: ERR (Update to get this to work)
* New 7.1: Ok

## Multiple Mains
Classes that contain more than one main

### Multiple legal mains
* Past: Err
* New 7: Err
* New 7.1: Err

### Single legal main, single async (void) main
* Past: Err (an entrypoint cannot be marked with async)
* New 7: Err (new error here?)
* New 7.1: Err (new error here? "void is not an acceptable async return type")

### Single legal main, single legal Task main
* Past: Ok (warning: task main has wrong signature)
* New 7: Ok (new warning here)
* New 7.1: Ok (new warning here?)

### Single legal main, single legal Task<int> main
* Past: Ok (warning: task main has wrong signature)
* New 7: Ok (new warning here)
* New 7.1: Ok (new warning here?)

# Method body creation

* Inspect IL for correct codegen.
* Make sure that attributes are correctly applied to the synthesized mains.