Using R# 8.2 with NUnit fluent Asserts

Hi,

I like to use NUnit fluent asserts, but my R# (8.2.1) doesn't seem to recognise them properly.

If I write this:

Assert.NotNull( x );                                        // Traditional NotNull NUnit Assert              
Assert.That( x.y, Is.EqualTo(z) );

Then R# is happy.  It knows that x cannot be null in the code that follows, because the assert prevents it.

If I write this:

Assert.That( x, Is.Not.Null );                         // Fluent NotNull NUnit Assert
Assert.That( x.y, Is.EqualTo(z) );

R# underlines 'x' on the second line in blue and warns me "Possible 'System.NullReferenceException'"

How do I get R# to treat the fluent NotNull Assert in the same way as the non-fluent version, and recognise that after a call to such an Assert there is no possibility of a NullReferenceException being thrown, because the Assert will have triggered on such a condition?

2 comments
Comment actions Permalink

Hello David

  There is the following ticket in YouTrack http://youtrack.jetbrains.com/issue/RSRP-185247 about the same request.

Thanks!

0
Comment actions Permalink

Thanks.  I've added my vote for this to be addressed.

0

Please sign in to leave a comment.