Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Tracked by #1891
adamsitnik opened this issue Nov 14, 2022 · 0 comments · Fixed by #1964
Closed
Tracked by #1891

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

adamsitnik opened this issue Nov 14, 2022 · 0 comments · Fixed by #1964
Assignees
Labels
Milestone

Comments

@adamsitnik
Copy link
Member

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
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant