Open shpaass opened 1 month ago
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! I'm currently searching for a way to disable all inspections that "may change code meaning", but I haven't found a list on the internet. MSDN articles of the inspections (IDE0078 for instance) also don't mention this aspect.
Is there a list of such inspections somewhere? If not, then what can I do to compile such a list?
@CyrusNajmabadi thank you for the triage! I'm currently searching for a way to disable all inspections that "may change code meaning", but I haven't found a list on the internet. MSDN articles of the inspections (IDE0078 for instance) also don't mention this aspect.
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)
@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.