Skip to content

All fluent APIs defined by Option<T> and Argument<T> should return generic value #1963

Closed

Description

@adamsitnik

While working on unblocking SDK with latest S.CL update in dotnet/sdk#29012 I've realized that in #1951 we have moved argument and option extension methods to the types themselves, but unfortunately, we have also made these methods non-generic. It does not allow to re-use the returned value when we need a generic value.

Example:

public static readonly Argument<string> CmdPackageArgument = new Argument<string>(LocalizableStrings.CmdPackage)
{
    Description = LocalizableStrings.CmdPackageDescription
}.AddCompletions((context) => QueryNuGet(context.WordToComplete).Select(match => new CompletionItem(match)));

// currently `AddCompletions` returns an `Argument` rather than `Argument<string>`
 Cannot implicitly convert type 'System.CommandLine.Argument' to 'System.CommandLine.Argument<string>'. An explicit
 conversion exists

cc @jozkee @jonsequitur

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions