Skip to content

Use NameOf with open generic types #122

Open
@craigajohnson

Description

@craigajohnson

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!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions