-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Labels
Bughelp wantedIssues that we would accept external contributions on. Also known as up-for-grabs.Issues that we would accept external contributions on. Also known as up-for-grabs.untriagedRequest triage from a team memberRequest triage from a team member
Description
Analyzer
Diagnostic ID: CA1859: Use concrete types when possible for improved performance
Describe the bug
Analyzer isn't considering interfaces with default implementations, resulting in warnings that if fixed will cause a compilation error.
Steps To Reproduce
interface I1
{
string Test() => string.Empty;
}
sealed class C1 : I1
{ }
static void UseClass(C1 c1)
{
I1 i1 = c1;
Console.WriteLine(i1.Test());
}
Expected behavior
No warning
Actual behavior
info: CA1859 Change type of variable 'i1' from 'Console1.I1' to 'Console1.C1' for improved performance
but changing the variable to type C1 will cause a compilation error because there's no available Test() to call.
Additional context
It looks like this was fixed for explicit implementations #6416 but not default.
excel-manan, wkronemeijer and Frulfump
Metadata
Metadata
Assignees
Labels
Bughelp wantedIssues that we would accept external contributions on. Also known as up-for-grabs.Issues that we would accept external contributions on. Also known as up-for-grabs.untriagedRequest triage from a team memberRequest triage from a team member
