Skip to content

Commit d00241c

Browse files
committed
make SymbolSet an IReadOnlyList<Symbol>
1 parent d4cae87 commit d00241c

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/System.CommandLine.ApiCompatibility.Tests/ApiCompatibilityApprovalTests.System_CommandLine_api_is_not_changed.approved.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ System.CommandLine.Builder
283283
public static CommandLineBuilder UseVersionOption(this CommandLineBuilder builder)
284284
public static CommandLineBuilder UseVersionOption(this CommandLineBuilder builder, System.String[] aliases)
285285
System.CommandLine.Collections
286-
public class SymbolSet, System.Collections.Generic.IEnumerable<System.CommandLine.Symbol>, System.Collections.IEnumerable
286+
public class SymbolSet, System.Collections.Generic.IEnumerable<System.CommandLine.Symbol>, System.Collections.Generic.IReadOnlyCollection<System.CommandLine.Symbol>, System.Collections.Generic.IReadOnlyList<System.CommandLine.Symbol>, System.Collections.IEnumerable
287287
.ctor()
288288
public System.Int32 Count { get; }
289289
public System.CommandLine.Symbol Item { get; }

src/System.CommandLine/Collections/SymbolSet.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,16 @@ namespace System.CommandLine.Collections
99
/// <summary>
1010
/// A set of symbols, unique and indexed by their aliases.
1111
/// </summary>
12-
public class SymbolSet : IEnumerable<Symbol>
12+
public class SymbolSet : IReadOnlyList<Symbol>
1313
{
14-
private readonly List<Symbol> _symbols = new List<Symbol>();
14+
private readonly List<Symbol> _symbols = new();
1515
private List<Argument>? _arguments;
1616
private List<Option>? _options;
1717

18+
/// <inheritdoc />
1819
public int Count => _symbols.Count;
1920

21+
/// <inheritdoc />
2022
public Symbol this[int index] => _symbols[index];
2123

2224
private void ResetIndex(Symbol item)
@@ -42,6 +44,7 @@ internal void AddWithoutAliasCollisionCheck(Symbol item)
4244
}
4345
}
4446

47+
/// <inheritdoc />
4548
public IEnumerator<Symbol> GetEnumerator() => _symbols.GetEnumerator();
4649

4750
IEnumerator IEnumerable.GetEnumerator() => _symbols.GetEnumerator();

0 commit comments

Comments
 (0)