Skip to content

Test plan for "top-level statements" feature #43563

@jcouv

Description

@jcouv

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 using declarations 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.$Main has expected signature:
    • Parameter: string[] args
    • Return type: void, int, Task, or Task<int> depending on explicit return statements and use of await
    • Use-site errors for types used in $Program and $Main declarations
  • Command-line arguments are available from string[] args
  • Top-level statements combined with explicit declaration of valid Main entry point
    • Consider -main:<type> option
  • Top-level statements when compiling a library, a net module, a .winmd
  • SymbolDisplay and diagnostics containing $Program and $Main
  • Variable scope:
    • Locals, local functions, and args parameter names used and redefined in top-level statements and local functions
    • Locals, local functions, and args parameter names used and redefined in using statements and type declarations, in same and distinct compilation units
  • All valid and invalid modifiers for locals and local functions
  • Attributes on locals and local functions
  • Capturing of locals and args parameter in local functions
  • Emit and execution of top-level statements and local functions
  • Local function with extension method this argument
  • 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 unsafe block, with/without -unsafe command-line option
    • LDM question: should unsafe code be allowed without unsafe block?
  • $Main is used for [CallerMemberName] arguments
  • Explicit return statement in some branches only: if (expr) { return 1; }
  • Locals named await and async
  • Add "Top-level statements" to compiler test plan
  • ref locals with await
  • ref escaping (e.g. storing Span<int> from a stackalloc local in a field)

Public API:

  • ISymbol instances for $Program and $Main
  • IOperation for 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
  • LookupSymbols and LookupNames:
    • For single and multiple compilation units
    • In using statements 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 to value in property setter)

Debugging (compiler):

  • $Main is 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, args and 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):

FYI @AlekseyTs

Metadata

Metadata

Labels

Area-CompilersFeature - Simple ProgramsTop-level statementsTestTest failures in roslyn-CITest-GapDescribes a specific feature or scenario that does not have test coverage

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions