You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
Proposal: parameterless-struct-constructors.md
Branch: features/struct-ctors
-langversion
:PublicParameterlessConstructor
)FieldInitializers_01
)public
and non-public
ctors declared in source (seePublicParameterlessConstructor
vs.NonPublicParameterlessConstructor_01
)extern
andunsafe
are valid ctor modifiers: this()
and: base()
initializers:: base()
initializer disallowed: this()
initializer allowed from other ctors (seeThisInitializer_01
): this(arg0, ...)
initializer allowed from parameterless ctor (seeThisInitializer_02
)record struct
parameterless ctor must include: this(arg0, ...)
(seeTypeDeclaration_ParameterlessConstructor_OtherConstructors
)default
ignores parameterless ctornew()
invokes parameterless ctor:new S()
andnew S { ... }
(seePublicParameterlessConstructor
)new S()
andnew S { ... }
in expression tree (seeExpressionTrees
)new T()
withwhere T : struct
andwhere T : new()
(seePublicParameterlessConstructor
)FieldInitializers_01
andFieldInitializers_02
)FieldInitializers_01
andFieldInitializers_02
)FieldInitializers_None
)FieldInitializers_None
)FieldInitializers_None
): this()
initializer with/without parameterless ctor (seeThisInitializer_03
): this(arg0, ...)
initializer (seeThisInitializer_03
)record struct
with cases above and: (seeTypeDeclaration_ParameterlessConstructor_Initializers
)()
()
(arg0, ...)
NullableAnalysis_*
)new S()
in parameter default value ifS
has parameterless ctor (seeParameterDefaultValues_*
)new T()
withwhere T : struct
orwhere T : new()
on desktop framework: dotnet/roslyn-analyzers/issues/5272The text was updated successfully, but these errors were encountered: