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
After getting no complaints in Visual Studio, compile.
Diagnostic Id: CS0102
Change second file:
file interface IFoo
{
IReadOnlyDictionary<int, string> Bar { get; }
}
internal partial class Foo : IFoo
{
}
(Foo needs to implement IFoo because, elsewhere in the file, an instance of Foo will be passed to a method taking IFoo.)
Visual Studio complains that Foo doesn't implement IFoo.
Compile.
Diagnostic Id: CS0535
Expected Behavior: The compiler recognizes that IFoo.Bar in the part of Foo in one file is different from IFoo.Bar in a different part because each IFoo is file scoped and is therefore a different type. Seeing these as different types, the compiler does not emit CS0102 and compiles the code.
Actual Behavior: The compiler confuses file scoped types with the same name and emits CS0102 and doesn't compile the code.
The text was updated successfully, but these errors were encountered:
Version Used: .NET 7
(Before you think this is a crazy scenario, the use case is generated code.)
Steps to Reproduce:
(Unfortunately, this can't be demonstrated in a gist, because it requires multiple files.)
Diagnostic Id: CS0102
(
Foo
needs to implementIFoo
because, elsewhere in the file, an instance ofFoo
will be passed to a method takingIFoo
.)Visual Studio complains that
Foo
doesn't implementIFoo
.Compile.
Diagnostic Id: CS0535
Expected Behavior: The compiler recognizes that
IFoo.Bar
in the part ofFoo
in one file is different fromIFoo.Bar
in a different part because eachIFoo
is file scoped and is therefore a different type. Seeing these as different types, the compiler does not emit CS0102 and compiles the code.Actual Behavior: The compiler confuses file scoped types with the same name and emits CS0102 and doesn't compile the code.
The text was updated successfully, but these errors were encountered: