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
The analyzer appears to not be factoring in whether methods from interfaces are implemented explicitly, resulting in warnings that, if fixed, will result in broken code.
Steps To Reproduce
[Fact]publicstaticasyncTaskRepro(){conststringSource=@" #nullable enable interface IFoo { int M(); } internal class C : IFoo { int IFoo.M() => 42; } internal class Use { static int Bar() { IFoo f = new C(); return f.M(); } } ";awaitTestCSAsync(Source);}
Expected behavior
No warning.
Actual behavior
info CA1859: Change type of variable 'f' from 'IFoo' to 'C' for improved performance
but if the developer tries to change the variable to type C, it'll fail to compile because there's no available M() to call.
Analyzer
Diagnostic ID: CA1859
Analyzer source
6ae2683
Describe the bug
The analyzer appears to not be factoring in whether methods from interfaces are implemented explicitly, resulting in warnings that, if fixed, will result in broken code.
Steps To Reproduce
Expected behavior
No warning.
Actual behavior
but if the developer tries to change the variable to type
C
, it'll fail to compile because there's no availableM()
to call.cc: @geeknoid, @buyaa-n
The text was updated successfully, but these errors were encountered: