The following example raises a wrong RCS1074 diagnostic in L7 (tested with Roslynator 4.15.0, .NET 10.0.300)
public readonly struct Foo
{
public bool B { get; init; }
public bool A { get; init; } = true;
public Foo()
{
}
}
Wrong, because removing the constructor leads to error CS8983: A 'struct' with field initializers must include an explicitly declared constructor.
After changing the order of properties A and B the diagnostic is not reported:
public readonly struct Foo
{
public bool A { get; init; } = true;
public bool B { get; init; }
public Foo()
{
}
}
The following example raises a wrong RCS1074 diagnostic in L7 (tested with Roslynator 4.15.0, .NET 10.0.300)
Wrong, because removing the constructor leads to error CS8983: A 'struct' with field initializers must include an explicitly declared constructor.
After changing the order of properties
AandBthe diagnostic is not reported: