Skip to content

Commit

Permalink
refactor!: remove Span<T>.Split
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverbooth committed Nov 13, 2024
1 parent 9d870b2 commit 0b978f5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
12 changes: 10 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 4.0.0 - [Unreleased]
## 4.0.1 - [Unreleased]

### Removed

- X10D: Removed `Span<T>.Split` for .NET 9.0 target due to conflicts with
[`System.MemoryExtensions.Split`](https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.split?view=net-8.0).

## [4.0.0] - 2024-06-12

### Added

Expand Down Expand Up @@ -642,7 +649,8 @@ please [open an issue](https://github.com/oliverbooth/X10D/issues)!

Earlier versions of this package are undocumented and unlisted from package results.

[unreleased]: https://github.com/oliverbooth/X10D/compare/v3.3.1...main
[unreleased]: https://github.com/oliverbooth/X10D/compare/v4.0.0...main
[4.0.0]: https://github.com/oliverbooth/X10D/releases/tag/v4.0.0
[3.3.1]: https://github.com/oliverbooth/X10D/releases/tag/v3.3.1
[3.3.0]: https://github.com/oliverbooth/X10D/releases/tag/v3.3.0
[3.2.2]: https://github.com/oliverbooth/X10D/releases/tag/v3.2.2
Expand Down
4 changes: 4 additions & 0 deletions X10D.Tests/src/Collections/SpanTest.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using NUnit.Framework;
#if !NET9_0_OR_GREATER
using X10D.Collections;
#endif

namespace X10D.Tests.Collections;

Expand Down Expand Up @@ -70,6 +72,7 @@ public void Replace_ShouldDoNothing_GivenSpanWithNoMatchingElements()
Assert.That(span.ToArray(), Is.EqualTo(new[] {1, 2, 3, 2, 5, 2, 7, 2, 9, 2, 11, 2, 13, 2, 15, 2}));
}

#if !NET9_0_OR_GREATER
[Test]
public void Split_OnEmptySpan_ShouldYieldNothing_UsingCharDelimiter_GivenReadOnlySpan()
{
Expand Down Expand Up @@ -497,4 +500,5 @@ public void Split_OnThreeWords_ShouldYieldLength3_UsingStringDelimiter_GivenSpan

Assert.That(index, Is.EqualTo(3));
}
#endif
}
2 changes: 2 additions & 0 deletions X10D/src/Collections/SpanExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public static void Replace<T>(this Span<T> haystack, T needle, T replacement) wh
}
#endif

#if !NET9_0_OR_GREATER
/// <summary>
/// Splits a span of elements into sub-spans based on a delimiting element.
/// </summary>
Expand Down Expand Up @@ -134,4 +135,5 @@ public static SpanSplitEnumerator<T> Split<T>(this in ReadOnlySpan<T> source, in
{
return new SpanSplitEnumerator<T>(source, delimiter);
}
#endif
}

0 comments on commit 0b978f5

Please sign in to comment.