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
    api-suggestion
    code-analyzer
    on Mar 19, 2020
  2. added
    untriaged
    on Mar 19, 2020
  3. added this to the 5.0 milestone on Mar 20, 2020
  4. added
    code-fixer
    on Mar 21, 2020
  5. jeffhandley commented on Mar 21, 2020

    @jeffhandley
    Member

    Estimates:

    • Analyzer: Small
    • Fixer: Large
  6. added
    api-approved
    and removed
    untriaged
    api-suggestion
    on Mar 21, 2020
  7. 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.

  8. added
    good first issue
    on May 26, 2020
  9. modified the milestones: 5.0, Future on May 26, 2020
  10. 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.

  11. 5 remaining items

  12. 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.

  13. modified the milestones: 6.0.0, Future on Jul 12, 2021
  14. steveberdy commented on Jul 20, 2021

    @steveberdy
    Contributor

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

  15. modified the milestones: Future, 7.0.0 on Aug 20, 2021
  16. removed
    help wanted
    on Sep 1, 2021
  17. added
    in-pr
    on Nov 23, 2021
  18. modified the milestones: 7.0.0, Future on Jul 9, 2022
  19. modified the milestones: Future, 8.0.0 on Nov 9, 2022
  20. 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-approvedarea-System.Runtimecode-analyzercode-fixerin-pr

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions