1
lorentz
17d

My new favourite RUNTIME c# error, evidently thrown by the standard library because the string is not present in the project:

"no parameterless constructor defined for this object"

Comments
  • 2
    1. why would you do this
    2. why not take 5 steps back and do something that doesn't need reflection when you're about to write this
    3. why not NAME THE FUCKING TYPE IN THE MESSAGE
  • 1
    - parent class has no parameterless ctor
    - descendants must have parameterless ctor

    I am forced to pass null to a parameter that is not explicitly documented as nullable. I'm gonna set something on fire and you best hope it's a cigarette.
  • 1
    Not naming things in error messages seems to be some kind of principled stance for some people.

    Non-nullable reference types in C# are an abomination and should have been strangled at birth.
  • 0
    @donkulator Why is the ability to pass a value that's not supported desirable?
  • 1
    @lorentz Why stop at nulls? Should Math.Sqrt(x) require a non-negative double instead of just a double?

    Maybe if the language was designed from the ground up to support constraints like that, it wouldn't be too bad. But non-nullable reference types in C# have been bodged on over the top and are just confusing.
  • 0
    @donkulator Arguably container-style Option would've been a better choice because it works better with generics, but I think null is a big enough problem that a solution that works most of the time is still desirable.
Add Comment