Skip to content

Commit 094948f

Browse files
committed
excluded Replace() and Count() for Versions later or equal to net8.0 to avoid conflicts with methods present in these versions
1 parent 3637bd4 commit 094948f

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

src/Extensions/ReadOnlySpan/Linq/Count.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ namespace SpanExtensions
44
{
55
public static partial class ReadOnlySpanExtensions
66
{
7+
#if !NET8_0_OR_GREATER // support for this method has been added in .Net 8. Just include it for backward-compatibility.
8+
79
/// <summary>
810
/// Returns the number of elements in a <see cref="ReadOnlySpan{T}"/>.
911
/// </summary>
@@ -15,7 +17,7 @@ public static int Count<T>(this ReadOnlySpan<T> source)
1517
{
1618
return source.Length;
1719
}
18-
20+
#endif
1921
/// <summary>
2022
/// Returns a number that represents how many elements in the specified sequence satisfy a condition.
2123
/// </summary>

src/Extensions/Span/Linq/Count.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ namespace SpanExtensions
44
{
55
public static partial class SpanExtensions
66
{
7+
#if !NET8_0_OR_GREATER // support for this method has been added in .Net 8. Just include it for backward-compatibility.
78
/// <summary>
89
/// Returns the number of elements in a <see cref="Span{T}"/>.
910
/// </summary>
@@ -15,7 +16,7 @@ public static int Count<T>(this Span<T> source)
1516
{
1617
return ReadOnlySpanExtensions.Count<T>(source);
1718
}
18-
19+
#endif
1920
/// <summary>
2021
/// Returns a number that represents how many elements in the specified sequence satisfy a condition.
2122
/// </summary>

src/Extensions/Span/String/Replace.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using System;
1+
#if !NET8_0_OR_GREATER // support for this method has been added in .Net 8. Just include it for backward-compatibility.
2+
3+
using System;
24

35
namespace SpanExtensions
46
{
@@ -22,4 +24,5 @@ public static void Replace<T>(this Span<T> source, T oldT, T newT) where T : IEq
2224
}
2325
}
2426
}
25-
}
27+
}
28+
#endif

0 commit comments

Comments
 (0)