Skip to content

typeof(THandler).GetMethod(nameof(CliAction.InvokeAsync) pattern #2207

Open
@KalleOlaviNiemitalo

Description

@KalleOlaviNiemitalo

As used in HostingExtensions.UseCommandHandler<THandler>(this CliCommand command):

public static CliCommand UseCommandHandler<THandler>(this CliCommand command)
where THandler : CliAction
{
command.Action = CommandHandler.Create(typeof(THandler).GetMethod(nameof(CliAction.InvokeAsync)));
return command;
}

This seems incompatible with explicit override supported by Visual Basic, i.e. where THandler has a method that overrides CliAction.InvokeAsync but is not itself named InvokeAsync.

Besides, GetMethod will fail due to ambiguity if THandler has multiple public methods named InvokeAsync, which is possible in C# too.

Originally posted by @KalleOlaviNiemitalo in #2205 (comment)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions