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

Test plan for "Primary Constructors" feature #65697

Closed
AlekseyTs opened this issue Dec 1, 2022 · 0 comments
Closed

Test plan for "Primary Constructors" feature #65697

AlekseyTs opened this issue Dec 1, 2022 · 0 comments

Comments

@AlekseyTs
Copy link
Contributor

AlekseyTs commented Dec 1, 2022

Championed issue: dotnet/csharplang#2691
Speclet: https://github.com/dotnet/csharplang/blob/main/proposals/csharp-12.0/primary-constructors.md
Feature branch: https://github.com/dotnet/roslyn/tree/features/PrimaryConstructors

Compiler

  • language version
  • syntax changes:
    • type Name; for class, struct
    • type Name(...) ... for class, struct
    • type Name(...) : Base(...) ... for class
    • error for type Name(...) : Interface(...) ...
    • error for type Name : Base(...) ...
  • public primary constructor emitted
  • declared constructors must call primary constructor
  • error for declared constructor with matching signature
  • error for primary constructor on multiple partial declarations
  • parameters:
  • attributes on parameters:
    • with no target modifier; with param: target; with other target (disallowed)
    • [CallerMemberName]
    • synthesized attributes: NativeIntegerAttribute, DynamicAttribute, TupleElementNames (see ParameterCapturing_*_SynthesizedAttributes)
  • parameter capturing in class, [readonly] struct, [readonly] ref struct (see ParameterCapturing_*)
  • parameter referenced in:
    • instance methods and property or event accessors (capturing)
    • instance field and property initializers (not capturing)
    • static members (error)
    • const field (error)
    • other constructor (error)
    • this(x) or base(x) initializer (error)
    • : Base(x) initializer (not capturing)
    • lambdas (capturing based on containing context)
    • local function (capturing based on containing member)
    • static lambdas and local functions (error if captured)
    • partial method
  • parameter referenced in:
    • is x
    • x()
    • @x (see ParameterCapturing_011_EscapedIdentifier)
    • nameof(x)
    • lock (x) (see ParameterCapturing_098_Lock)
    • using (x) (see ParameterCapturing_099_Using)
    • x switch { ... } (see ParameterCapturing_099_MultiplePathsToNode_SwitchDispatch_02)
    • deconstruction (see ParameterCapturing_103_Deconstruction)
    • &x (see *AddressOf*)
    • x.F fixed size field (see ParameterCapturing_*FixedSizeBuffer)
    • Color Color (see ParameterCapturing_*_ColorColor_*)
  • error capturing ref, in, out, or ref struct parameters (see IllegalCapturingDueToRefness_*)
  • name shadowing (see ParameterScope) from:
  • definite assignment (see DefiniteAssignment_*)
    • out parameters must be assigned
    • use of out parameters before assignment
    • warning for parameters that are not read
  • dynamic dispatch not allowed for : Base(@dynamic) initializer (see BaseArguments_10)
  • (Add Primary Constructor tests for some scenarios from Test Plan #70056) order of evaluation: field initializers, : Base()
  • Semantic model:
    • primary constructor symbol available from containing type
    • GetDeclaredSymbol()
    • GetSymbolInfo()
    • GetSpeculativeSymbolInfo(), GetSpeculativeTypeInfo()
  • LookupSymbols and LookupNames for parameters
    • in initializers
    • in : Base(x, y)
    • in attributes
    • in members (see ParameterScope)
  • analyzer events:
    • syntax events for primary constructor parameters
    • syntax events for : Base(x, y) arguments
    • symbol events for primary constructor parameters
    • IOperation events for synthesized constructor bodies, parameters, default values
  • XML doc comments:
    • param on containing type and members
    • paramref on containing type and members
    • across partial declarations
  • capturing managed parameter makes struct managed (see ParameterCapturing_056_CapturingOfAManagedParameterMakesStructManaged)
  • struct cycles from capture (see ParameterCapturing_*_Cycle)
  • synthesized constructor not allowed on [ComImport] types
  • parameters (captured or not) referenced in lambda (see *ParameterUsedInLambda_InPrimaryConstructor)
  • warning for captured parameter passed to base constructor (see ParameterCapturing_*CapturedAndPassedToBase*)
  • nullable analysis (see ParameterCapturing_*NullableAnalysis*)
  • parameters are readonly in readonly struct (see ParameterCapturing_*_ReadonlyContext)
  • parameter assignment in readonly struct or readonly method (see ParameterCapturing_*_ReadonlyContext)
  • ref safety analysis of parameter references (see ParameterCapturing_145_ReturnByRef, etc.)
  • (Add "Primary Constructors" to Compiler Test Plan.md #70050) add feature to Compiler Test Plan.md
  • (Add Primary Constructor tests for some scenarios from Test Plan #70056) order of emitted fields with/without explicit fields
  • (Add Primary Constructor tests for some scenarios from Test Plan #70056) error for primary constructor on static class
  • report unused parameters
  • SyntaxNormalizer (SyntaxNormalizerTests.TestSpacingOnPrimaryConstructor/TestSemicolonBody)
  • (Add Primary Constructor tests for some scenarios from Test Plan #70056) structs fulfilling the unmanaged constraint requires binding all members first

Public API

IDE test pass

  • Language version upgrade
  • Type and paste new constructs
  • Completion
    • Type completion for parameters
    • Parameter name completion
      • In base initializer
      • In field initializer
      • In member body
    • Dotting off of parameter name
      • In base initializer
      • In field initializer
      • In member body
    • Identifier highlighting
      • Prefix matching
      • Full identifier matching
  • Formatting
    • Format command
  • Automatic Brace Completion
    • Parameter list
    • Argument list
  • Indentation (typing Enter in an unfinished statement indents the next line)
    • Parameter list
    • Argument list
  • Go To definition
    • For parameter
    • For constructor
  • Find All References
    • For parameters
    • For constructor
  • Colorization
    • Types in parameter list
    • Parameter names
  • Error Squiggles
  • Rename of parameter
  • Change signature (for constructor)
  • Extract method/local function for code referencing parameter


Filed issues:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants