Skip to content

Extract array of const to static readonly field #33794

Closed
dotnet/roslyn-analyzers
#5383

Description

@terrajobst

Arrays of const passed to known methods on types like System.String (e.g. IndexOfAny(new[] { ',', '.' })) can be lifted out to static readonly fields.

Category: Performance

Activity

  1. added this to the 5.0 milestone on Mar 20, 2020
  2. jeffhandley commented on Mar 21, 2020

    @jeffhandley
    Member

    Estimates:

    • Analyzer: Small
    • Fixer: Large
  3. added
    api-approvedAPI was approved in API review, it can be implemented
    and removed
    untriagedNew issue has not been triaged by the area owner
    api-suggestionEarly API idea and discussion, it is NOT ready for implementation
    on Mar 21, 2020
  4. jeffhandley commented on May 26, 2020

    @jeffhandley
    Member

    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.

  5. added
    good first issueIssue should be easy to implement, good for first-time contributors
    on May 26, 2020
  6. modified the milestones: 5.0, Future on May 26, 2020
  7. jeffhandley commented on May 26, 2020

    @jeffhandley
    Member

    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.

  8. 5 remaining items

  9. teo-tsirpanis commented on Dec 28, 2020

    @teo-tsirpanis
    Contributor

    Such optimization could be automatically done by the compiler for methods that accept a ReadOnlySpan.

  10. modified the milestones: 6.0.0, Future on Jul 12, 2021
  11. steveberdy commented on Jul 20, 2021

    @steveberdy
    Contributor

    @buyaa-n I would like this assigned to me. Thanks.

  12. modified the milestones: Future, 7.0.0 on Aug 20, 2021
  13. removed
    help wanted[up-for-grabs] Good issue for external contributors
    on Sep 1, 2021
  14. added
    in-prThere is an active PR which will close this issue when it is merged
    on Nov 23, 2021
  15. modified the milestones: 7.0.0, Future on Jul 9, 2022
  16. modified the milestones: Future, 8.0.0 on Nov 9, 2022
  17. ghost locked as resolved and limited conversation to collaborators on Jun 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

api-approvedAPI was approved in API review, it can be implementedarea-System.Runtimecode-analyzerMarks an issue that suggests a Roslyn analyzercode-fixerMarks an issue that suggests a Roslyn code fixerin-prThere is an active PR which will close this issue when it is merged

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions