|
|
|
@ -64,7 +64,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring |
|
|
|
|
|
|
|
|
|
|
|
void CheckExpressionInAutoCallContext(Expression expression) |
|
|
|
void CheckExpressionInAutoCallContext(Expression expression) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (expression is InvocationExpression) { |
|
|
|
if (expression is InvocationExpression && !processedNodes.Contains(expression)) { |
|
|
|
CheckInvocationInAutoCallContext((InvocationExpression)expression); |
|
|
|
CheckInvocationInAutoCallContext((InvocationExpression)expression); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -75,12 +75,12 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring |
|
|
|
if (memberExpression == null) { |
|
|
|
if (memberExpression == null) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
var resolveResult = ctx.Resolve(invocationExpression) as CSharpInvocationResolveResult; |
|
|
|
if (memberExpression.MemberName != "ToString" || invocationExpression.Arguments.Any ()) { |
|
|
|
if (resolveResult == null) { |
|
|
|
|
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
var member = resolveResult.Member; |
|
|
|
|
|
|
|
if (member.Name != "ToString" || member.Parameters.Count != 0) { |
|
|
|
var resolveResult = ctx.Resolve(invocationExpression) as CSharpInvocationResolveResult; |
|
|
|
|
|
|
|
if (resolveResult == null) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
AddRedundantToStringIssue(memberExpression, invocationExpression); |
|
|
|
AddRedundantToStringIssue(memberExpression, invocationExpression); |
|
|
|
@ -88,9 +88,8 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring |
|
|
|
|
|
|
|
|
|
|
|
void AddRedundantToStringIssue(MemberReferenceExpression memberExpression, InvocationExpression invocationExpression) |
|
|
|
void AddRedundantToStringIssue(MemberReferenceExpression memberExpression, InvocationExpression invocationExpression) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (processedNodes.Contains(invocationExpression)) { |
|
|
|
// Simon Lindgren 2012-09-14: Previously there was a check here to see if the node had already been processed
|
|
|
|
return; |
|
|
|
// This has been moved out to the callers, to check it earlier for a 30-40% run time reduction
|
|
|
|
} |
|
|
|
|
|
|
|
processedNodes.Add(invocationExpression); |
|
|
|
processedNodes.Add(invocationExpression); |
|
|
|
|
|
|
|
|
|
|
|
AddIssue(memberExpression.DotToken.StartLocation, invocationExpression.RParToken.EndLocation, |
|
|
|
AddIssue(memberExpression.DotToken.StartLocation, invocationExpression.RParToken.EndLocation, |
|
|
|
@ -176,7 +175,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring |
|
|
|
void CheckTargetedObject(InvocationExpression invocationExpression, IType type, IMember member) |
|
|
|
void CheckTargetedObject(InvocationExpression invocationExpression, IType type, IMember member) |
|
|
|
{ |
|
|
|
{ |
|
|
|
var memberExpression = invocationExpression.Target as MemberReferenceExpression; |
|
|
|
var memberExpression = invocationExpression.Target as MemberReferenceExpression; |
|
|
|
if (memberExpression != null) { |
|
|
|
if (memberExpression != null && !processedNodes.Contains(invocationExpression)) { |
|
|
|
if (type.IsKnownType(KnownTypeCode.String) && member.Name == "ToString") { |
|
|
|
if (type.IsKnownType(KnownTypeCode.String) && member.Name == "ToString") { |
|
|
|
AddRedundantToStringIssue(memberExpression, invocationExpression); |
|
|
|
AddRedundantToStringIssue(memberExpression, invocationExpression); |
|
|
|
} |
|
|
|
} |
|
|
|
|