-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
IDE0078: Code Cleanup applied IDE0078 and broke the code #75122
Comments
We should probably disable the pattern matching logic if there is a variable passed by-ref. It strongly indicates a mutation across calls that can't be elided. |
@CyrusNajmabadi thank you for the triage! Is there a list of such inspections somewhere? If not, then what can I do to compile such a list? |
All fixers can change code meaning. (Not joking) |
This inspection broke some of our code: dotnet/roslyn#75122 On a side note, it turns out that all inspection-fixers can change code meaning, so none of the inspections are safe. IDE0078: Use pattern matching: https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0078-ide0260
This inspection broke some of our code: dotnet/roslyn#75122 On a side note, it turns out that all inspection-fixers can change code meaning, so none of the inspections are safe. IDE0078: Use pattern matching: https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0078-ide0260
This inspection broke some of our code: dotnet/roslyn#75122 On a side note, it turns out that all inspection-fixers can change code meaning, so none of the inspections are safe. IDE0078: Use pattern matching: https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0078-ide0260
This inspection broke some of our code: dotnet/roslyn#75122 On a side note, it turns out that all inspection-fixers can change code meaning, so none of the inspections are safe. IDE0078: Use pattern matching: https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0078-ide0260
@sharwell Can you make it so that "Apply Code Cleanup" does not automatically apply the CSharpUsePatternCombinatorsDiagnosticAnalyzer fixes to diagnostics that do not have hte "safe" property attached to them. I do not know how 'code cleanup' makes its determinations. Thanks. |
On an unrelated note, apologies for the commit spam. I was rebasing after squashes. |
Version Used: Microsoft Visual Studio Community 2022 (64-bit) - Current Version 17.11.2
Steps to Reproduce:
git clone https://github.com/shpaass/yafc-ce.git
git checkout cd421ef319f9dd354757b5898500bfb13c72f140
yafc-ce/FactorioCalc.sln
in Visual Studio.Use pattern matching (may change code meaning)
.From
To
The expression now has one read operation instead of two, and is always true, which would lead to a guaranteed exception.
Diagnostic Id:
"IDE0078: Use pattern matching"
Expected Behavior: The line is not changed or changed without breaking the code.
Actual Behavior: The line is changed. The change broke the code.
The text was updated successfully, but these errors were encountered: