Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add CollectionExpression support to CA1870 (UseSearchValues)#7252

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

@MihaZupan
Copy link
Member

Followup after#6898 to add recognition for collection expression patterns as well.

Currently, if you write something like

privatestaticreadonlychar[]s_chars=new[]{'a','e','i','o','u','A'};publicstaticintTest(ReadOnlySpan<char>s)=>s.IndexOfAny(s_chars);

you will be offered two fixers: one to replaces_chars withSearchValues.Create("aeiouA"), and the other to replace the array creation with['a', 'e', 'i', 'o', 'u', 'A'].
If you accept the latter, you won't be offered theSearchValues fixer anymore since we don't recognize the pattern.

This PR adds recognition for patterns like

staticreadonlychar[]s_chars=['a','e','i','o','u','A'];text.IndexOfAny(['a','e','i','o','u','A']);text.IndexOfAny([(byte)'a',(byte)'e',(byte)'i',(byte)'o',(byte)'u',(byte)'A']);text.IndexOfAny(s_chars);

@MihaZupanMihaZupan requested a review froma team as acode ownerMarch 19, 2024 21:39
@MihaZupan
Copy link
MemberAuthor

cc:@stephentoub

@codecov
Copy link

codecovbot commentedMar 19, 2024

Codecov Report

Attention: Patch coverage is86.82171% with17 lines in your changes are missing coverage. Please review.

Project coverage is 96.47%. Comparing base(de3a920) to head(3692f88).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@##             main    #7252     +/-   ##=========================================  Coverage   96.47%   96.47%             =========================================  Files        1436     1440      +4       Lines      342881   344487   +1606       Branches    11292    11340     +48     =========================================+ Hits       330797   332356   +1559- Misses       9230     9262     +32- Partials     2854     2869     +15

@MihaZupan
Copy link
MemberAuthor

@dotnet/roslyn-analysis who would be the right person to review this one?

Copy link

@buyaa-nbuyaa-n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

LGTM, I will let@CyrusNajmabadi take another look

Copy link
Member

@CyrusNajmabadiCyrusNajmabadi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Looks reasonable to me :-)

buyaa-n reacted with thumbs up emoji
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@CyrusNajmabadiCyrusNajmabadiCyrusNajmabadi left review comments

+1 more reviewer

@buyaa-nbuyaa-nbuyaa-n approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@MihaZupan@CyrusNajmabadi@buyaa-n

[8]ページ先頭

©2009-2025 Movatter.jp