Skip to content

Commit 5679023

Browse files
jozkeemichaelgsharp
authored andcommitted
Reapply params ReadOnlySpan overloads without params keyword (dotnet#101308)
* Reapply "Add params ReadOnlySpan<T> overloads (dotnet#100898)" (dotnet#101123) This reverts commit 3e569f5. * Comment-out params keyword * Remove /*params*/ from ref
1 parent 33b7e4f commit 5679023

File tree

77 files changed

+1388
-263
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+1388
-263
lines changed

src/libraries/Common/tests/Tests/System/StringTests.cs

Lines changed: 172 additions & 29 deletions
Large diffs are not rendered by default.

src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableArray.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public static ImmutableArray<T> Create<T>(T item1, T item2, T item3, T item4)
8787
/// <typeparam name="T">The type of element stored in the array.</typeparam>
8888
/// <param name="items">The elements to store in the array.</param>
8989
/// <returns>An immutable array containing the specified items.</returns>
90-
public static ImmutableArray<T> Create<T>(ReadOnlySpan<T> items)
90+
public static ImmutableArray<T> Create<T>(/*params*/ ReadOnlySpan<T> items)
9191
{
9292
if (items.IsEmpty)
9393
{

src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableArray_1.Builder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ public void AddRange(ImmutableArray<T> items, int length)
430430
/// Adds the specified items to the end of the array.
431431
/// </summary>
432432
/// <param name="items">The items to add at the end of the array.</param>
433-
public void AddRange(ReadOnlySpan<T> items)
433+
public void AddRange(/*params*/ ReadOnlySpan<T> items)
434434
{
435435
int offset = this.Count;
436436
this.Count += items.Length;
@@ -443,7 +443,7 @@ public void AddRange(ReadOnlySpan<T> items)
443443
/// </summary>
444444
/// <typeparam name="TDerived">The type that derives from the type of item already in the array.</typeparam>
445445
/// <param name="items">The items to add at the end of the array.</param>
446-
public void AddRange<TDerived>(ReadOnlySpan<TDerived> items) where TDerived : T
446+
public void AddRange<TDerived>(/*params*/ ReadOnlySpan<TDerived> items) where TDerived : T
447447
{
448448
int offset = this.Count;
449449
this.Count += items.Length;

src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableArray_1.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,7 @@ public IEnumerable<TResult> OfType<TResult>()
880880
/// </summary>
881881
/// <param name="items">The values to add.</param>
882882
/// <returns>A new list with the elements added.</returns>
883-
public ImmutableArray<T> AddRange(ReadOnlySpan<T> items)
883+
public ImmutableArray<T> AddRange(/*params*/ ReadOnlySpan<T> items)
884884
{
885885
ImmutableArray<T> self = this;
886886
return self.InsertRange(self.Length, items);
@@ -949,7 +949,7 @@ public ImmutableArray<T> InsertRange(int index, T[] items)
949949
/// <param name="index">The index at which to insert the value.</param>
950950
/// <param name="items">The elements to insert.</param>
951951
/// <returns>The new immutable collection.</returns>
952-
public ImmutableArray<T> InsertRange(int index, ReadOnlySpan<T> items)
952+
public ImmutableArray<T> InsertRange(int index, /*params*/ ReadOnlySpan<T> items)
953953
{
954954
ImmutableArray<T> self = this;
955955
self.ThrowNullRefIfNotInitialized();

src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableHashSet.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public static ImmutableHashSet<T> Create<T>(params T[] items)
9898
/// <typeparam name="T">The type of items stored by the collection.</typeparam>
9999
/// <param name="items">The items to prepopulate.</param>
100100
/// <returns>The new immutable collection.</returns>
101-
public static ImmutableHashSet<T> Create<T>(ReadOnlySpan<T> items)
101+
public static ImmutableHashSet<T> Create<T>(/*params*/ ReadOnlySpan<T> items)
102102
{
103103
return ImmutableHashSet<T>.Empty.Union(items);
104104
}
@@ -124,7 +124,7 @@ public static ImmutableHashSet<T> Create<T>(IEqualityComparer<T>? equalityCompar
124124
/// <param name="equalityComparer">The equality comparer.</param>
125125
/// <param name="items">The items to prepopulate.</param>
126126
/// <returns>The new immutable collection.</returns>
127-
public static ImmutableHashSet<T> Create<T>(IEqualityComparer<T>? equalityComparer, ReadOnlySpan<T> items)
127+
public static ImmutableHashSet<T> Create<T>(IEqualityComparer<T>? equalityComparer, /*params*/ ReadOnlySpan<T> items)
128128
{
129129
return ImmutableHashSet<T>.Empty.WithComparer(equalityComparer).Union(items);
130130
}

src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableList.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public static ImmutableList<T> Create<T>(params T[] items)
5252
/// <typeparam name="T">The type of items stored by the collection.</typeparam>
5353
/// <param name="items">A span that contains the items to prepopulate the list with.</param>
5454
/// <returns>A new immutable list that contains the specified items.</returns>
55-
public static ImmutableList<T> Create<T>(ReadOnlySpan<T> items) => ImmutableList<T>.Empty.AddRange(items);
55+
public static ImmutableList<T> Create<T>(/*params*/ ReadOnlySpan<T> items) => ImmutableList<T>.Empty.AddRange(items);
5656

5757
/// <summary>
5858
/// Creates a new immutable list builder.

src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableQueue.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public static ImmutableQueue<T> Create<T>(params T[] items)
8383
/// <typeparam name="T">The type of items in the immutable queue.</typeparam>
8484
/// <param name="items">A span that contains the items to prepopulate the queue with.</param>
8585
/// <returns>A new immutable queue that contains the specified items.</returns>
86-
public static ImmutableQueue<T> Create<T>(ReadOnlySpan<T> items)
86+
public static ImmutableQueue<T> Create<T>(/*params*/ ReadOnlySpan<T> items)
8787
{
8888
if (items.IsEmpty)
8989
{

src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableSortedSet.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public static ImmutableSortedSet<T> Create<T>(params T[] items)
9797
/// <typeparam name="T">The type of items in the immutable set.</typeparam>
9898
/// <param name="items">A span that contains the items to prepopulate the set with.</param>
9999
/// <returns>A new immutable set that contains the specified items.</returns>
100-
public static ImmutableSortedSet<T> Create<T>(ReadOnlySpan<T> items)
100+
public static ImmutableSortedSet<T> Create<T>(/*params*/ ReadOnlySpan<T> items)
101101
{
102102
return ImmutableSortedSet<T>.Empty.Union(items);
103103
}
@@ -123,7 +123,7 @@ public static ImmutableSortedSet<T> Create<T>(IComparer<T>? comparer, params T[]
123123
/// <param name="comparer">The comparer.</param>
124124
/// <param name="items">The items to prepopulate.</param>
125125
/// <returns>The new immutable collection.</returns>
126-
public static ImmutableSortedSet<T> Create<T>(IComparer<T>? comparer, ReadOnlySpan<T> items)
126+
public static ImmutableSortedSet<T> Create<T>(IComparer<T>? comparer, /*params*/ ReadOnlySpan<T> items)
127127
{
128128
return ImmutableSortedSet<T>.Empty.WithComparer(comparer).Union(items);
129129
}

src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableStack.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public static ImmutableStack<T> Create<T>(params T[] items)
7070
/// <typeparam name="T">The type of items in the immutable stack.</typeparam>
7171
/// <param name="items">A span that contains the items to prepopulate the stack with.</param>
7272
/// <returns>A new immutable stack that contains the specified items.</returns>
73-
public static ImmutableStack<T> Create<T>(ReadOnlySpan<T> items)
73+
public static ImmutableStack<T> Create<T>(/*params*/ ReadOnlySpan<T> items)
7474
{
7575
ImmutableStack<T> stack = ImmutableStack<T>.Empty;
7676
foreach (T item in items)

src/libraries/System.Collections.Immutable/tests/ImmutableHashSetTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,15 @@ public void Create()
118118
Assert.Equal(1, set.Count);
119119
Assert.Same(comparer, set.KeyComparer);
120120

121-
set = ImmutableHashSet.Create("a", "b");
121+
set = ImmutableHashSet.Create(new[] { "a", "b" });
122122
Assert.Equal(2, set.Count);
123123
Assert.Same(EqualityComparer<string>.Default, set.KeyComparer);
124124

125125
set = ImmutableHashSet.Create((ReadOnlySpan<string>)new[] { "a", "b" });
126126
Assert.Equal(2, set.Count);
127127
Assert.Same(EqualityComparer<string>.Default, set.KeyComparer);
128128

129-
set = ImmutableHashSet.Create(comparer, "a", "b");
129+
set = ImmutableHashSet.Create(comparer, new[] { "a", "b" });
130130
Assert.Equal(2, set.Count);
131131
Assert.Same(comparer, set.KeyComparer);
132132

0 commit comments

Comments
 (0)