-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Labels
Area-CompilersFeature - Simple ProgramsTop-level statementsTop-level statementsTestTest failures in roslyn-CITest failures in roslyn-CITest-GapDescribes a specific feature or scenario that does not have test coverageDescribes a specific feature or scenario that does not have test coverage
Milestone
Description
Championed issue: dotnet/csharplang#2765
Speclet: https://github.com/dotnet/csharplang/blob/master/proposals/top-level-statements.md
Compiler:
- Language version errors (LanguageVersion_01, Scope_03, Scope_06)
- Top-level statements across multiple compilation units (Simple_03, Simple_05)
- Locals and local functions defined and used in distinct compilation units (Simple_06_02, Simple_07, LocalUsedBeforeDeclaration_01, LocalUsedBeforeDeclaration_02, LocalUsedBeforeDeclaration_03, LocalUsedBeforeDeclaration_04, NullableRewrite_01, Scope_02, Scope_03, Scope_05, Scope_06, Scope_16, Scope_18, Scope_20, Scope_22, Scope_24)
- Locals re-defined in distinct compilation units (LocalDeclarationStatement_07)
- Top-level statements before
usingdeclarations and after namespaces and type declarations - Statements as top-level statements including:
-
;,{ } - labels,
goto,break,continue,return -
yield return,yield break,await
-
- Member declarations as top-level statements including: fields, events, methods, properties, indexers, operators, explicit implementations
-
$Program.$Mainhas expected signature:- Parameter:
string[] args - Return type:
void,int,Task, orTask<int>depending on explicitreturnstatements and use ofawait - Use-site errors for types used in
$Programand$Maindeclarations
- Parameter:
- Command-line arguments are available from
string[] args - Top-level statements combined with explicit declaration of valid
Mainentry point- Consider
-main:<type>option
- Consider
- Top-level statements when compiling a library, a net module, a .winmd
-
SymbolDisplayand diagnostics containing$Programand$Main - Variable scope:
- Locals, local functions, and
argsparameter names used and redefined in top-level statements and local functions - Locals, local functions, and
argsparameter names used and redefined inusingstatements and type declarations, in same and distinct compilation units
- Locals, local functions, and
- All valid and invalid modifiers for locals and local functions
- Attributes on locals and local functions
- Capturing of locals and
argsparameter in local functions - Emit and execution of top-level statements and local functions
- Local function with extension method
thisargument - Flow analysis of top-level statements
- Definite assignment for single and multiple compilation units
- Unreachable code
- Nullable analysis for single and multiple compilation units
- Unsafe code in top-level statements with/without
unsafeblock, with/without-unsafecommand-line option- LDM question: should unsafe code be allowed without
unsafeblock?
- LDM question: should unsafe code be allowed without
-
$Mainis used for[CallerMemberName]arguments - Explicit
returnstatement in some branches only:if (expr) { return 1; } - Locals named
awaitandasync - Add "Top-level statements" to compiler test plan
-
reflocals withawait -
refescaping (e.g. storingSpan<int>from astackalloclocal in a field)
Public API:
-
ISymbolinstances for$Programand$Main -
IOperationfor single and multiple compilation units - CFG for locals and local functions in single and multiple compilation units
- Analyzer actions for single an multiple compilation units
-
LookupSymbolsandLookupNames:- For single and multiple compilation units
- In
usingstatements before top-level statements - In type declarations after top-level statements
Productivity:
- Completion on
args - QuickInfo and GoToDefinition on
args - Semantic classification of
args(maybe should be colored similarly tovaluein property setter)
Debugging (compiler):
-
$Mainis correctly marked as an entry point in the PDB - F10 on a console app project with top-level code, the debugger stops at the first statement of the top-level code (for both async and sync code)
- Expression Evaluator works in the context of top-level code (usings,
argsand locals are in scope when evaluating expression in context of top-level code) - Edit and Continue - emit delta works (adding a top-level type, top-level local function, updating body of a top-level local function, modifying statements in top-level code) (EnC is currently not working in a compilation with top-level statements A change in a top-level statement or an addition of a new top-level statement is not picked up by ENC #44196)
Debugging (IDE):
- Edit and Continue works end-to-end (EnC is currently not working in a compilation with top-level statements A change in a top-level statement or an addition of a new top-level statement is not picked up by ENC #44196)
FYI @AlekseyTs
Reactions are currently unavailable
Metadata
Metadata
Labels
Area-CompilersFeature - Simple ProgramsTop-level statementsTop-level statementsTestTest failures in roslyn-CITest failures in roslyn-CITest-GapDescribes a specific feature or scenario that does not have test coverageDescribes a specific feature or scenario that does not have test coverage