We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extract to static readonly field
class Class1(int[] arr); class Class2 : Class1 { public Class2() : base(new int[] { 1, 2, 3 }) { } }
CA1861
new int[] { 1, 2, 3 }
Class2
The suggested static readonly field is generated and the argument is replaced with the field's name:
static readonly
class Class2 : Class1 { private static readonly int[] arr = new int[] { 1, 2, 3 }; // Should respect any applying naming rules. public Class2() : base(arr) { } }
The field is not generated. The argument is replaced with the parameter name:
class Class2 : Class1 { public Class2() : base(arr) { } }
Moved from dotnet/roslyn#72334.
The text was updated successfully, but these errors were encountered:
Successfully merging a pull request may close this issue.
Version Used
Steps to Reproduce
CA1861
will appear on thenew int[] { 1, 2, 3 }
argument inClass2
's call to the base constructor.Expected Behavior
The suggested
static readonly
field is generated and the argument is replaced with the field's name:Actual Behavior
The field is not generated. The argument is replaced with the parameter name:
Moved from dotnet/roslyn#72334.
The text was updated successfully, but these errors were encountered: