-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Open
Open
Copy link
Labels
Area-CompilersFeature - Extension EverythingThe extension everything featureThe extension everything feature
Milestone
Description
This issue is referenced in source.
The following scenario illustrates a diagnostic produced by check in CheckPropertyValueKind
which may not be applicable for extension properties.
[Fact]
public void ExtensionMemberLookup_ObjectInitializer_Conversion_02()
{
var src = """
_ = new System.ReadOnlySpan<string>() { Property = 42 };
new System.ReadOnlySpan<string>().Property = 43;
class C { }
static class E
{
extension(System.ReadOnlySpan<object> s)
{
public int Property { set { } }
}
}
""";
// Tracked by https://github.com/dotnet/roslyn/issues/76130 : consider adjusting receiver requirements for extension members
var comp = CreateCompilation(src, targetFramework: TargetFramework.Net90);
comp.VerifyEmitDiagnostics(
// (1,41): error CS0131: The left-hand side of an assignment must be a variable, property or indexer
// _ = new System.ReadOnlySpan<string>() { Property = 42 };
Diagnostic(ErrorCode.ERR_AssgLvalueExpected, "Property").WithLocation(1, 41),
// (3,1): error CS0131: The left-hand side of an assignment must be a variable, property or indexer
// new System.ReadOnlySpan<string>().Property = 43;
Diagnostic(ErrorCode.ERR_AssgLvalueExpected, "new System.ReadOnlySpan<string>().Property").WithLocation(3, 1));
}
Relates to test plan #76130
Metadata
Metadata
Assignees
Labels
Area-CompilersFeature - Extension EverythingThe extension everything featureThe extension everything feature