Browse Source

Gate decrement conversion behind IntroduceIncrementAndDecrement

Operator precedence made the condition read
(setting && Add) || Subtract, so 'x -= 1' was converted to 'x--' even
with IntroduceIncrementAndDecrement disabled. Only observable with the
non-default setting, which no fixture configuration exercises, so no
test accompanies the fix.

Assisted-by: Claude:claude-fable-5:Claude Code
pull/3953/head
Siegfried Pammer 1 month ago committed by Siegfried Pammer
parent
commit
8873983ff9
  1. 2
      ICSharpCode.Decompiler/CSharp/Transforms/PrettifyAssignments.cs

2
ICSharpCode.Decompiler/CSharp/Transforms/PrettifyAssignments.cs

@ -74,7 +74,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms @@ -74,7 +74,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
}
}
}
if (context.Settings.IntroduceIncrementAndDecrement && assignment.Operator == AssignmentOperatorType.Add || assignment.Operator == AssignmentOperatorType.Subtract)
if (context.Settings.IntroduceIncrementAndDecrement && assignment.Operator is AssignmentOperatorType.Add or AssignmentOperatorType.Subtract)
{
// detect increment/decrement; ++/-- on float/double compiles to the same IL as
// adding/subtracting a constant 1 (which both types represent exactly), so a

Loading…
Cancel
Save