Possible Null Reference Exception and Assert.IsNotNull()

I'm sure I remember seeing this covered before, but I can't find the
discussion, and can't figure away around this.

I have an MSTest test class, and it has a line something like this:

MyDerivedClass foo = myBaseVar as MyDerivedClass;
Assert.IsNotNull(foo);
var testValue = foo.SomeMethod();

ReSharper is flagging the last line as a possible null reference exception,
in spite of the fact that the Assert.IsNotNull(foo) ensures that foo is
not-null by the time that executes.

I'd like to get rid of the warning marker in the side bar, but I cannot
recall how to go about this. Shoudln't ReSharper already have appropriate
external annotations to cover the built-in MSTest assert methods?

Thanks for any info...

2 comments

Those annotations are added in ReSharper 4.5.1 RC, that will be released soon.

0

Thank you!

"Victor Kropp" <no_reply@jetbrains.com> wrote in message
news:33518870.144111247496850682.JavaMail.clearspace@app8.labs.intellij.net...

Those annotations are added in ReSharper 4.5.1 RC, that will be released
soon.

>

---
Original message URL:
http://www.jetbrains.net/devnet/message/5241733#5241733


0

Please sign in to leave a comment.