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

[Backport] Fix CA2021 false positive for generic class types #7493

Merged
merged 2 commits into from
Dec 5, 2024

Conversation

JoeRobich
Copy link
Member

Backport of #7488

Fix for #7357.

#7183 changed the CastWillAlwaysFail(ITypeSymbol castFrom, ITypeSymbol castTo) to work with castFrom.OriginalDefinition/castTo.OriginalDefinition, eliding the generic type information in order to fix issues with interfaces, but that appears to have broken the check for class types. This reverts just the class type case to use the castFrom/castTo types passed in instead of the .OriginalDefinition. I'm not sure I quite understand why that's the only place this matters, but I tried a few variations with structs and interfaces and couldn't get any other false positives.

@JoeRobich JoeRobich requested a review from a team as a code owner December 2, 2024 22:43
@JoeRobich JoeRobich changed the title Fix/enumerable casts/7357 9.0.1xx [Backport] Fix CA2021 false positive for generic class types Dec 2, 2024
Copy link

codecov bot commented Dec 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.49%. Comparing base (3d61c57) to head (f9a1058).
Report is 3 commits behind head on release/9.0.1xx.

Additional details and impacted files
@@               Coverage Diff                @@
##           release/9.0.1xx    #7493   +/-   ##
================================================
  Coverage            96.49%   96.49%           
================================================
  Files                 1443     1443           
  Lines               345885   345928   +43     
  Branches             11374    11374           
================================================
+ Hits                333765   333810   +45     
+ Misses                9238     9236    -2     
  Partials              2882     2882           

@JoeRobich JoeRobich requested a review from sharwell December 4, 2024 01:28
@JoeRobich JoeRobich merged commit 5bfaf6a into release/9.0.1xx Dec 5, 2024
14 checks passed
@JoeRobich JoeRobich deleted the fix/enumerable-casts/7357-9.0.1xx branch December 5, 2024 18:49
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.

3 participants