Skip to content

Commit 469b742

Browse files
committed
remove LINQ code from tokenizer
1 parent 518dd1f commit 469b742

File tree

8 files changed

+154
-76
lines changed

8 files changed

+154
-76
lines changed

src/System.CommandLine.Tests/Binding/HandlerDescriptorTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using System.IO;
77
using FluentAssertions;
88
using System.Linq;
9-
using System.Threading.Tasks;
109
using Xunit;
1110

1211
namespace System.CommandLine.Tests.Binding

src/System.CommandLine.Tests/Binding/TypeConversionTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
using FluentAssertions;
88
using System.Linq;
99
using Xunit;
10-
using System.CommandLine.Invocation;
1110

1211
namespace System.CommandLine.Tests.Binding
1312
{

src/System.CommandLine.Tests/UseHelpTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.CommandLine.IO;
77
using System.CommandLine.Parsing;
88
using System.CommandLine.Tests.Utility;
9+
using System.IO;
910
using System.Threading.Tasks;
1011
using FluentAssertions;
1112
using Xunit;

src/System.CommandLine/Collections/AliasedSet.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
namespace System.CommandLine.Collections
88
{
9-
public abstract class AliasedSet<T> : IReadOnlyCollection<T>
9+
public abstract class AliasedSet<T> : IReadOnlyList<T>
1010
where T : class
1111
{
1212
protected IList<T> Items { get; } = new List<T>();
@@ -65,5 +65,7 @@ internal void Remove(T item)
6565
protected abstract IReadOnlyList<string> GetRawAliases(T item);
6666

6767
public bool Contains(string alias) => GetByAlias(alias) != null;
68+
69+
public T this[int index] => Items[index];
6870
}
6971
}

src/System.CommandLine/Collections/ISymbolSet.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace System.CommandLine.Collections
77
{
8-
public interface ISymbolSet : IReadOnlyCollection<ISymbol>
8+
public interface ISymbolSet : IReadOnlyList<ISymbol>
99
{
1010
ISymbol? GetByAlias(string alias);
1111
}

src/System.CommandLine/CommandLineConfiguration.cs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ namespace System.CommandLine
1313
{
1414
public class CommandLineConfiguration
1515
{
16-
private IReadOnlyCollection<InvocationMiddleware> _middlewarePipeline;
17-
private Func<BindingContext, IHelpBuilder> _helpBuilderFactory;
16+
private readonly IReadOnlyCollection<InvocationMiddleware> _middlewarePipeline;
17+
private readonly Func<BindingContext, IHelpBuilder> _helpBuilderFactory;
1818
private readonly SymbolSet _symbols = new SymbolSet();
1919

2020
public CommandLineConfiguration(
@@ -37,7 +37,18 @@ public CommandLineConfiguration(
3737
throw new ArgumentException("You must specify at least one option or command.");
3838
}
3939

40-
ArgumentDelimiters = argumentDelimiters ?? new[] { ':', '=' };
40+
if (argumentDelimiters is null)
41+
{
42+
ArgumentDelimitersInternal = new HashSet<char>
43+
{
44+
':',
45+
'='
46+
};
47+
}
48+
else
49+
{
50+
ArgumentDelimitersInternal = new HashSet<char>(argumentDelimiters);
51+
}
4152

4253
foreach (var symbol in symbols)
4354
{
@@ -110,8 +121,10 @@ private void AddGlobalOptionsToChildren(Command parentCommand)
110121

111122
public ISymbolSet Symbols => _symbols;
112123

113-
public IReadOnlyCollection<char> ArgumentDelimiters { get; }
124+
public IReadOnlyCollection<char> ArgumentDelimiters => ArgumentDelimitersInternal;
114125

126+
internal HashSet<char> ArgumentDelimitersInternal { get; }
127+
115128
public bool EnableDirectives { get; }
116129

117130
public bool EnablePosixBundling { get; }

0 commit comments

Comments
 (0)