AssertionCondition on this parameter not working.

/// /// Will Assert in debug build when obj is null. /// ]]>
[Conditional("DEBUG")]



public static void CantBeNull]]>( this T obj) where T : class
{
if (obj == null)
{
Debug.Assert(false, "Object of type '" + typeof(T) + "' can't be null.");
}
}

This method doesn't work as it should, if I would replace the parameters as in (this string test, T obj) and call "".CantBeNull(someObj) then it works.

But now Resharper still says on the first following call that the obj could generate a NullReferenceException.

someObj.CantBeNull(); // Doesn't work
"".CantBeNull(someObj); // With the changed parameters does work

2 comments
Comment actions Permalink

Hello,

We appreciate your feedback. The corresponding JIRA request has been created,
and you are welcome to monitor its status at http://www.jetbrains.net/jira/browse/RSRP-59340.

You may want to check our request tracking policy here: http://www.jetbrains.net/confluence/display/ReSharper/ReSharperIssueTracker

Best regards,
- Development Team.


0
Comment actions Permalink

Seems like it is fixed already :)

0

Please sign in to leave a comment.