-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
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 array of const to static readonly field #33794
Comments
Estimates:
|
Moving this one out of .NET 5, but this would be a good warmup analyzer for someone, and it would be a high-value analyzer in .NET 6 because it applies to some recently added APIs. |
The hardest part of this one will be coming up with the list of APIs we want this to target--using a heuristic is the recommended approach. Beyond that, we think the analyzer will be pretty easy; the fixer will have some edge cases to consider for how to rewrite the code to reflect the definition/usage of the const--simply extracting the const won't necessarily be straightforward, and there will need to be an ordered list of approaches to apply. |
Cannot optimization like this be done by the compiler? |
Such optimization could be automatically done by the compiler for methods that accept a |
@buyaa-n I would like this assigned to me. Thanks. |
Arrays of
const
passed to known methods on types likeSystem.String
(e.g.IndexOfAny(new[] { ',', '.' })
) can be lifted out tostatic readonly
fields.Category: Performance
The text was updated successfully, but these errors were encountered: