/// 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