Why is Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsNotNull()
declared as:
public static void IsNotNull(Object value)
and not:
public static void IsNotNull<T>(T value) where T : class
I just think that some less experienced developers will pass in a value type thinking that it will throw an exception if the value is 0.
UPDATE: Is there a way to constrain the parameter to a reference type in C# 1.0?
As I said in a comment, the answer to "why" is because generics were not available in C# 1.0 when Assert.IsNotNull was written. Changing it, while arguably (much) more correct, has the potential to break existing code. For better or worse, Microsoft places a very high priority on keeping existing code working.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With