diff --git a/ICSharpCode.Decompiler/CSharp/Transforms/PrettifyAssignments.cs b/ICSharpCode.Decompiler/CSharp/Transforms/PrettifyAssignments.cs index fc18a8442..a6aaa16aa 100644 --- a/ICSharpCode.Decompiler/CSharp/Transforms/PrettifyAssignments.cs +++ b/ICSharpCode.Decompiler/CSharp/Transforms/PrettifyAssignments.cs @@ -37,6 +37,8 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms /// class PrettifyAssignments : DepthFirstAstVisitor, IAstTransform { + TransformContext context; + public override void VisitAssignmentExpression(AssignmentExpression assignment) { base.VisitAssignmentExpression(assignment); @@ -52,13 +54,12 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms } } } - // TODO: context.Settings.IntroduceIncrementAndDecrement - if (assignment.Operator == AssignmentOperatorType.Add || assignment.Operator == AssignmentOperatorType.Subtract) { + if (context.Settings.IntroduceIncrementAndDecrement && assignment.Operator == AssignmentOperatorType.Add || assignment.Operator == AssignmentOperatorType.Subtract) { // detect increment/decrement var rr = assignment.Right.GetResolveResult(); if (rr.IsCompileTimeConstant && rr.Type.IsCSharpPrimitiveIntegerType() && CSharpPrimitiveCast.Cast(rr.Type.GetTypeCode(), 1, false).Equals(rr.ConstantValue)) { // only if it's not a custom operator - if (assignment.Annotation() == null && assignment.Annotation() == null) { + if (assignment.Annotation() == null && assignment.Annotation() == null && assignment.Annotation() == null) { UnaryOperatorType type; // When the parent is an expression statement, pre- or post-increment doesn't matter; // so we can pick post-increment which is more commonly used (for (int i = 0; i < x; i++)) @@ -121,6 +122,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms void IAstTransform.Run(AstNode node, TransformContext context) { + this.context = context; node.AcceptVisitor(this); } }