-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19436 from dotnet/features/async-main
Merge Features/async main
- Loading branch information
Showing
27 changed files
with
2,339 additions
and
376 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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();` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
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. | ||
|
||
## Broken methods on Task and Task<T> | ||
|
||
* GetAwatier or GetResult are missing | ||
* GetAwaiter or GetResult don't have the required signature | ||
* Has the right shape, but types are missing | ||
|
||
## Task or Task<T> is missing | ||
|
||
This will be caught during entrypoint detection, should be a binding error. | ||
|
||
## Void or int is missing | ||
|
||
If Task can be found, but void or int can't be found, then the compiler should behave gracefully. | ||
|
||
# Vlad Test Plan | ||
|
||
## Public interface of compiler APIs | ||
-N/A? | ||
|
||
## General functionality | ||
- `Task` and `Task<int>` returns are allowed. Do we require `async`. | ||
- Multiple valid/invalid async candidates. | ||
- process exit code on success (void and int) and on exception | ||
- `/main:<type>` cmd switch is still functional | ||
|
||
## Old versions, compat | ||
- langver | ||
- when both async and regular Main avaialble. With old/new compiler versions. | ||
- async void Main. With old.new langver. With another applicable Main present. | ||
|
||
## Type and members | ||
- Access modifiers (public, protected, internal, protected internal, private), static modifier | ||
- Parameter modifiers (ref, out, params) | ||
- STA attribute | ||
- Partial method | ||
- Named and optional parameters | ||
- `Task<dynamic>` | ||
- Task-Like types | ||
|
||
## Debug | ||
- F11 works | ||
- stepping through Main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.