Browse Source

[CodeIssue] ConstantConditionIssue: use 'true'/'false' instead of 'True'/'False' in title

newNRvisualizers
Mansheng Yang 13 years ago
parent
commit
90c1b11416
  1. 8
      ICSharpCode.NRefactory.CSharp/Refactoring/CodeIssues/ConstantConditionIssue.cs

8
ICSharpCode.NRefactory.CSharp/Refactoring/CodeIssues/ConstantConditionIssue.cs

@ -94,12 +94,14 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring @@ -94,12 +94,14 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
var value = (bool)resolveResult.ConstantValue;
var conditionalExpr = condition.Parent as ConditionalExpression;
var ifElseStatement = condition.Parent as IfElseStatement;
var valueStr = value.ToString ().ToLower ();
if (conditionalExpr != null) {
var replaceExpr = value ? conditionalExpr.TrueExpression : conditionalExpr.FalseExpression;
AddIssue (condition, ctx.TranslateString ("Replace '?:' with '" + value + "' branch"),
AddIssue (condition, ctx.TranslateString ("Replace '?:' with '" + valueStr + "' branch"),
script => script.Replace (conditionalExpr, replaceExpr.Clone ()));
} else if (ifElseStatement != null) {
AddIssue (condition, ctx.TranslateString ("Replace 'if' with '" + value + "' branch"),
AddIssue (condition, ctx.TranslateString ("Replace 'if' with '" + valueStr + "' branch"),
script => {
var statement = value ? ifElseStatement.TrueStatement : ifElseStatement.FalseStatement;
var blockStatement = statement as BlockStatement;
@ -121,7 +123,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring @@ -121,7 +123,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
script.FormatText (ifElseStatement.Parent);
});
} else {
AddIssue (condition, ctx.TranslateString ("Replace expression with '" + value + "'"),
AddIssue (condition, ctx.TranslateString ("Replace expression with '" + valueStr + "'"),
script => script.Replace (condition, new PrimitiveExpression (value)));
}
}

Loading…
Cancel
Save