KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I do not want to disable the warnings completely, just when it's in an Assert statement. So for example if I have the following two lines var someObject = GetObject(); Assert.IsNotNull(someObject, "someObject should not be null"); Assert.AreEqual(expectedValue, someObject.SomeProperty); I'll get the possible null reference warning on the second line on someObject.SomeProperty . Is it possible to disable the warning when it is within a certain call, like Assert.AreEqual ? Since this is an issue with a lot of unit tests, I don't want to litter the tests with the ReSharper disable code. Right now the only option I can think of is to change every Assert.IsNotNull call to be var someObject = GetObject(); if(someObject == null) { Assert.Fail("someObject is null"); return; } Although this kind of seems to defeat the purpose of having Assert.IsNotNull in the first place. Just wondering if there is a better way.
Tags (comma-separated)
Save Edits
Cancel