Skip to content

Commit

Permalink
Fix NRE in AssigningSymbolAndItsMemberInSameStatement analyzer
Browse files Browse the repository at this point in the history
  • Loading branch information
mavasani committed Oct 2, 2019
1 parent 6c05175 commit 8047d1f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
Expand Up @@ -80,8 +80,8 @@ private void AnalyzeAssignment(OperationAnalysisContext context)
{
assignmentOperation = (ISimpleAssignmentOperation)assignmentOperation.Value;

var operationValue = assignmentOperation.Target as T;
if (equalityComparer(instance, operationValue))
if (assignmentOperation.Target is T operationValue &&
equalityComparer(instance, operationValue))
{
return true;
}
Expand Down
Expand Up @@ -329,6 +329,22 @@ public unsafe void Method(Test a, Test *b)
b->PtrField = a.PtrField;
}
}
");
}

[Fact]
[WorkItem(2889, "https://github.com/dotnet/roslyn-analyzers/issues/2889")]
public void CSharpAssignmentLocalReferenceOperation()
{
VerifyCSharp(@"
public static class Class1
{
public static void Foo()
{
var u = new System.UriBuilder();
u.Host = u.Path = string.Empty;
}
}
");
}
}
Expand Down

0 comments on commit 8047d1f

Please sign in to comment.