Open craigajohnson opened 7 years ago
Love it!
I think we have more latitude in VB than in C# because NameOf is a proper keyword (like GetType) so we wouldn't need to make as much of the binder resilient to unexpected open generic types. I wonder if we can just substitute Object
or Integer
for the type arguments behind the scenes to simplify the implementation (would the hack bleed through to the IDE?). Certainly that approach could be taken to implement a prototype.
C# issue here.
NameOf is a proper keyword
wait, when that happened? could it break existing code?
NameOf
was a proper keyword in VB from the start. We considered the risk, spoke with community members (MVPs specifically) and made that design decision. It was based on several factors including:
CUInt
, GetXmlNamespace
and we have never added a semantically conditional keyword to VB before (like C#s var
or dynamic
keywords).
I have a project which invokes late-bound calls on various methods/properties of a type inheriting from a generic base class. To guard against a breaking refactor, I use NameOf. This is all fine and good except I must specify a dummy class name in order to use NameOf.
Example:
This change would result in a nice code cleanup. I imagine it could be a gnarly change for a relatively unusual case though!