AssertionCondition on this parameter not working.

/// /// Will Assert in debug build when obj is null. /// ]]>

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

Comment actions Permalink


We appreciate your feedback. The corresponding JIRA request has been created,
and you are welcome to monitor its status at

You may want to check our request tracking policy here:

Best regards,
- Development Team.

Comment actions Permalink

Seems like it is fixed already :)


Please sign in to leave a comment.