Skip to content

Commit 616387d

Browse files
committed
implemented .net9-style split methods for backwards-compatibility and made original split methods available only as static methods.
1 parent 1d7ab99 commit 616387d

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

src/Extensions/ReadOnlySpan/String/SplitAny.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public static partial class ReadOnlySpanExtensions
1313
/// <param name="source">The <see cref="ReadOnlySpan{T}"/> to be split.</param>
1414
/// <param name="delimiters">A <see cref="ReadOnlySpan{T}"/> with the instances of <typeparamref name="T"/> that delimit the various sub-ReadOnlySpans in <paramref name="source"/>.</param>
1515
/// <returns>An instance of the ref struct <see cref="SpanSplitAnyEnumerator{T}"/>, which works the same way as every <see cref="IEnumerator"/> does and can be used in a foreach construct.</returns>
16-
public static SpanSplitAnyEnumerator<T> SplitAny<T>(this ReadOnlySpan<T> source, ReadOnlySpan<T> delimiters) where T : IEquatable<T>
16+
public static SpanSplitAnyEnumerator<T> SplitAny<T>(ReadOnlySpan<T> source, ReadOnlySpan<T> delimiters) where T : IEquatable<T>
1717
{
1818
return new SpanSplitAnyEnumerator<T>(source, delimiters);
1919
}
@@ -27,7 +27,7 @@ public static SpanSplitAnyEnumerator<T> SplitAny<T>(this ReadOnlySpan<T> source,
2727
/// <param name="count">The maximum number of sub-ReadOnlySpans to split into.</param>
2828
/// <param name="countExceedingBehaviour">The handling of the instances more than count.</param>
2929
/// <returns>An instance of the ref struct <see cref="SpanSplitAnyWithCountEnumerator{T}"/>, which works the same way as every <see cref="IEnumerator"/> does and can be used in a foreach construct.</returns>
30-
public static SpanSplitAnyWithCountEnumerator<T> SplitAny<T>(this ReadOnlySpan<T> source, ReadOnlySpan<T> delimiters, int count, CountExceedingBehaviour countExceedingBehaviour = CountExceedingBehaviour.AppendRemainingElements) where T : IEquatable<T>
30+
public static SpanSplitAnyWithCountEnumerator<T> SplitAny<T>(ReadOnlySpan<T> source, ReadOnlySpan<T> delimiters, int count, CountExceedingBehaviour countExceedingBehaviour = CountExceedingBehaviour.AppendRemainingElements) where T : IEquatable<T>
3131
{
3232
return new SpanSplitAnyWithCountEnumerator<T>(source, delimiters, count, countExceedingBehaviour);
3333
}
@@ -39,7 +39,7 @@ public static SpanSplitAnyWithCountEnumerator<T> SplitAny<T>(this ReadOnlySpan<T
3939
/// <param name="delimiters">A <see cref="ReadOnlySpan{Char}"/>, that delimit the various sub-ReadOnlySpans in <paramref name="source"/>.</param>
4040
/// <param name="options">A bitwise combination of the enumeration values that specifies whether to trim results and include empty results.</param>
4141
/// <returns>An instance of the ref struct <see cref="SpanSplitAnyStringSplitOptionsEnumerator"/>, which works the same way as every <see cref="IEnumerator"/> does and can be used in a foreach construct.</returns>
42-
public static SpanSplitAnyStringSplitOptionsEnumerator SplitAny(this ReadOnlySpan<char> source, ReadOnlySpan<char> delimiters, StringSplitOptions options)
42+
public static SpanSplitAnyStringSplitOptionsEnumerator SplitAny(ReadOnlySpan<char> source, ReadOnlySpan<char> delimiters, StringSplitOptions options)
4343
{
4444
return new SpanSplitAnyStringSplitOptionsEnumerator(source, delimiters, options);
4545
}
@@ -53,7 +53,7 @@ public static SpanSplitAnyStringSplitOptionsEnumerator SplitAny(this ReadOnlySpa
5353
/// <param name="options">A bitwise combination of the enumeration values that specifies whether to trim results and include empty results.</param>
5454
/// <param name="countExceedingBehaviour">The handling of the instances more than count.</param>
5555
/// <returns>An instance of the ref struct <see cref="SpanSplitAnyStringSplitOptionsWithCountEnumerator"/>, which works the same way as every <see cref="IEnumerator"/> does and can be used in a foreach construct.</returns>
56-
public static SpanSplitAnyStringSplitOptionsWithCountEnumerator SplitAny(this ReadOnlySpan<char> source, ReadOnlySpan<char> delimiters, int count, StringSplitOptions options, CountExceedingBehaviour countExceedingBehaviour = CountExceedingBehaviour.AppendRemainingElements)
56+
public static SpanSplitAnyStringSplitOptionsWithCountEnumerator SplitAny(ReadOnlySpan<char> source, ReadOnlySpan<char> delimiters, int count, StringSplitOptions options, CountExceedingBehaviour countExceedingBehaviour = CountExceedingBehaviour.AppendRemainingElements)
5757
{
5858
return new SpanSplitAnyStringSplitOptionsWithCountEnumerator(source, delimiters, count, options, countExceedingBehaviour);
5959
}

src/Extensions/ReadOnlySpan/String/SplitSequence.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public static partial class ReadOnlySpanExtensions
1313
/// <param name="source">The <see cref="ReadOnlySpan{T}"/> to be split.</param>
1414
/// <param name="delimiter">An instance of <see cref="ReadOnlySpan{T}"/> that delimits the various sub-ReadOnlySpans in <paramref name="source"/>.</param>
1515
/// <returns>An instance of the ref struct <see cref="SpanSplitSequenceEnumerator{T}"/>, which works the same way as every <see cref="IEnumerator"/> does and can be used in a foreach construct.</returns>
16-
public static SpanSplitSequenceEnumerator<T> Split<T>(this ReadOnlySpan<T> source, ReadOnlySpan<T> delimiter) where T : IEquatable<T>
16+
public static SpanSplitSequenceEnumerator<T> Split<T>(ReadOnlySpan<T> source, ReadOnlySpan<T> delimiter) where T : IEquatable<T>
1717
{
1818
return new SpanSplitSequenceEnumerator<T>(source, delimiter);
1919
}
@@ -27,7 +27,7 @@ public static SpanSplitSequenceEnumerator<T> Split<T>(this ReadOnlySpan<T> sourc
2727
/// <param name="count">The maximum number of sub-ReadOnlySpans to split into.</param>
2828
/// <param name="countExceedingBehaviour">The handling of the instances more than count.</param>
2929
/// <returns>An instance of the ref struct , which works the same way as every <see cref="IEnumerator"/> does and can be used in a foreach construct.</returns>
30-
public static SpanSplitSequenceWithCountEnumerator<T> Split<T>(this ReadOnlySpan<T> source, ReadOnlySpan<T> delimiter, int count, CountExceedingBehaviour countExceedingBehaviour = CountExceedingBehaviour.AppendRemainingElements) where T : IEquatable<T>
30+
public static SpanSplitSequenceWithCountEnumerator<T> Split<T>(ReadOnlySpan<T> source, ReadOnlySpan<T> delimiter, int count, CountExceedingBehaviour countExceedingBehaviour = CountExceedingBehaviour.AppendRemainingElements) where T : IEquatable<T>
3131
{
3232
return new SpanSplitSequenceWithCountEnumerator<T>(source, delimiter, count, countExceedingBehaviour);
3333
}
@@ -39,7 +39,7 @@ public static SpanSplitSequenceWithCountEnumerator<T> Split<T>(this ReadOnlySpan
3939
/// <param name="delimiter">An instance of <see cref="ReadOnlySpan{Char}"/> that delimits the various sub-ReadOnlySpans in <paramref name="source"/>.</param>
4040
/// <param name="options">A bitwise combination of the enumeration values that specifies whether to trim results and include empty results.</param>
4141
/// <returns>An instance of the ref struct <see cref="SpanSplitSequenceStringSplitOptionsEnumerator"/>, which works the same way as every <see cref="IEnumerator"/> does and can be used in a foreach construct.</returns>
42-
public static SpanSplitSequenceStringSplitOptionsEnumerator Split(this ReadOnlySpan<char> source, ReadOnlySpan<char> delimiter, StringSplitOptions options)
42+
public static SpanSplitSequenceStringSplitOptionsEnumerator Split(ReadOnlySpan<char> source, ReadOnlySpan<char> delimiter, StringSplitOptions options)
4343
{
4444
return new SpanSplitSequenceStringSplitOptionsEnumerator(source, delimiter, options);
4545
}
@@ -53,7 +53,7 @@ public static SpanSplitSequenceStringSplitOptionsEnumerator Split(this ReadOnlyS
5353
/// <param name="options">A bitwise combination of the enumeration values that specifies whether to trim results and include empty results.</param>
5454
/// <param name="countExceedingBehaviour">The handling of the instances more than count.</param>
5555
/// <returns>An instance of the ref struct <see cref="SpanSplitSequenceStringSplitOptionsWithCountEnumerator"/>, which works the same way as every <see cref="IEnumerator"/> does and can be used in a foreach construct.</returns>
56-
public static SpanSplitSequenceStringSplitOptionsWithCountEnumerator Split(this ReadOnlySpan<char> source, ReadOnlySpan<char> delimiter, int count, StringSplitOptions options, CountExceedingBehaviour countExceedingBehaviour = CountExceedingBehaviour.AppendRemainingElements)
56+
public static SpanSplitSequenceStringSplitOptionsWithCountEnumerator Split(ReadOnlySpan<char> source, ReadOnlySpan<char> delimiter, int count, StringSplitOptions options, CountExceedingBehaviour countExceedingBehaviour = CountExceedingBehaviour.AppendRemainingElements)
5757
{
5858
return new SpanSplitSequenceStringSplitOptionsWithCountEnumerator(source, delimiter, count, options, countExceedingBehaviour);
5959
}

src/Extensions/Span/String/Split.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public static partial class SpanExtensions
1313
/// <param name="source">The <see cref="Span{T}"/> to be split.</param>
1414
/// <param name="delimiter">An instance of <typeparamref name="T"/> that delimits the various sub-ReadOnlySpans in <paramref name="source"/>.</param>
1515
/// <returns>An instance of the ref struct <see cref="SpanSplitEnumerator{T}"/>, which works the same way as every <see cref="IEnumerator"/> does and can be used in a foreach construct.</returns>
16-
public static SpanSplitEnumerator<T> Split<T>(this Span<T> source, T delimiter) where T : IEquatable<T>
16+
public static SpanSplitEnumerator<T> Split<T>(Span<T> source, T delimiter) where T : IEquatable<T>
1717
{
1818
return new SpanSplitEnumerator<T>(source, delimiter);
1919
}
@@ -27,7 +27,7 @@ public static SpanSplitEnumerator<T> Split<T>(this Span<T> source, T delimiter)
2727
/// <param name="count">The maximum number of sub-ReadOnlySpans to split into.</param>
2828
/// <param name="countExceedingBehaviour">The handling of the instances more than count.</param>
2929
/// <returns>An instance of the ref struct <see cref="SpanSplitWithCountEnumerator{T}"/>, which works the same way as every <see cref="IEnumerator"/> does and can be used in a foreach construct.</returns>
30-
public static SpanSplitWithCountEnumerator<T> Split<T>(this Span<T> source, T delimiter, int count, CountExceedingBehaviour countExceedingBehaviour = CountExceedingBehaviour.AppendRemainingElements) where T : IEquatable<T>
30+
public static SpanSplitWithCountEnumerator<T> Split<T>(Span<T> source, T delimiter, int count, CountExceedingBehaviour countExceedingBehaviour = CountExceedingBehaviour.AppendRemainingElements) where T : IEquatable<T>
3131
{
3232
return new SpanSplitWithCountEnumerator<T>(source, delimiter, count, countExceedingBehaviour);
3333
}
@@ -39,7 +39,7 @@ public static SpanSplitWithCountEnumerator<T> Split<T>(this Span<T> source, T de
3939
/// <param name="delimiter">A <see cref="char"/> that delimits the various sub-ReadOnlySpans in <paramref name="source"/>.</param>
4040
/// <param name="options">A bitwise combination of the enumeration values that specifies whether to trim results and include empty results.</param>
4141
/// <returns>An instance of the ref struct <see cref="SpanSplitStringSplitOptionsEnumerator"/>, which works the same way as every <see cref="IEnumerator"/> does and can be used in a foreach construct.</returns>
42-
public static SpanSplitStringSplitOptionsEnumerator Split(this Span<char> source, char delimiter, StringSplitOptions options)
42+
public static SpanSplitStringSplitOptionsEnumerator Split(Span<char> source, char delimiter, StringSplitOptions options)
4343
{
4444
return new SpanSplitStringSplitOptionsEnumerator(source, delimiter, options);
4545
}
@@ -53,7 +53,7 @@ public static SpanSplitStringSplitOptionsEnumerator Split(this Span<char> source
5353
/// <param name="options">A bitwise combination of the enumeration values that specifies whether to trim results and include empty results.</param>
5454
/// <param name="countExceedingBehaviour">The handling of the instances more than count.</param>
5555
/// <returns>An instance of the ref struct <see cref="SpanSplitAnyStringSplitOptionsWithCountEnumerator"/>, which works the same way as every <see cref="IEnumerator"/> does and can be used in a foreach construct.</returns>
56-
public static SpanSplitStringSplitOptionsWithCountEnumerator Split(this Span<char> source, char delimiter, int count, StringSplitOptions options, CountExceedingBehaviour countExceedingBehaviour = CountExceedingBehaviour.AppendRemainingElements)
56+
public static SpanSplitStringSplitOptionsWithCountEnumerator Split(Span<char> source, char delimiter, int count, StringSplitOptions options, CountExceedingBehaviour countExceedingBehaviour = CountExceedingBehaviour.AppendRemainingElements)
5757
{
5858
return new SpanSplitStringSplitOptionsWithCountEnumerator(source, delimiter, count, options, countExceedingBehaviour);
5959
}

src/Extensions/Span/String/SplitAny.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public static partial class SpanExtensions
1313
/// <param name="source">The <see cref="Span{T}"/> to be split.</param>
1414
/// <param name="delimiters">A <see cref="ReadOnlySpan{T}"/>, that delimit the various sub-ReadOnlySpans in <paramref name="source"/>.</param>
1515
/// <returns>An instance of the ref struct <see cref="SpanSplitAnyEnumerator{T}"/>, which works the same way as every <see cref="IEnumerator"/> does and can be used in a foreach construct.</returns>
16-
public static SpanSplitAnyEnumerator<T> SplitAny<T>(this Span<T> source, ReadOnlySpan<T> delimiters) where T : IEquatable<T>
16+
public static SpanSplitAnyEnumerator<T> SplitAny<T>(Span<T> source, ReadOnlySpan<T> delimiters) where T : IEquatable<T>
1717
{
1818
return new SpanSplitAnyEnumerator<T>(source, delimiters);
1919
}
@@ -27,7 +27,7 @@ public static SpanSplitAnyEnumerator<T> SplitAny<T>(this Span<T> source, ReadOnl
2727
/// <param name="delimiters">A <see cref="ReadOnlySpan{T}"/>, that delimit the various sub-ReadOnlySpans in <paramref name="source"/>.</param>
2828
/// <param name="countExceedingBehaviour">The handling of the instances more than count.</param>
2929
/// <returns>An instance of the ref struct <see cref="SpanSplitAnyWithCountEnumerator{T}"/>, which works the same way as every <see cref="IEnumerator"/> does and can be used in a foreach construct.</returns>
30-
public static SpanSplitAnyWithCountEnumerator<T> SplitAny<T>(this Span<T> source, ReadOnlySpan<T> delimiters, int count, CountExceedingBehaviour countExceedingBehaviour = CountExceedingBehaviour.AppendRemainingElements) where T : IEquatable<T>
30+
public static SpanSplitAnyWithCountEnumerator<T> SplitAny<T>(Span<T> source, ReadOnlySpan<T> delimiters, int count, CountExceedingBehaviour countExceedingBehaviour = CountExceedingBehaviour.AppendRemainingElements) where T : IEquatable<T>
3131
{
3232
return new SpanSplitAnyWithCountEnumerator<T>(source, delimiters, count, countExceedingBehaviour);
3333
}
@@ -39,7 +39,7 @@ public static SpanSplitAnyWithCountEnumerator<T> SplitAny<T>(this Span<T> source
3939
/// <param name="delimiters">A <see cref="ReadOnlySpan{Char}"/>, that delimit the various sub-ReadOnlySpans in <paramref name="source"/>.</param>
4040
/// <param name="options">A bitwise combination of the enumeration values that specifies whether to trim results and include empty results.</param>
4141
/// <returns>An instance of the ref struct <see cref="SpanSplitAnyStringSplitOptionsEnumerator"/>, which works the same way as every <see cref="IEnumerator"/> does and can be used in a foreach construct.</returns>
42-
public static SpanSplitAnyStringSplitOptionsEnumerator SplitAny(this Span<char> source, ReadOnlySpan<char> delimiters, StringSplitOptions options)
42+
public static SpanSplitAnyStringSplitOptionsEnumerator SplitAny(Span<char> source, ReadOnlySpan<char> delimiters, StringSplitOptions options)
4343
{
4444
return new SpanSplitAnyStringSplitOptionsEnumerator(source, delimiters, options);
4545
}
@@ -53,7 +53,7 @@ public static SpanSplitAnyStringSplitOptionsEnumerator SplitAny(this Span<char>
5353
/// <param name="count">The maximum number of sub-ReadOnlySpans to split into.</param>
5454
/// <param name="countExceedingBehaviour">The handling of the instances more than count.</param>
5555
/// <returns>An instance of the ref struct <see cref="SpanSplitAnyStringSplitOptionsWithCountEnumerator"/>, which works the same way as every <see cref="IEnumerator"/> does and can be used in a foreach construct.</returns>
56-
public static SpanSplitAnyStringSplitOptionsWithCountEnumerator SplitAny(this Span<char> source, ReadOnlySpan<char> delimiters, int count, StringSplitOptions options, CountExceedingBehaviour countExceedingBehaviour = CountExceedingBehaviour.AppendRemainingElements)
56+
public static SpanSplitAnyStringSplitOptionsWithCountEnumerator SplitAny(Span<char> source, ReadOnlySpan<char> delimiters, int count, StringSplitOptions options, CountExceedingBehaviour countExceedingBehaviour = CountExceedingBehaviour.AppendRemainingElements)
5757
{
5858
return new SpanSplitAnyStringSplitOptionsWithCountEnumerator(source, delimiters, count, options, countExceedingBehaviour);
5959
}

0 commit comments

Comments
 (0)