-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Description
Should semi-auto properties be treated as auto properties for the purpose of definite assignment?
struct Program
{
// causes CS0843:
// Auto-implemented property must be fully assigned before control is returned to the caller.
int P1 { get; set; }
int P2 { get => field; set => field = value; } // CS0843?
int P3 { get => field; set; } // CS0843?
int P4 { get; set => field = value; } // CS0843?
public Program(int dummy)
{
}
}There is also this scenario:
struct Program
{
struct S1
{
public int AutoProp { get; }
public int SemiAutoProp { get => field; }
public int ManualProp { get => throw null; }
}
S1 x { get; set; }
S1 x2 { get; set; }
S1 x3 { get; set; }
public Program(int dummy) // Error that x must be assigned, no error on x3. What should x2 do?
{
_ = x.AutoProp;
_ = x2.SemiAutoProp;
_ = x3.ManualProp;
}
}ufcpp, lindexi and Unknown6656
Metadata
Metadata
Assignees
Labels
No labels