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
Next Next commit
remove CompletionSourceList, expose a ICollection<ICompletionSource> …
…instead:

- it has Add and Clear
- it has no indexer, but we don't need it

fixes #1911
  • Loading branch information
adamsitnik committed Nov 3, 2022
commit d5d965e5c65b226dee5ef7bdac0829f89ee8fbb5
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
System.CommandLine
public abstract class Argument : Symbol, System.CommandLine.Binding.IValueDescriptor, System.CommandLine.Completions.ICompletionSource
public ArgumentArity Arity { get; set; }
public CompletionSourceList Completions { get; }
public System.Collections.Generic.ICollection<System.CommandLine.Completions.ICompletionSource> Completions { get; }
public System.Boolean HasDefaultValue { get; }
public System.String HelpName { get; set; }
public System.Type ValueType { get; }
Expand Down Expand Up @@ -109,16 +109,9 @@ System.CommandLine
.ctor()
.ctor(System.String message, System.Exception innerException)
public static class CompletionSourceExtensions
public static System.Void Add(this CompletionSourceList completionSources, System.Func<System.CommandLine.Completions.CompletionContext,System.Collections.Generic.IEnumerable<System.String>> complete)
public static System.Void Add(this CompletionSourceList completionSources, System.CommandLine.Completions.CompletionDelegate complete)
public static System.Void Add(this CompletionSourceList completionSources, System.String[] completions)
public class CompletionSourceList, System.Collections.Generic.IEnumerable<System.CommandLine.Completions.ICompletionSource>, System.Collections.Generic.IReadOnlyCollection<System.CommandLine.Completions.ICompletionSource>, System.Collections.Generic.IReadOnlyList<System.CommandLine.Completions.ICompletionSource>, System.Collections.IEnumerable
.ctor()
public System.Int32 Count { get; }
public System.CommandLine.Completions.ICompletionSource Item { get; }
public System.Void Add(System.CommandLine.Completions.ICompletionSource source)
public System.Void Clear()
public System.Collections.Generic.IEnumerator<System.CommandLine.Completions.ICompletionSource> GetEnumerator()
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.String[] completions)
public static class ConsoleExtensions
public static System.Void Write(this IConsole console, System.String value)
public static System.Void WriteLine(this IConsole console, System.String value)
Expand Down
8 changes: 4 additions & 4 deletions src/System.CommandLine/Argument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public abstract class Argument : Symbol, IValueDescriptor
private Func<ArgumentResult, object?>? _defaultValueFactory;
private ArgumentArity _arity;
private TryConvertArgument? _convertArguments;
private CompletionSourceList? _completions = null;
private List<ICompletionSource>? _completions = null;
private List<ValidateSymbolResult<ArgumentResult>>? _validators = null;

/// <summary>
Expand Down Expand Up @@ -72,10 +72,10 @@ internal TryConvertArgument? ConvertArguments
}

/// <summary>
/// Gets the list of completion sources for the argument.
/// Gets the collection of completion sources for the argument.
/// </summary>
public CompletionSourceList Completions =>
_completions ??= new CompletionSourceList
public ICollection<ICompletionSource> Completions =>
_completions ??= new ()
{
CompletionSource.ForType(ValueType)
};
Expand Down
6 changes: 3 additions & 3 deletions src/System.CommandLine/CompletionSourceExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static class CompletionSourceExtensions
/// <param name="completionSources">The list of completion sources to add to.</param>
/// <param name="complete">The delegate to be called when calculating completions.</param>
public static void Add(
this CompletionSourceList completionSources,
this ICollection<ICompletionSource> completionSources,
Func<CompletionContext, IEnumerable<string>> complete)
{
if (completionSources is null)
Expand All @@ -40,7 +40,7 @@ public static void Add(
/// <param name="completionSources">The list of completion sources to add to.</param>
/// <param name="complete">The delegate to be called when calculating completions.</param>
public static void Add(
this CompletionSourceList completionSources,
this ICollection<ICompletionSource> completionSources,
CompletionDelegate complete)
{
if (completionSources is null)
Expand All @@ -62,7 +62,7 @@ public static void Add(
/// <param name="completionSources">The list of completion sources to add to.</param>
/// <param name="completions">A list of strings to be suggested for command line completions.</param>
public static void Add(
this CompletionSourceList completionSources,
this ICollection<ICompletionSource> completionSources,
params string[] completions)
{
if (completionSources is null)
Expand Down
45 changes: 0 additions & 45 deletions src/System.CommandLine/CompletionSourceList.cs

This file was deleted.