From ad431543a3ebbfe8eb5105be0651b2035fa60cdf Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Thu, 4 Oct 2012 23:50:15 +0200 Subject: [PATCH] Fix NullReferenceException in IncorrectExceptionParameterOrderingIssue. --- .../CodeIssues/IncorrectExceptionParameterOrderingIssue.cs | 4 ++-- .../CodeIssues/IncorrectExceptionParameterOrderingTests.cs | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeIssues/IncorrectExceptionParameterOrderingIssue.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeIssues/IncorrectExceptionParameterOrderingIssue.cs index dc7ab72d0f..73e5051f52 100644 --- a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeIssues/IncorrectExceptionParameterOrderingIssue.cs +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeIssues/IncorrectExceptionParameterOrderingIssue.cs @@ -63,8 +63,8 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring return; var firstParam = parameters.FirstOrNullObject() as PrimitiveExpression; var secondParam = parameters.LastOrNullObject() as PrimitiveExpression; - if (firstParam == null || firstParam.Value.GetType() != typeof(string) || - secondParam == null || firstParam.Value.GetType() != typeof(string)) + if (firstParam == null || !(firstParam.Value is string) || + secondParam == null || !(secondParam.Value is string)) return; var type = context.Resolve(objectCreateExpression.Type) as TypeResolveResult; if (type == null) diff --git a/ICSharpCode.NRefactory.Tests/CSharp/CodeIssues/IncorrectExceptionParameterOrderingTests.cs b/ICSharpCode.NRefactory.Tests/CSharp/CodeIssues/IncorrectExceptionParameterOrderingTests.cs index 883df7b1d2..1a50b304ca 100644 --- a/ICSharpCode.NRefactory.Tests/CSharp/CodeIssues/IncorrectExceptionParameterOrderingTests.cs +++ b/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 ArgumentOutOfRangeException (""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;