fluffynuts / NExpect

An assertions framework for .NET with a BDD-like feel, inspired by Chai and Jasmine, designed to be user-extensible
BSD 3-Clause "New" or "Revised" License
22 stars 8 forks source link

Null assertion not being recognized by IDE #17

Closed sduduzog closed 4 years ago

sduduzog commented 4 years ago

This is not a trains mash but it would be nice to have that 'Possible NullReferenceException' underline go away when I've expected it not to be. See screenshots image

image

fluffynuts commented 4 years ago

I've brought this up with JetBrains before. Apparently there are ways to annotate code to help with the warnings (these warnings are from R#). However, those methods are only capable of doing so at the original call site -- in other words, there's (apparently) no way for those annotations to "recognise" that Expect(campaignTemplateResult) will chain on to Not.To.Be.Null(); this is why you don't get the warning if using NUnit's Assert.That(foo, Is.Not.Null) or Assert.IsNotNull(foo) -- because, in both cases, there's a single function call which can be correctly decorated to help the R# engine to figure out that, by the next line, foo won't be null.

It may be time for me to see if there's not a hacky method to bypass this, but I'm not very optimistic that I'll find one, based on the conversation I've already had with JetBrains, sorry ):