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

Avoid direct descriptor comparison, so the fix can be shown #7296

Merged
merged 2 commits into from Apr 29, 2024

Conversation

DoctorKrolic
Copy link
Contributor

Fixes: #4539

It turned out that despite DiagnosticDescriptor class is fully equatable, it isn't safe to compare instances in a codefix due to localized strings. For whatever reason all localizable strings in diagnostic.Descriptor are fixed strings while singleton descriptor instances in tha analyzer contain localizable resource strings, so the comparison could never succeed and thus fixes were not shown. I guess, this might be due to serialization-deserialization between devenv and roslyn OOP. To avoid that I made it so that diagnostics are now identified via Rule property, which is correctly passed between analyzer and a codefix provider. I've made a local setup where I verified, that this actually resolves the problem and the fix is finally shown. I don't really like the proposed fix, but that is a story for another PR)

@DoctorKrolic DoctorKrolic requested a review from a team as a code owner April 17, 2024 14:41
Copy link

codecov bot commented Apr 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.47%. Comparing base (b07c100) to head (aba7cf1).
Report is 2 commits behind head on main.

❗ Current head aba7cf1 differs from pull request most recent head 37a5a32. Consider uploading reports for the commit 37a5a32 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7296      +/-   ##
==========================================
- Coverage   96.48%   96.47%   -0.01%     
==========================================
  Files        1443     1443              
  Lines      345394   345395       +1     
  Branches    11364    11364              
==========================================
- Hits       333240   333237       -3     
- Misses       9275     9278       +3     
- Partials     2879     2880       +1     

@sharwell sharwell enabled auto-merge April 29, 2024 16:20
@DoctorKrolic

This comment was marked as resolved.

@dotnet dotnet deleted a comment from azure-pipelines bot Apr 29, 2024
@sharwell sharwell merged commit bc8aca0 into dotnet:main Apr 29, 2024
8 checks passed
@DoctorKrolic DoctorKrolic deleted the fix-rs1024-codefix branch April 29, 2024 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RS1024 has no code fix
2 participants