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) { } }
The text was updated successfully, but these errors were encountered:
IDE0300
Can you please move this to Roslyn-anayzers? GitHub is not letting me do that.
Sorry, something went wrong.
No branches or pull requests
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:
The text was updated successfully, but these errors were encountered: