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
A method can return both the base abstract type and a derived type, and the analyzer erroneously suggests changing the return type to the derived type.
Steps To Reproduce
[Fact]publicstaticasyncTaskRepro(){conststringSource=@" #nullable enable using System; using System.IO; namespace Example { internal static class C { private static Stream GetStream(int i) { if (i == 0) { return Stream.Null; } return new MyStream(); } } } public class MyStream : MemoryStream { } ";awaitTestCSAsync(Source);}
Expected behavior
No warning.
Actual behavior
// /0/Test0.cs(11,47): info CA1859: Change return type of method 'GetStream' from 'System.IO.Stream' to 'MyStream' for improved performance
VerifyCS.Diagnostic(UseConcreteTypeAnalyzer.CA1859).WithSpan(11, 47, 11, 56).WithArguments("GetStream", "System.IO.Stream", "MyStream"),
Analyzer
Diagnostic ID: CA1859
Analyzer source
6ae2683
Describe the bug
A method can return both the base abstract type and a derived type, and the analyzer erroneously suggests changing the return type to the derived type.
Steps To Reproduce
Expected behavior
No warning.
Actual behavior
cc: @geeknoid, @buyaa-n
The text was updated successfully, but these errors were encountered: