Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
replace CompletionDelegate with a Func, fixes #1927
  • Loading branch information
adamsitnik committed Nov 3, 2022
commit f99bf0fd9e0b704a4edffac085d621b556265465
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ System.CommandLine
public static class ArgumentExtensions
public static TArgument AddCompletions<TArgument>(this TArgument argument, System.String[] values)
public static TArgument AddCompletions<TArgument>(this TArgument argument, System.Func<System.CommandLine.Completions.CompletionContext,System.Collections.Generic.IEnumerable<System.String>> complete)
public static TArgument AddCompletions<TArgument>(this TArgument argument, System.CommandLine.Completions.CompletionDelegate complete)
public static TArgument AddCompletions<TArgument>(this TArgument argument, System.Func<System.CommandLine.Completions.CompletionContext,System.Collections.Generic.IEnumerable<System.CommandLine.Completions.CompletionItem>> complete)
public static Argument<System.IO.FileInfo> ExistingOnly(this Argument<System.IO.FileInfo> argument)
public static Argument<System.IO.DirectoryInfo> ExistingOnly(this Argument<System.IO.DirectoryInfo> argument)
public static Argument<System.IO.FileSystemInfo> ExistingOnly(this Argument<System.IO.FileSystemInfo> argument)
Expand Down Expand Up @@ -110,7 +110,7 @@ System.CommandLine
.ctor(System.String message, System.Exception innerException)
public static class CompletionSourceExtensions
public static System.Void Add(this System.Collections.Generic.ICollection<System.CommandLine.Completions.ICompletionSource> completionSources, System.Func<System.CommandLine.Completions.CompletionContext,System.Collections.Generic.IEnumerable<System.String>> complete)
public static System.Void Add(this System.Collections.Generic.ICollection<System.CommandLine.Completions.ICompletionSource> completionSources, System.CommandLine.Completions.CompletionDelegate complete)
public static System.Void Add(this System.Collections.Generic.ICollection<System.CommandLine.Completions.ICompletionSource> completionSources, System.Func<System.CommandLine.Completions.CompletionContext,System.Collections.Generic.IEnumerable<System.CommandLine.Completions.CompletionItem>> complete)
public static System.Void Add(this System.Collections.Generic.ICollection<System.CommandLine.Completions.ICompletionSource> completionSources, System.String[] completions)
public static class ConsoleExtensions
public static System.Void Write(this IConsole console, System.String value)
Expand Down Expand Up @@ -210,7 +210,7 @@ System.CommandLine
public static class OptionExtensions
public static TOption AddCompletions<TOption>(this TOption option, System.String[] values)
public static TOption AddCompletions<TOption>(this TOption option, System.Func<System.CommandLine.Completions.CompletionContext,System.Collections.Generic.IEnumerable<System.String>> complete)
public static TOption AddCompletions<TOption>(this TOption option, System.CommandLine.Completions.CompletionDelegate complete)
public static TOption AddCompletions<TOption>(this TOption option, System.Func<System.CommandLine.Completions.CompletionContext,System.Collections.Generic.IEnumerable<System.CommandLine.Completions.CompletionItem>> complete)
public static Option<System.IO.FileInfo> ExistingOnly(this Option<System.IO.FileInfo> option)
public static Option<System.IO.DirectoryInfo> ExistingOnly(this Option<System.IO.DirectoryInfo> option)
public static Option<System.IO.FileSystemInfo> ExistingOnly(this Option<System.IO.FileSystemInfo> option)
Expand Down Expand Up @@ -277,11 +277,6 @@ System.CommandLine.Completions
public abstract class CompletionContext
public System.CommandLine.ParseResult ParseResult { get; }
public System.String WordToComplete { get; }
public delegate CompletionDelegate : System.MulticastDelegate, System.ICloneable, System.Runtime.Serialization.ISerializable
.ctor(System.Object object, System.IntPtr method)
public System.IAsyncResult BeginInvoke(CompletionContext context, System.AsyncCallback callback, System.Object object)
public System.Collections.Generic.IEnumerable<CompletionItem> EndInvoke(System.IAsyncResult result)
public System.Collections.Generic.IEnumerable<CompletionItem> Invoke(CompletionContext context)
public class CompletionItem
.ctor(System.String label, System.String kind = Value, System.String sortText = null, System.String insertText = null, System.String documentation = null, System.String detail = null)
public System.String Detail { get; }
Expand Down
6 changes: 3 additions & 3 deletions src/System.CommandLine/ArgumentExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static TArgument AddCompletions<TArgument>(
/// </summary>
/// <typeparam name="TArgument">The type of the argument.</typeparam>
/// <param name="argument">The argument for which to add completions.</param>
/// <param name="complete">A <see cref="CompletionDelegate"/> that will be called to provide completions.</param>
/// <param name="complete">A function that will be called to provide completions.</param>
/// <returns>The option being extended.</returns>
public static TArgument AddCompletions<TArgument>(
this TArgument argument,
Expand All @@ -52,11 +52,11 @@ public static TArgument AddCompletions<TArgument>(
/// </summary>
/// <typeparam name="TArgument">The type of the argument.</typeparam>
/// <param name="argument">The argument for which to add completions.</param>
/// <param name="complete">A <see cref="CompletionDelegate"/> that will be called to provide completions.</param>
/// <param name="complete">A function that will be called to provide completions.</param>
/// <returns>The configured argument.</returns>
public static TArgument AddCompletions<TArgument>(
this TArgument argument,
CompletionDelegate complete)
Func<CompletionContext, IEnumerable<CompletionItem>> complete)
where TArgument : Argument
{
argument.Completions.Add(complete);
Expand Down
4 changes: 2 additions & 2 deletions src/System.CommandLine/CompletionSourceExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ public static void Add(
/// Adds a completion source using a delegate.
/// </summary>
/// <param name="completionSources">The list of completion sources to add to.</param>
/// <param name="complete">The delegate to be called when calculating completions.</param>
/// <param name="complete">The function to be called when calculating completions.</param>
public static void Add(
this ICollection<ICompletionSource> completionSources,
CompletionDelegate complete)
Func<CompletionContext, IEnumerable<CompletionItem>> complete)
{
if (completionSources is null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ namespace System.CommandLine.Completions
{
internal class AnonymousCompletionSource : ICompletionSource
{
private readonly CompletionDelegate _complete;
private readonly Func<CompletionContext, IEnumerable<CompletionItem>> _complete;

public AnonymousCompletionSource(CompletionDelegate complete)
public AnonymousCompletionSource(Func<CompletionContext, IEnumerable<CompletionItem>> complete)
{
_complete = complete ?? throw new ArgumentNullException(nameof(complete));
}
Expand Down
13 changes: 0 additions & 13 deletions src/System.CommandLine/Completions/CompletionDelegate.cs

This file was deleted.

6 changes: 3 additions & 3 deletions src/System.CommandLine/OptionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static TOption AddCompletions<TOption>(
/// </summary>
/// <typeparam name="TOption">The type of the option.</typeparam>
/// <param name="option">The option for which to add completions.</param>
/// <param name="complete">A <see cref="CompletionDelegate"/> that will be called to provide completions.</param>
/// <param name="complete">A function that will be called to provide completions.</param>
/// <returns>The option being extended.</returns>
public static TOption AddCompletions<TOption>(
this TOption option,
Expand All @@ -72,11 +72,11 @@ public static TOption AddCompletions<TOption>(
/// </summary>
/// <typeparam name="TOption">The type of the option.</typeparam>
/// <param name="option">The option for which to add completions.</param>
/// <param name="complete">A <see cref="CompletionDelegate"/> that will be called to provide completions.</param>
/// <param name="complete">A function that will be called to provide completions.</param>
/// <returns>The option being extended.</returns>
public static TOption AddCompletions<TOption>(
this TOption option,
CompletionDelegate complete)
Func<CompletionContext, IEnumerable<CompletionItem>> complete)
where TOption : Option
{
option.Argument.Completions.Add(complete);
Expand Down