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 parameterless struct constructors #51698

Closed
23 of 31 tasks
cston opened this issue Mar 5, 2021 · 1 comment
Closed
23 of 31 tasks

Test plan for parameterless struct constructors #51698

cston opened this issue Mar 5, 2021 · 1 comment
Assignees
Labels
Milestone

Comments

@cston
Copy link
Member

cston commented Mar 5, 2021

Proposal: parameterless-struct-constructors.md
Branch: features/struct-ctors

  • -langversion:
    • for parameterless ctor (see PublicParameterlessConstructor)
    • for field initializers (see FieldInitializers_01)
  • public and non-public ctors declared in source (see PublicParameterlessConstructor vs. NonPublicParameterlessConstructor_01)
  • extern and unsafe are valid ctor modifiers
  • : this() and : base() initializers:
    • : base() initializer disallowed
    • : this() initializer allowed from other ctors (see ThisInitializer_01)
    • : this(arg0, ...) initializer allowed from parameterless ctor (see ThisInitializer_02)
  • record struct parameterless ctor must include : this(arg0, ...) (see TypeDeclaration_ParameterlessConstructor_OtherConstructors)
  • default ignores parameterless ctor
  • new() invokes parameterless ctor:
    • from new S() and new S { ... } (see PublicParameterlessConstructor)
    • from new S() and new S { ... } in expression tree (see ExpressionTrees)
    • from new T() with where T : struct and where T : new() (see PublicParameterlessConstructor)
  • all fields assigned:
    • all fields have initializers if any have initializers and no ctors (see FieldInitializers_01 and FieldInitializers_02)
    • all fields have initializers or are explicitly assigned in each explicit ctor (see FieldInitializers_01 and FieldInitializers_02)
  • field initializers and initialization order with:
    • no constructors (see FieldInitializers_None)
    • explicit parameterless ctor (see FieldInitializers_None)
    • explicit ctor with parameters (see FieldInitializers_None)
    • explicit ctor with : this() initializer with/without parameterless ctor (see ThisInitializer_03)
    • explicit parameterless ctor with : this(arg0, ...) initializer (see ThisInitializer_03)
  • field initializers and initialization order on record struct with cases above and: (see TypeDeclaration_ParameterlessConstructor_Initializers)
    • no ()
    • ()
    • (arg0, ...)
  • nullability analysis (initial state of fields in ctor bodies) for field initializer cases above (see NullableAnalysis_*)
  • error for new S() in parameter default value if S has parameterless ctor (see ParameterDefaultValues_*)
  • analyzer checks runtime capability and warns for new T() with where T : struct or where T : new() on desktop framework: dotnet/roslyn-analyzers/issues/5272
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Mar 5, 2021
@cston cston added Feature Request and removed untriaged Issues and PRs which have not yet been triaged by a lead labels Mar 5, 2021
@jcouv jcouv self-assigned this Mar 9, 2021
@jcouv jcouv added this to the C# 10 milestone Mar 9, 2021
@jaredpar jaredpar modified the milestones: C# 10, 17.0 Jul 13, 2021
@tmat
Copy link
Member

tmat commented Jul 23, 2021

  • EnC analyzer needs to be updated

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

No branches or pull requests

4 participants