-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Description
Spec: https://github.com/dotnet/csharplang/blob/main/proposals/csharp-11.0/auto-default-structs.md
Championed proposal: dotnet/csharplang#5737
- Provide a discoverable setting to enable all auto-default warnings #60176
- EnC (implicit initializations should occur after sequence point for opening
{in constructor?)
Compiler
- add proposal to dotnet/csharplang (Create auto-default-structs.md csharplang#5964)
- add to compiler test plan
-
-langversion - field initialization:
- when all fields are explicitly assigned
- when no fields are assigned (use
initobj?)- implementation initializes each field individually.
- when no fields
- with auto-properties with
getonly; withset; withinitSemanticErrorTests.CS0843ERR_UnassignedThisAutoProperty,FlowDiagnosticTests.AutoPropInitialization4StructConstructorTests.FieldInitializers_08
- with field-like events
- when all sub-fields of a field are explicitly assigned
- when some sub-fields of a field are explicitly assigned
- when field is conditionally assigned
- when explicitly calling declared constructor
: this(...) - when explicitly calling default parameterless constructor
: this() - when assigning
this = default; - when assigning
this = default;conditionally -
when assigning to backing field of semi-auto property (i.e. using a field initializer)moved to Test plan for "field keyword in properties" #57012 -
when assigning to property of semi-auto property (i.e. in a constructor)moved to Test plan for "field keyword in properties" #57012 - when reading field before assigning
- fields assigned where C#10 produces warnings with
/warn:5 -
record- with explicit fields
- with explicit auto-properties
- disabled-by-default diagnostics:
- when all fields are explicitly assigned
- when no fields are assigned
- when diagnostics are elevated to warnings or errors
-
defaultassigned:- to backing fields of auto-properties
- for field of type parameter type
- for field of
structtype with parameterless constructor - for field of empty
structtype (no assignment?)
- field initialization when parameters have
!!(which runs first?) - nullable analysis treats auto-initialized fields as nullable
-
#pragma warning restoreshould not enable disabled diagnostics
Productivity
- Add new error codes to UpgradeProject fixer
- upgrade from warnings?
- Debugger: reposition to first sequence point in constructor (init fields?)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Language/design