[TODO: follow standard sections, add examples, flesh everything out]
This is a small feature that removes a common frustration: why do I have to pick a generic type argument when the choice has no effect on the evaluation of the expression? It's very odd to require something to be specified within an operand when it has no impact on the result. Notably, typeof
does not suffer from this limitation.
It's not just about code that better expresses itself. Once some arbitrary type argument has been chosen in a nameof
expression, such as object?
, changing a constraint on a type parameter can break uses of nameof
unnecessarily. Insult becomes added to injury in this scenario. Satisfying the type parameter requires declaring a dummy class to implement an interface which is constraining the type parameter. Now there's unused metadata and a strange name invented, all for the purpose of adding a type argument to the nameof
expression, a type argument which `na