Skip to content
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

Improve messaging of CA1861 #6642

Merged
merged 4 commits into from
May 21, 2023
Merged

Improve messaging of CA1861 #6642

merged 4 commits into from
May 21, 2023

Conversation

buyaa-n
Copy link
Member

@buyaa-n buyaa-n commented May 19, 2023

Updating messaging of CA1861 to apply the suggestion if the array argument is not mutated within the invoked method

Related to dotnet/runtime#86229 (comment) and dotnet/runtime#86414

@danmoseley
Copy link
Member

Worth also adding the caveat -- "and if the called method is called repeatedly" or something ?

@buyaa-n
Copy link
Member Author

buyaa-n commented May 19, 2023

the called method is called repeatedly

Updated message: Prefer 'static readonly' fields over constant array arguments if the called method is not mutating the passed array and it is called repeatedly

Description: Constant arrays passed as arguments are not reused when called repeatedly, which implies a new array is created each time. Consider extracting them to 'static readonly' fields to improve performance if the passed array is not mutated within the called method.

@codecov
Copy link

codecov bot commented May 19, 2023

Codecov Report

Merging #6642 (26abac4) into main (c2fd19b) will decrease coverage by 0.01%.
The diff coverage is n/a.

❗ Current head 26abac4 differs from pull request most recent head d233646. Consider uploading reports for the commit d233646 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6642      +/-   ##
==========================================
- Coverage   96.40%   96.40%   -0.01%     
==========================================
  Files        1377     1377              
  Lines      322008   322008              
  Branches    10434    10434              
==========================================
- Hits       310438   310429       -9     
- Misses       9081     9089       +8     
- Partials     2489     2490       +1     

…CoreAnalyzersResources.resx

Co-authored-by: Dan Moseley <danmose@microsoft.com>
@buyaa-n buyaa-n enabled auto-merge (squash) May 21, 2023 05:00
@buyaa-n buyaa-n merged commit 9d77d84 into dotnet:main May 21, 2023
10 of 11 checks passed
@github-actions github-actions bot added this to the vNext milestone May 21, 2023
@buyaa-n buyaa-n deleted the update-message branch May 22, 2023 01:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants