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
classRepro{voidM(PartialClassc){// ❌ CS0229 Ambiguity between 'PartialClass.Prop' and 'PartialClass.Prop'_=c.Prop;_=c.Prop;// Yep, error still here._=newPartialClass(0).Prop;// No error here!_=c.Prop;// ERROR DISAPPEARS_=c.Prop;// IT'S STILL GONE}}
The text was updated successfully, but these errors were encountered:
It looks like there is a race around merging of partial members that can be observed in the following unit-tests.
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/76651")]
public void PartialMemberAmbiguity_01()
{
var source1 = """
class Repro
{
void M(PartialClass c)
{
_ = c.Prop;
}
}
""";
var source2 = """
class PartialClass(int p)
{
public partial string Prop => null;
public partial string Prop { get; }
}
""";
var comp = CreateCompilation([source1, source2]);
var tree = comp.SyntaxTrees[0];
var model = comp.GetSemanticModel(tree, ignoreAccessibility: false);
model.GetDiagnostics().Verify(
// (5,15): error CS0229: Ambiguity between 'PartialClass.Prop' and 'PartialClass.Prop'
// _ = c.Prop;
Diagnostic(ErrorCode.ERR_AmbigMember, "Prop").WithArguments("PartialClass.Prop", "PartialClass.Prop").WithLocation(5, 15)
);
}
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/76651")]
public void PartialMemberAmbiguity_02()
{
var source1 = """
class Repro
{
void M(PartialClass c)
{
c.M();
}
}
""";
var source2 = """
class PartialClass(int p)
{
public partial string M() => null;
public partial string M();
}
""";
var comp = CreateCompilation([source1, source2]);
var tree = comp.SyntaxTrees[0];
var model = comp.GetSemanticModel(tree, ignoreAccessibility: false);
model.GetDiagnostics().Verify(
// (5,11): error CS0121: The call is ambiguous between the following methods or properties: 'PartialClass.M()' and 'PartialClass.M()'
// c.M();
Diagnostic(ErrorCode.ERR_AmbigCall, "M").WithArguments("PartialClass.M()", "PartialClass.M()").WithLocation(5, 11)
);
}
Version Used: 17.13.0 Preview 2.1
Thanks to @RoccoZero who reported that this issue has been happening for a few months.
.csproj
File 1
File 2
The text was updated successfully, but these errors were encountered: