Open
Description
Analyzer
Diagnostic ID: CA1859: Use concrete types when possible for improved performance
Analyzer source
SDK: 9.0.101
Describe the bug
When a method's return type is object
and the returned value is an anonymous type (new { Name = "Alex" }
) the analyzer suggests changing the method's return type from object
to <anonymous type: string Name>
. Of course, this return type is invalid.
Steps To Reproduce
Console.WriteLine(BuildObject());
private static object BuildObject() // Triggers CA1859
{
var outputData = new
{
Name = "Alex"
};
return outputData;
}
Expected behavior
Shouldn't trigger the CA1859 rule.
Actual behavior
Triggers the CA1859 rule.
Metadata
Metadata
Assignees
Labels
No labels
Activity