-
Notifications
You must be signed in to change notification settings - Fork 479
Closed
Labels
Area-CodeFixBug in code fixerBug in code fixerBugThe product is not behaving according to its current intended designThe product is not behaving according to its current intended designgood first issuehelp wantedThe issue is up-for-grabs, and can be claimed by commentingThe issue is up-for-grabs, and can be claimed by commenting
Milestone
Description
Analyzer
Diagnostic ID: CA1861: Extract to static readonly field
Analyzer source
SDK: Built-in CA analyzers in .NET 5 SDK or later
Version: SDK 8.0.0-rc2
Describe the bug
CA1861 code fix creates a new field that can have the same name as a local variable
Steps To Reproduce
Original code:
class Sample
{
void A(char separator)
{
"".Split(new char[] { 'a', 'b' });
}
}After code fix:
class Sample
{
internal static readonly char[] separator = new char[] { 'a', 'b' };
void A(char separator)
{
// "separator" is the local parameter instead of the static field
"".Split(separator);
}
}Expected behavior
Generate a unique name
Actual behavior
Additional context
Metadata
Metadata
Assignees
Labels
Area-CodeFixBug in code fixerBug in code fixerBugThe product is not behaving according to its current intended designThe product is not behaving according to its current intended designgood first issuehelp wantedThe issue is up-for-grabs, and can be claimed by commentingThe issue is up-for-grabs, and can be claimed by commenting