To me this seems like purely an issue of preference. If it bugs you that much, you could always subclass the NullReferenceException
and change the message. :)
What it comes down to though is the amount of information available when the message is created. Without manually passing in some extra information, simply determining the name of the field that was null inside the NullReferenceException
would require reflection (possibly quite a bit), which is a rather heavy-load operation. Take for example the ArgumentNullException
, in order to throw one in which the message indicates the offending parameter name, you have to pass in a string when you call it: throw new ArgumentNullException("param1")
.
The level of detail in an exception message is entirely up to the programmer who defines it, but it's prudent to avoid doing anything system intensive when throwing an exception.