Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/xamarin/NRefactory.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Grunwald <daniel@danielgrunwald.de>2014-02-14 21:54:00 +0400
committerDaniel Grunwald <daniel@danielgrunwald.de>2014-02-14 21:54:00 +0400
commitaa289c252a3eb21bd10154d78e9752227f468290 (patch)
tree182f3f84b844272a6924bde1dfa7ea8a4e53b438 /ICSharpCode.NRefactory.CSharp.Refactoring
parent9db72dc8379ba196abf48f13ad57c1989e4efaa2 (diff)
Fix potential NullReferenceException in OperatorIsCanBeUsedIssue.
Diffstat (limited to 'ICSharpCode.NRefactory.CSharp.Refactoring')
-rw-r--r--ICSharpCode.NRefactory.CSharp.Refactoring/CodeIssues/Synced/CodeQuality/OperatorIsCanBeUsedIssue.cs23
1 files changed, 6 insertions, 17 deletions
diff --git a/ICSharpCode.NRefactory.CSharp.Refactoring/CodeIssues/Synced/CodeQuality/OperatorIsCanBeUsedIssue.cs b/ICSharpCode.NRefactory.CSharp.Refactoring/CodeIssues/Synced/CodeQuality/OperatorIsCanBeUsedIssue.cs
index 47e86ec0..bed5eb33 100644
--- a/ICSharpCode.NRefactory.CSharp.Refactoring/CodeIssues/Synced/CodeQuality/OperatorIsCanBeUsedIssue.cs
+++ b/ICSharpCode.NRefactory.CSharp.Refactoring/CodeIssues/Synced/CodeQuality/OperatorIsCanBeUsedIssue.cs
@@ -24,6 +24,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.using System;
+using System.Linq;
using ICSharpCode.NRefactory.PatternMatching;
using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.NRefactory.Semantics;
@@ -64,25 +65,13 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
if (!m.Success)
return;
- Expression identifier = null;
- AstType type = null;
-
- if (binaryOperatorExpression.Left is TypeOfExpression && binaryOperatorExpression.Right is InvocationExpression) {
- type = (binaryOperatorExpression.Left as TypeOfExpression).Type;
- var right = binaryOperatorExpression.Right as InvocationExpression;
- identifier = (right.Target as MemberReferenceExpression).Target;
- } else if (binaryOperatorExpression.Right is TypeOfExpression && binaryOperatorExpression.Left is InvocationExpression) {
- type = (binaryOperatorExpression.Right as TypeOfExpression).Type;
- var left = binaryOperatorExpression.Left as InvocationExpression;
- identifier = (left.Target as MemberReferenceExpression).Target;
- } else
- return;
-
- if (identifier == null || type == null)
+ Expression identifier = m.Get<Expression>("a").Single();
+ AstType type = m.Get<AstType>("b").Single();
+
+ var typeResolved = ctx.Resolve(type) as TypeResolveResult;
+ if (typeResolved == null)
return;
- var typeResolved = ctx.Resolve(type) as TypeResolveResult;
-
if (typeResolved.Type.Kind == TypeKind.Class) {
if (!typeResolved.Type.GetDefinition().IsSealed) {
return;