Browse Source

Fix NullReferenceException in IncorrectExceptionParameterOrderingIssue.

newNRvisualizers
Daniel Grunwald 13 years ago
parent
commit
ad431543a3
  1. 4
      ICSharpCode.NRefactory.CSharp/Refactoring/CodeIssues/IncorrectExceptionParameterOrderingIssue.cs
  2. 1
      ICSharpCode.NRefactory.Tests/CSharp/CodeIssues/IncorrectExceptionParameterOrderingTests.cs

4
ICSharpCode.NRefactory.CSharp/Refactoring/CodeIssues/IncorrectExceptionParameterOrderingIssue.cs

@ -63,8 +63,8 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
return; return;
var firstParam = parameters.FirstOrNullObject() as PrimitiveExpression; var firstParam = parameters.FirstOrNullObject() as PrimitiveExpression;
var secondParam = parameters.LastOrNullObject() as PrimitiveExpression; var secondParam = parameters.LastOrNullObject() as PrimitiveExpression;
if (firstParam == null || firstParam.Value.GetType() != typeof(string) || if (firstParam == null || !(firstParam.Value is string) ||
secondParam == null || firstParam.Value.GetType() != typeof(string)) secondParam == null || !(secondParam.Value is string))
return; return;
var type = context.Resolve(objectCreateExpression.Type) as TypeResolveResult; var type = context.Resolve(objectCreateExpression.Type) as TypeResolveResult;
if (type == null) if (type == null)

1
ICSharpCode.NRefactory.Tests/CSharp/CodeIssues/IncorrectExceptionParameterOrderingTests.cs

@ -79,6 +79,7 @@ class A
throw new ArgumentException (""The parameter 'blah' can not be null"", ""blah""); throw new ArgumentException (""The parameter 'blah' can not be null"", ""blah"");
throw new ArgumentOutOfRangeException (""blah"", ""The parameter 'blah' can not be null""); throw new ArgumentOutOfRangeException (""blah"", ""The parameter 'blah' can not be null"");
throw new DuplicateWaitObjectException (""blah"", ""The parameter 'blah' can not be null""); throw new DuplicateWaitObjectException (""blah"", ""The parameter 'blah' can not be null"");
throw new ArgumentOutOfRangeException (""blah"", 42);
} }
}"; }";
TestRefactoringContext context; TestRefactoringContext context;

Loading…
Cancel
Save