dotnet / dotnet/vblang

Use NameOf with open generic types

Open
#122 5 comments 0 reactions 0 assignees View on GitHub
Approved-in-Principle Proposal Prototype-Needed
Dominant language
No language data
Stars
328
Forks
71
PR merge metrics
No merged PRs in 30d

Description

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:

```
Sub Main()
'workaround - no inherent value in having to specify type
Console.WriteLine(NameOf(Grover(Of Object).Lichen))

'preferable
Console.WriteLine(NameOf(Grover(Of ).Lichen))
End Sub

Public Class Grover(Of T)
Public Function Lichen() As Integer
Return 23
End Function
End Class
```

This change would result in a nice code cleanup. I imagine it could be a gnarly change for a relatively unusual case though!

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.