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

Address CA1862 cases to diagnose and to fix and improve messages #6928

Merged
merged 17 commits into from
Sep 16, 2023

Conversation

carlossanlop
Copy link
Member

@carlossanlop carlossanlop commented Sep 13, 2023

  • Modify unit tests to fix the cases that should only offer a diagnostic but no fix.
  • Add comments to the unit tests to more easily find the test cases.
  • Fix the analyzer and fixer logic.
  • Improve the messages.

The two main changes are:

  • That we won't offer a fix when the user combines cultures (for example: ToUpper vs ToUpperInvariant).
  • The description has a warning for the user that they need to test the fix if they decide to apply it, or use Ordinal if needed.

@carlossanlop carlossanlop changed the title Test PR - no merge, no review [Draft] Address CA1862 cases to diagnose and to fix and improve messages Sep 13, 2023
@carlossanlop carlossanlop changed the title [Draft] Address CA1862 cases to diagnose and to fix and improve messages Address CA1862 cases to diagnose and to fix and improve messages Sep 14, 2023
@carlossanlop carlossanlop marked this pull request as ready for review September 14, 2023 22:59
@carlossanlop carlossanlop requested a review from a team as a code owner September 14, 2023 22:59
Copy link
Member

@tarekgh tarekgh left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks @carlossanlop for getting this done!

Will be good if @buyaa-n can take a look too.

Copy link
Contributor

@mavasani mavasani left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@carlossanlop
Copy link
Member Author

There are a lot of failures in the CI that Visual Studio is not showing. I was able to see them in my local machine by running the tests in the console using dotnet test.

Very frustrating. Between this blind spot and the Roslyn suggestions that show up in CI but not in the IDE, the experience has been painful with Visual Studio.

@carlossanlop
Copy link
Member Author

carlossanlop commented Sep 15, 2023

OK I figured out the problem. The tests that are failing are the ones where the arguments are named and they are passed unordered.

  • In C#, the order passed by the user is respected when retrieving them from IInvocationOperation.Arguments.
  • But in Visual Basic, IInvocationOperation.Arguments reorders the arguments to their original order as defined in the method signature.

The C# tests are currently failing because I thought both languages restored the order to the original one, but C# needs to respect the order passed by the user.

I will split the tests and will provide different expected data for VB and in C#.

@codecov
Copy link

codecov bot commented Sep 15, 2023

Codecov Report

Merging #6928 (b54971d) into main (f2007ac) will decrease coverage by 0.01%.
Report is 13 commits behind head on main.
The diff coverage is 94.64%.

@@            Coverage Diff             @@
##             main    #6928      +/-   ##
==========================================
- Coverage   96.40%   96.39%   -0.01%     
==========================================
  Files        1396     1402       +6     
  Lines      330443   332159    +1716     
  Branches    10891    11061     +170     
==========================================
+ Hits       318564   320195    +1631     
- Misses       9152     9195      +43     
- Partials     2727     2769      +42     

@carlossanlop
Copy link
Member Author

Finally, green CI! 🎉

Copy link
Contributor

@buyaa-n buyaa-n left a comment

Choose a reason for hiding this comment

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

Added some comment mostly for messaging, overall LGTM, thank you!

@carlossanlop carlossanlop merged commit 8611d76 into dotnet:main Sep 16, 2023
11 checks passed
@carlossanlop
Copy link
Member Author

/backport to release/8.0

@carlossanlop carlossanlop deleted the FixCA1862 branch September 16, 2023 04:31
@github-actions
Copy link
Contributor

@github-actions
Copy link
Contributor

@carlossanlop an error occurred while backporting to release/8.0, please check the run log for details!

Error: The specified backport target branch release/8.0 wasn't found in the repo.

@carlossanlop
Copy link
Member Author

/backport to release/8.0.1xx

@github-actions
Copy link
Contributor

Started backporting to release/8.0.1xx: https://github.com/dotnet/roslyn-analyzers/actions/runs/6205301140

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.

5 participants