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
CA1859 is falsely raised when multiple derivatives are involved together with custom operator overwrites. Applying the suggested fix leads to compilation errors.
Repro
publicabstractclassBase{publicstaticBaseoperator*(Baseleft,intright)=>default;}publicclassA:Base;
public class B :Base;
public class Test
{privatestaticBaseFoo(Baseinput)// ^^^ CA1859{returninputisA?newB():input*4;}}
Actual behavior
CA1859 is raised for Test.Foo method, suggesting to change the return type to B
Additional context
No warning is raised when either
the operator ist replaced with a method like static Base Multiply(Base, int)
the ternary operator in the return expression of Test.Foo is removed (e.g. return input * 4;)
The text was updated successfully, but these errors were encountered:
Analyzer
Diagnostic ID: CA1859:
Use concrete types when possible for improved performance
Analyzer source
SDK: Built-in CA analyzers in .NET 5 SDK or later
Version: SDK 8.0.101
Describe the bug
CA1859 is falsely raised when multiple derivatives are involved together with custom operator overwrites. Applying the suggested fix leads to compilation errors.
Repro
Actual behavior
CA1859 is raised for
Test.Foo
method, suggesting to change the return type toB
Additional context
No warning is raised when either
operator
ist replaced with a method likestatic Base Multiply(Base, int)
Test.Foo
is removed (e.g.return input * 4;)
The text was updated successfully, but these errors were encountered: