Removing Span<byte> extension methods and using the generic ones (dotnet/corefx#24911)
authorAhson Khan <ahkha@microsoft.com>
Fri, 27 Oct 2017 22:55:40 +0000 (15:55 -0700)
committerGitHub <noreply@github.com>
Fri, 27 Oct 2017 22:55:40 +0000 (15:55 -0700)
* Removing Span<byte> extension methods and use the generic ones.

* Addressing PR feedback.

* Fixing nits and moving type check to public API.

Commit migrated from https://github.com/dotnet/corefx/commit/42582c350c33515ddea2f211afb23840dbab260a

13 files changed:
src/libraries/System.Memory/ref/System.Memory.cs
src/libraries/System.Memory/src/System/SpanExtensions.cs
src/libraries/System.Memory/src/System/SpanHelpers.T.cs
src/libraries/System.Memory/tests/Performance/Perf.Span.IndexOf.cs
src/libraries/System.Memory/tests/Performance/Perf.Span.StartsWith.cs
src/libraries/System.Memory/tests/ReadOnlySpan/IndexOf.byte.cs
src/libraries/System.Memory/tests/ReadOnlySpan/IndexOfSequence.byte.cs
src/libraries/System.Memory/tests/ReadOnlySpan/SequenceEqual.byte.cs
src/libraries/System.Memory/tests/ReadOnlySpan/StartsWith.byte.cs
src/libraries/System.Memory/tests/Span/IndexOf.byte.cs
src/libraries/System.Memory/tests/Span/IndexOfSequence.byte.cs
src/libraries/System.Memory/tests/Span/SequenceEqual.byte.cs
src/libraries/System.Memory/tests/Span/StartsWith.byte.cs

index 2e6ab08..0159b24 100644 (file)
@@ -76,20 +76,16 @@ namespace System
     
     public static class SpanExtensions
     {
-        public static int IndexOf<T>(this Span<T> span, T value) where T:struct, IEquatable<T> { throw null; }
-        public static int IndexOf<T>(this Span<T> span, ReadOnlySpan<T> value) where T : struct, IEquatable<T> { throw null; }
-        public static int IndexOf(this Span<byte> span, byte value) { throw null; }
-        public static int IndexOf(this Span<byte> span, ReadOnlySpan<byte> value) { throw null; }
+        public static int IndexOf<T>(this Span<T> span, T value) where T : IEquatable<T> { throw null; }
+        public static int IndexOf<T>(this Span<T> span, ReadOnlySpan<T> value) where T : IEquatable<T> { throw null; }
 
         public static int IndexOfAny(this Span<byte> span, byte value0, byte value1) { throw null; }
         public static int IndexOfAny(this Span<byte> span, byte value0, byte value1, byte value2) { throw null; }
         public static int IndexOfAny(this Span<byte> span, ReadOnlySpan<byte> values) { throw null; }
 
-        public static bool SequenceEqual<T>(this Span<T> first, ReadOnlySpan<T> second) where T:struct, IEquatable<T> { throw null; }
-        public static bool SequenceEqual(this Span<byte> first, ReadOnlySpan<byte> second) { throw null; }
+        public static bool SequenceEqual<T>(this Span<T> first, ReadOnlySpan<T> second) where T : IEquatable<T> { throw null; }
         
-        public static bool StartsWith<T>(this Span<T> span, ReadOnlySpan<T> value) where T : struct, IEquatable<T> { throw null; }
-        public static bool StartsWith(this Span<byte> span, ReadOnlySpan<byte> value) { throw null; }
+        public static bool StartsWith<T>(this Span<T> span, ReadOnlySpan<T> value) where T : IEquatable<T> { throw null; }
 
         public static Span<byte> AsBytes<T>(this Span<T> source) where T : struct { throw null; }
 
@@ -103,20 +99,16 @@ namespace System
 
         public static void CopyTo<T>(this T[] array, Span<T> destination) { throw null; }
 
-        public static int IndexOf<T>(this ReadOnlySpan<T> span, T value) where T : struct, IEquatable<T> { throw null; }
-        public static int IndexOf<T>(this ReadOnlySpan<T> span, ReadOnlySpan<T> value) where T : struct, IEquatable<T> { throw null; }
-        public static int IndexOf(this ReadOnlySpan<byte> span, byte value) { throw null; }
-        public static int IndexOf(this ReadOnlySpan<byte> span, ReadOnlySpan<byte> value) { throw null; }
+        public static int IndexOf<T>(this ReadOnlySpan<T> span, T value) where T : IEquatable<T> { throw null; }
+        public static int IndexOf<T>(this ReadOnlySpan<T> span, ReadOnlySpan<T> value) where T : IEquatable<T> { throw null; }
 
         public static int IndexOfAny(this ReadOnlySpan<byte> span, byte value0, byte value1) { throw null; }
         public static int IndexOfAny(this ReadOnlySpan<byte> span, byte value0, byte value1, byte value2) { throw null; }
         public static int IndexOfAny(this ReadOnlySpan<byte> span, ReadOnlySpan<byte> values) { throw null; }
 
-        public static bool SequenceEqual<T>(this ReadOnlySpan<T> first, ReadOnlySpan<T> second) where T : struct, IEquatable<T> { throw null; }
-        public static bool SequenceEqual(this ReadOnlySpan<byte> first, ReadOnlySpan<byte> second) { throw null; }
+        public static bool SequenceEqual<T>(this ReadOnlySpan<T> first, ReadOnlySpan<T> second) where T : IEquatable<T> { throw null; }
 
-        public static bool StartsWith<T>(this ReadOnlySpan<T> span, ReadOnlySpan<T> value) where T : struct, IEquatable<T> { throw null; }
-        public static bool StartsWith(this ReadOnlySpan<byte> span, ReadOnlySpan<byte> value) { throw null; }
+        public static bool StartsWith<T>(this ReadOnlySpan<T> span, ReadOnlySpan<T> value) where T : IEquatable<T> { throw null; }
 
         public static ReadOnlySpan<byte> AsBytes<T>(this ReadOnlySpan<T> source) where T : struct { throw null; }
         
index 31bc74c..e993f43 100644 (file)
@@ -19,63 +19,48 @@ namespace System
         /// <param name="value">The value to search for.</param>
         [MethodImpl(MethodImplOptions.AggressiveInlining)]
         public static int IndexOf<T>(this Span<T> span, T value)
-            where T:struct, IEquatable<T>
+            where T : IEquatable<T>
         {
+            if (typeof(T) == typeof(byte)) 
+                return SpanHelpers.IndexOf(
+                    ref Unsafe.As<T, byte>(ref span.DangerousGetPinnableReference()), 
+                    Unsafe.As<T, byte>(ref value), 
+                    span.Length);
             return SpanHelpers.IndexOf<T>(ref span.DangerousGetPinnableReference(), value, span.Length);
         }
 
         /// <summary>
-        /// Searches for the specified value and returns the index of its first occurrence. If not found, returns -1. 
-        /// </summary>
-        /// <param name="span">The span to search.</param>
-        /// <param name="value">The value to search for.</param>
-        [MethodImpl(MethodImplOptions.AggressiveInlining)]
-        public static int IndexOf(this Span<byte> span, byte value)
-        {
-            return SpanHelpers.IndexOf(ref span.DangerousGetPinnableReference(), value, span.Length);
-        }
-
-        /// <summary>
         /// Searches for the specified sequence and returns the index of its first occurrence. If not found, returns -1. Values are compared using IEquatable&lt;T&gt;.Equals(T). 
         /// </summary>
         /// <param name="span">The span to search.</param>
         /// <param name="value">The sequence to search for.</param>
         [MethodImpl(MethodImplOptions.AggressiveInlining)]
         public static int IndexOf<T>(this Span<T> span, ReadOnlySpan<T> value)
-            where T : struct, IEquatable<T>
+            where T : IEquatable<T>
         {
+            if (typeof(T) == typeof(byte)) 
+                return SpanHelpers.IndexOf(
+                    ref Unsafe.As<T, byte>(ref span.DangerousGetPinnableReference()), 
+                    span.Length, 
+                    ref Unsafe.As<T, byte>(ref value.DangerousGetPinnableReference()), 
+                    value.Length);
             return SpanHelpers.IndexOf<T>(ref span.DangerousGetPinnableReference(), span.Length, ref value.DangerousGetPinnableReference(), value.Length);
         }
 
         /// <summary>
-        /// Searches for the specified sequence and returns the index of its first occurrence. If not found, returns -1.
-        /// </summary>
-        /// <param name="span">The span to search.</param>
-        /// <param name="value">The sequence to search for.</param>
-        [MethodImpl(MethodImplOptions.AggressiveInlining)]
-        public static int IndexOf(this Span<byte> span, ReadOnlySpan<byte> value)
-        {
-            return SpanHelpers.IndexOf(ref span.DangerousGetPinnableReference(), span.Length, ref value.DangerousGetPinnableReference(), value.Length);
-        }
-
-        /// <summary>
         /// Determines whether two sequences are equal by comparing the elements using IEquatable&lt;T&gt;.Equals(T). 
         /// </summary>
         [MethodImpl(MethodImplOptions.AggressiveInlining)]
         public static bool SequenceEqual<T>(this Span<T> first, ReadOnlySpan<T> second)
-            where T:struct, IEquatable<T>
-        {
-            int length = first.Length;
-            return length == second.Length && SpanHelpers.SequenceEqual(ref first.DangerousGetPinnableReference(), ref second.DangerousGetPinnableReference(), length);
-        }
-
-        /// <summary>
-        /// Determines whether two sequences are equal by comparing the elements.
-        /// </summary>
-        [MethodImpl(MethodImplOptions.AggressiveInlining)]
-        public static bool SequenceEqual(this Span<byte> first, ReadOnlySpan<byte> second)
+            where T : IEquatable<T>
         {
             int length = first.Length;
+            if (typeof(T) == typeof(byte))
+                return length == second.Length &&
+                SpanHelpers.SequenceEqual(
+                    ref Unsafe.As<T, byte>(ref first.DangerousGetPinnableReference()),
+                    ref Unsafe.As<T, byte>(ref second.DangerousGetPinnableReference()),
+                    length);
             return length == second.Length && SpanHelpers.SequenceEqual(ref first.DangerousGetPinnableReference(), ref second.DangerousGetPinnableReference(), length);
         }
 
@@ -86,47 +71,35 @@ namespace System
         /// <param name="value">The value to search for.</param>
         [MethodImpl(MethodImplOptions.AggressiveInlining)]
         public static int IndexOf<T>(this ReadOnlySpan<T> span, T value)
-            where T : struct, IEquatable<T>
+            where T : IEquatable<T>
         {
+            if (typeof(T) == typeof(byte)) 
+                return SpanHelpers.IndexOf(
+                    ref Unsafe.As<T, byte>(ref span.DangerousGetPinnableReference()), 
+                    Unsafe.As<T, byte>(ref value), 
+                    span.Length);
             return SpanHelpers.IndexOf<T>(ref span.DangerousGetPinnableReference(), value, span.Length);
         }
 
         /// <summary>
-        /// Searches for the specified value and returns the index of its first occurrence. If not found, returns -1. 
-        /// </summary>
-        /// <param name="span">The span to search.</param>
-        /// <param name="value">The value to search for.</param>
-        [MethodImpl(MethodImplOptions.AggressiveInlining)]
-        public static int IndexOf(this ReadOnlySpan<byte> span, byte value)
-        {
-            return SpanHelpers.IndexOf(ref span.DangerousGetPinnableReference(), value, span.Length);
-        }
-
-        /// <summary>
         /// Searches for the specified sequence and returns the index of its first occurrence. If not found, returns -1. Values are compared using IEquatable&lt;T&gt;.Equals(T). 
         /// </summary>
         /// <param name="span">The span to search.</param>
         /// <param name="value">The sequence to search for.</param>
         [MethodImpl(MethodImplOptions.AggressiveInlining)]
         public static int IndexOf<T>(this ReadOnlySpan<T> span, ReadOnlySpan<T> value)
-            where T : struct, IEquatable<T>
+            where T : IEquatable<T>
         {
+            if (typeof(T) == typeof(byte)) 
+                return SpanHelpers.IndexOf(
+                    ref Unsafe.As<T, byte>(ref span.DangerousGetPinnableReference()), 
+                    span.Length, 
+                    ref Unsafe.As<T, byte>(ref value.DangerousGetPinnableReference()), 
+                    value.Length);
             return SpanHelpers.IndexOf<T>(ref span.DangerousGetPinnableReference(), span.Length, ref value.DangerousGetPinnableReference(), value.Length);
         }
 
         /// <summary>
-        /// Searches for the specified sequence and returns the index of its first occurrence. If not found, returns -1.
-        /// </summary>
-        /// <param name="span">The span to search.</param>
-        /// <param name="value">The sequence to search for.</param>
-        [MethodImpl(MethodImplOptions.AggressiveInlining)]
-        public static int IndexOf(this ReadOnlySpan<byte> span, ReadOnlySpan<byte> value)
-        {
-            return SpanHelpers.IndexOf(ref span.DangerousGetPinnableReference(), span.Length, ref value.DangerousGetPinnableReference(), value.Length);
-        }
-
-
-        /// <summary>
         /// Searches for the first index of any of the specified values similar to calling IndexOf several times with the logical OR operator. If not found, returns -1.
         /// </summary>
         /// <param name="span">The span to search.</param>
@@ -203,19 +176,15 @@ namespace System
         /// </summary>
         [MethodImpl(MethodImplOptions.AggressiveInlining)]
         public static bool SequenceEqual<T>(this ReadOnlySpan<T> first, ReadOnlySpan<T> second)
-            where T : struct, IEquatable<T>
-        {
-            int length = first.Length;
-            return length == second.Length && SpanHelpers.SequenceEqual(ref first.DangerousGetPinnableReference(), ref second.DangerousGetPinnableReference(), length);
-        }
-
-        /// <summary>
-        /// Determines whether two sequences are equal by comparing the elements.
-        /// </summary>
-        [MethodImpl(MethodImplOptions.AggressiveInlining)]
-        public static bool SequenceEqual(this ReadOnlySpan<byte> first, ReadOnlySpan<byte> second)
+            where T : IEquatable<T>
         {
             int length = first.Length;
+            if (typeof(T) == typeof(byte))
+                return length == second.Length &&
+                SpanHelpers.SequenceEqual(
+                    ref Unsafe.As<T, byte>(ref first.DangerousGetPinnableReference()),
+                    ref Unsafe.As<T, byte>(ref second.DangerousGetPinnableReference()),
+                    length);
             return length == second.Length && SpanHelpers.SequenceEqual(ref first.DangerousGetPinnableReference(), ref second.DangerousGetPinnableReference(), length);
         }
 
@@ -223,30 +192,16 @@ namespace System
         /// Determines whether the specified sequence appears at the start of the span.
         /// </summary>
         [MethodImpl(MethodImplOptions.AggressiveInlining)]
-        public static bool StartsWith(this Span<byte> span, ReadOnlySpan<byte> value)
-        {
-            int valueLength = value.Length;
-            return valueLength <= span.Length && SpanHelpers.SequenceEqual(ref span.DangerousGetPinnableReference(), ref value.DangerousGetPinnableReference(), valueLength);
-        }
-
-        /// <summary>
-        /// Determines whether the specified sequence appears at the start of the span.
-        /// </summary>
-        [MethodImpl(MethodImplOptions.AggressiveInlining)]
         public static bool StartsWith<T>(this Span<T> span, ReadOnlySpan<T> value)
-            where T : struct, IEquatable<T>
-        {
-            int valueLength = value.Length;
-            return valueLength <= span.Length && SpanHelpers.SequenceEqual(ref span.DangerousGetPinnableReference(), ref value.DangerousGetPinnableReference(), valueLength);
-        }
-
-        /// <summary>
-        /// Determines whether the specified sequence appears at the start of the span.
-        /// </summary>
-        [MethodImpl(MethodImplOptions.AggressiveInlining)]
-        public static bool StartsWith(this ReadOnlySpan<byte> span, ReadOnlySpan<byte> value)
+            where T : IEquatable<T>
         {
             int valueLength = value.Length;
+            if (typeof(T) == typeof(byte))
+                return valueLength <= span.Length && 
+                SpanHelpers.SequenceEqual(
+                    ref Unsafe.As<T, byte>(ref span.DangerousGetPinnableReference()),
+                    ref Unsafe.As<T, byte>(ref value.DangerousGetPinnableReference()),
+                    valueLength);
             return valueLength <= span.Length && SpanHelpers.SequenceEqual(ref span.DangerousGetPinnableReference(), ref value.DangerousGetPinnableReference(), valueLength);
         }
 
@@ -255,9 +210,15 @@ namespace System
         /// </summary>
         [MethodImpl(MethodImplOptions.AggressiveInlining)]
         public static bool StartsWith<T>(this ReadOnlySpan<T> span, ReadOnlySpan<T> value)
-            where T : struct, IEquatable<T>
+            where T : IEquatable<T>
         {
             int valueLength = value.Length;
+            if (typeof(T) == typeof(byte))
+                return valueLength <= span.Length && 
+                SpanHelpers.SequenceEqual(
+                    ref Unsafe.As<T, byte>(ref span.DangerousGetPinnableReference()),
+                    ref Unsafe.As<T, byte>(ref value.DangerousGetPinnableReference()),
+                    valueLength);
             return valueLength <= span.Length && SpanHelpers.SequenceEqual(ref span.DangerousGetPinnableReference(), ref value.DangerousGetPinnableReference(), valueLength);
         }
 
index b4d65c0..88bb444 100644 (file)
@@ -10,7 +10,7 @@ namespace System
     internal static partial class SpanHelpers
     {
         public static int IndexOf<T>(ref T searchSpace, int searchSpaceLength, ref T value, int valueLength)
-            where T : struct, IEquatable<T>
+            where T : IEquatable<T>
         {
             Debug.Assert(searchSpaceLength >= 0);
             Debug.Assert(valueLength >= 0);
@@ -46,7 +46,7 @@ namespace System
         }
 
         public static unsafe int IndexOf<T>(ref T searchSpace, T value, int length)
-            where T : struct, IEquatable<T>
+            where T : IEquatable<T>
         {
             Debug.Assert(length >= 0);
 
@@ -120,7 +120,7 @@ namespace System
         }
 
         public static bool SequenceEqual<T>(ref T first, ref T second, int length)
-            where T : struct, IEquatable<T>
+            where T : IEquatable<T>
         {
             Debug.Assert(length >= 0);
 
index 28212e2..7557533 100644 (file)
@@ -53,7 +53,7 @@ namespace System.Memory.Tests
                 {
                     for (int i = 0; i < Benchmark.InnerIterationCount; i++)
                     {
-                        index |= byteSpan.IndexOf(53);        // '5' = 53
+                        index |= byteSpan.IndexOf<byte>(53);        // '5' = 53
                     }
                 }
             }
index 60c9a83..912429e 100644 (file)
@@ -9,7 +9,7 @@ namespace System.Memory.Tests
 {
     public class Perf_Span_StartsWith
     {
-        [Benchmark]
+        [Benchmark(InnerIterationCount = 10000)]
         [InlineData(1, 1)]
         [InlineData(10, 1)]
         [InlineData(100, 1)]
@@ -46,7 +46,7 @@ namespace System.Memory.Tests
             {
                 using (iteration.StartMeasurement())
                 {
-                    for (int i = 0; i < 10000; i++)
+                    for (int i = 0; i < Benchmark.InnerIterationCount; i++)
                     {
                         bool result = span.StartsWith(value);
                     }
@@ -54,7 +54,7 @@ namespace System.Memory.Tests
             }
         }
 
-        [Benchmark]
+        [Benchmark(InnerIterationCount = 1000000)]
         [InlineData(1, 1)]
         [InlineData(10, 1)]
         [InlineData(100, 1)]
@@ -91,7 +91,52 @@ namespace System.Memory.Tests
             {
                 using (iteration.StartMeasurement())
                 {
-                    for (int i = 0; i < 10000; i++)
+                    for (int i = 0; i < Benchmark.InnerIterationCount; i++)
+                    {
+                        bool result = span.StartsWith(value);
+                    }
+                }
+            }
+        }
+
+        [Benchmark(InnerIterationCount = 10000)]
+        [InlineData(1, 1)]
+        [InlineData(10, 1)]
+        [InlineData(100, 1)]
+        [InlineData(1000, 1)]
+        [InlineData(10000, 1)]
+        [InlineData(10, 10)]
+        [InlineData(100, 10)]
+        [InlineData(1000, 10)]
+        [InlineData(10000, 10)]
+        [InlineData(100, 100)]
+        [InlineData(1000, 100)]
+        [InlineData(10000, 100)]
+        [InlineData(1000, 1000)]
+        [InlineData(10000, 1000)]
+        [InlineData(10000, 10000)]
+        public void String(int size, int valSize)
+        {
+            var a = new string[size];
+            for (int i = 0; i < size; i++)
+            {
+                int num = 65 + i % 26;
+                a[i] = ((char)num).ToString();
+            }
+
+            var b = new string[valSize];
+            for (int i = 0; i < valSize; i++)
+            {
+                int num = 65 + i % 26;
+                b[i] = ((char)num).ToString();
+            }
+            var span = new Span<string>(a);
+            var value = new Span<string>(b);
+            foreach (var iteration in Benchmark.Iterations)
+            {
+                using (iteration.StartMeasurement())
+                {
+                    for (int i = 0; i < Benchmark.InnerIterationCount; i++)
                     {
                         bool result = span.StartsWith(value);
                     }
index 09182a4..f37938f 100644 (file)
@@ -14,7 +14,7 @@ namespace System.SpanTests
         public static void ZeroLengthIndexOf_Byte()
         {
             ReadOnlySpan<byte> sp = new ReadOnlySpan<byte>(Array.Empty<byte>());
-            int idx = sp.IndexOf(0);
+            int idx = sp.IndexOf<byte>(0);
             Assert.Equal(-1, idx);
         }
 
@@ -29,7 +29,7 @@ namespace System.SpanTests
                 for (int i = 0; i < length; i++)
                 {
                     byte target0 = default(byte);
-                    int idx = span.IndexOf(target0);
+                    int idx = span.IndexOf<byte>(target0);
                     Assert.Equal(0, idx);
                 }
             }
@@ -50,7 +50,7 @@ namespace System.SpanTests
                 for (int targetIndex = 0; targetIndex < length; targetIndex++)
                 {
                     byte target = a[targetIndex];
-                    int idx = span.IndexOf(target);
+                    int idx = span.IndexOf<byte>(target);
                     Assert.Equal(targetIndex, idx);
                 }
             }
@@ -71,7 +71,7 @@ namespace System.SpanTests
                 }
                 ReadOnlySpan<byte> span = new ReadOnlySpan<byte>(a);
 
-                int idx = span.IndexOf(target);
+                int idx = span.IndexOf<byte>(target);
                 Assert.Equal(-1, idx);
             }
         }
@@ -83,11 +83,11 @@ namespace System.SpanTests
             for (var i = 0; i < Vector<byte>.Count; i++)
             {
                 var span = new ReadOnlySpan<byte>(array, i, 3 * Vector<byte>.Count);
-                int idx = span.IndexOf((byte)'1');
+                int idx = span.IndexOf<byte>((byte)'1');
                 Assert.Equal(-1, idx);
 
                 span = new ReadOnlySpan<byte>(array, i, 3 * Vector<byte>.Count - 3);
-                idx = span.IndexOf((byte)'1');
+                idx = span.IndexOf<byte>((byte)'1');
                 Assert.Equal(-1, idx);
             }
         }
@@ -103,11 +103,11 @@ namespace System.SpanTests
             for (var i = 0; i < Vector<byte>.Count; i++)
             {
                 var span = new ReadOnlySpan<byte>(array, i, 3 * Vector<byte>.Count);
-                int idx = span.IndexOf(5);
+                int idx = span.IndexOf<byte>(5);
                 Assert.Equal(0, idx);
 
                 span = new ReadOnlySpan<byte>(array, i, 3 * Vector<byte>.Count - 3);
-                idx = span.IndexOf(5);
+                idx = span.IndexOf<byte>(5);
                 Assert.Equal(0, idx);
             }
         }
@@ -128,7 +128,7 @@ namespace System.SpanTests
                 a[length - 2] = 200;
 
                 ReadOnlySpan<byte> span = new ReadOnlySpan<byte>(a);
-                int idx = span.IndexOf(200);
+                int idx = span.IndexOf<byte>(200);
                 Assert.Equal(length - 2, idx);
             }
         }
@@ -142,7 +142,7 @@ namespace System.SpanTests
                 a[0] = 99;
                 a[length + 1] = 99;
                 ReadOnlySpan<byte> span = new ReadOnlySpan<byte>(a, 1, length);
-                int index = span.IndexOf(99);
+                int index = span.IndexOf<byte>(99);
                 Assert.Equal(-1, index);
             }
         }
@@ -177,7 +177,7 @@ namespace System.SpanTests
             var index = -1;
             if (searchFor.Length == 1)
             {
-                index = span.IndexOf((byte)searchFor[0]);
+                index = span.IndexOf<byte>((byte)searchFor[0]);
             }
             else if (searchFor.Length == 2)
             {
index 3a23695..5040363 100644 (file)
@@ -13,7 +13,7 @@ namespace System.SpanTests
         {
             ReadOnlySpan<byte> span = new ReadOnlySpan<byte>(new byte[] { 5, 1, 77, 2, 3, 77, 77, 4, 5, 77, 77, 77, 88, 6, 6, 77, 77, 88, 9 });
             ReadOnlySpan<byte> value = new ReadOnlySpan<byte>(new byte[] { 5, 1, 77 });
-            int index = span.IndexOf(value);
+            int index = span.IndexOf<byte>(value);
             Assert.Equal(0, index);
         }
 
@@ -22,7 +22,7 @@ namespace System.SpanTests
         {
             ReadOnlySpan<byte> span = new ReadOnlySpan<byte>(new byte[] { 1, 2, 3, 1, 2, 3, 1, 2, 3 });
             ReadOnlySpan<byte> value = new ReadOnlySpan<byte>(new byte[] { 2, 3 });
-            int index = span.IndexOf(value);
+            int index = span.IndexOf<byte>(value);
             Assert.Equal(1, index);
         }
 
@@ -31,7 +31,7 @@ namespace System.SpanTests
         {
             ReadOnlySpan<byte> span = new ReadOnlySpan<byte>(new byte[] { 0, 1, 77, 2, 3, 77, 77, 4, 5, 77, 77, 77, 88, 6, 6, 77, 77, 88, 9 });
             ReadOnlySpan<byte> value = new ReadOnlySpan<byte>(new byte[] { 77, 77, 88 });
-            int index = span.IndexOf(value);
+            int index = span.IndexOf<byte>(value);
             Assert.Equal(10, index);
         }
 
@@ -40,7 +40,7 @@ namespace System.SpanTests
         {
             ReadOnlySpan<byte> span = new ReadOnlySpan<byte>(new byte[] { 0, 1, 77, 2, 3, 77, 77, 4, 5, 77, 77, 77, 88, 6, 6, 77, 77, 88, 9 });
             ReadOnlySpan<byte> value = new ReadOnlySpan<byte>(new byte[] { 77, 77, 88, 99 });
-            int index = span.IndexOf(value);
+            int index = span.IndexOf<byte>(value);
             Assert.Equal(-1, index);
         }
 
@@ -49,7 +49,7 @@ namespace System.SpanTests
         {
             ReadOnlySpan<byte> span = new ReadOnlySpan<byte>(new byte[] { 0, 1, 77, 2, 3, 77, 77, 4, 5, 77, 77, 77, 88, 6, 6, 77, 77, 88, 9 });
             ReadOnlySpan<byte> value = new ReadOnlySpan<byte>(new byte[] { 100, 77, 88, 99 });
-            int index = span.IndexOf(value);
+            int index = span.IndexOf<byte>(value);
             Assert.Equal(-1, index);
         }
 
@@ -58,7 +58,7 @@ namespace System.SpanTests
         {
             ReadOnlySpan<byte> span = new ReadOnlySpan<byte>(new byte[] { 0, 1, 2, 3, 4, 5 });
             ReadOnlySpan<byte> value = new ReadOnlySpan<byte>(new byte[] { 3, 4, 5 });
-            int index = span.IndexOf(value);
+            int index = span.IndexOf<byte>(value);
             Assert.Equal(3, index);
         }
 
@@ -67,7 +67,7 @@ namespace System.SpanTests
         {
             ReadOnlySpan<byte> span = new ReadOnlySpan<byte>(new byte[] { 0, 1, 2, 3, 4, 5 }, 0, 5);
             ReadOnlySpan<byte> value = new ReadOnlySpan<byte>(new byte[] { 3, 4, 5 });
-            int index = span.IndexOf(value);
+            int index = span.IndexOf<byte>(value);
             Assert.Equal(-1, index);
         }
 
@@ -77,7 +77,7 @@ namespace System.SpanTests
             // A zero-length value is always "found" at the start of the span.
             ReadOnlySpan<byte> span = new ReadOnlySpan<byte>(new byte[] { 0, 1, 77, 2, 3, 77, 77, 4, 5, 77, 77, 77, 88, 6, 6, 77, 77, 88, 9 });
             ReadOnlySpan<byte> value = new ReadOnlySpan<byte>(Array.Empty<byte>());
-            int index = span.IndexOf(value);
+            int index = span.IndexOf<byte>(value);
             Assert.Equal(0, index);
         }
 
@@ -86,7 +86,7 @@ namespace System.SpanTests
         {
             ReadOnlySpan<byte> span = new ReadOnlySpan<byte>(Array.Empty<byte>());
             ReadOnlySpan<byte> value = new ReadOnlySpan<byte>(new byte[] { 1, 2, 3 });
-            int index = span.IndexOf(value);
+            int index = span.IndexOf<byte>(value);
             Assert.Equal(-1, index);
         }
 
@@ -96,7 +96,7 @@ namespace System.SpanTests
             // A zero-length value is always "found" at the start of the span.
             ReadOnlySpan<byte> span = new ReadOnlySpan<byte>(new byte[] { 0, 1, 2, 3, 4, 5 });
             ReadOnlySpan<byte> value = new ReadOnlySpan<byte>(new byte[] { 2 });
-            int index = span.IndexOf(value);
+            int index = span.IndexOf<byte>(value);
             Assert.Equal(2, index);
         }
 
@@ -106,7 +106,7 @@ namespace System.SpanTests
             // A zero-length value is always "found" at the start of the span.
             ReadOnlySpan<byte> span = new ReadOnlySpan<byte>(new byte[] { 0, 1, 2, 3, 4, 5 });
             ReadOnlySpan<byte> value = new ReadOnlySpan<byte>(new byte[] { 5 });
-            int index = span.IndexOf(value);
+            int index = span.IndexOf<byte>(value);
             Assert.Equal(5, index);
         }
 
@@ -116,7 +116,7 @@ namespace System.SpanTests
             // A zero-length value is always "found" at the start of the span.
             ReadOnlySpan<byte> span = new ReadOnlySpan<byte>(new byte[] { 0, 1, 2, 3, 4, 5 }, 0, 5);
             ReadOnlySpan<byte> value = new ReadOnlySpan<byte>(new byte[] { 5 });
-            int index = span.IndexOf(value);
+            int index = span.IndexOf<byte>(value);
             Assert.Equal(-1, index);
         }
     }
index fa5d6dc..02dd9ec 100644 (file)
@@ -15,7 +15,7 @@ namespace System.SpanTests
 
             ReadOnlySpan<byte> first = new ReadOnlySpan<byte>(a, 1, 0);
             ReadOnlySpan<byte> second = new ReadOnlySpan<byte>(a, 2, 0);
-            bool b = first.SequenceEqual(second);
+            bool b = first.SequenceEqual<byte>(second);
             Assert.True(b);
         }
 
@@ -24,7 +24,7 @@ namespace System.SpanTests
         {
             byte[] a = { 4, 5, 6 };
             ReadOnlySpan<byte> span = new ReadOnlySpan<byte>(a);
-            bool b = span.SequenceEqual(span);
+            bool b = span.SequenceEqual<byte>(span);
             Assert.True(b);
         }
 
@@ -33,7 +33,7 @@ namespace System.SpanTests
         {
             byte[] a = { 4, 5, 6 };
             ReadOnlySpan<byte> first = new ReadOnlySpan<byte>(a, 0, 3);
-            bool b = first.SequenceEqual(a);
+            bool b = first.SequenceEqual<byte>(a);
             Assert.True(b);
         }
 
@@ -45,7 +45,7 @@ namespace System.SpanTests
             var segment = new ArraySegment<byte>(dst, 1, 3);
 
             ReadOnlySpan<byte> first = new ReadOnlySpan<byte>(src, 0, 3);
-            bool b = first.SequenceEqual(segment);
+            bool b = first.SequenceEqual<byte>(segment);
             Assert.True(b);
         }
 
@@ -55,7 +55,7 @@ namespace System.SpanTests
             byte[] a = { 4, 5, 6 };
             ReadOnlySpan<byte> first = new ReadOnlySpan<byte>(a, 0, 3);
             ReadOnlySpan<byte> second = new ReadOnlySpan<byte>(a, 0, 2);
-            bool b = first.SequenceEqual(second);
+            bool b = first.SequenceEqual<byte>(second);
             Assert.False(b);
         }
 
@@ -77,7 +77,7 @@ namespace System.SpanTests
 
                     ReadOnlySpan<byte> firstSpan = new ReadOnlySpan<byte>(first);
                     ReadOnlySpan<byte> secondSpan = new ReadOnlySpan<byte>(second);
-                    bool b = firstSpan.SequenceEqual(secondSpan);
+                    bool b = firstSpan.SequenceEqual<byte>(secondSpan);
                     Assert.False(b);
                 }
             }
@@ -96,7 +96,7 @@ namespace System.SpanTests
                 second[length + 1] = 100;
                 ReadOnlySpan<byte> span1 = new ReadOnlySpan<byte>(first, 1, length);
                 ReadOnlySpan<byte> span2 = new ReadOnlySpan<byte>(second, 1, length);
-                bool b = span1.SequenceEqual(span2);
+                bool b = span1.SequenceEqual<byte>(span2);
                 Assert.True(b);
             }
         }
index 680235f..57fa490 100644 (file)
@@ -15,7 +15,7 @@ namespace System.SpanTests
 
             ReadOnlySpan<byte> span = new ReadOnlySpan<byte>(a);
             ReadOnlySpan<byte> slice = new ReadOnlySpan<byte>(a, 2, 0);
-            bool b = span.StartsWith(slice);
+            bool b = span.StartsWith<byte>(slice);
             Assert.True(b);
         }
 
@@ -24,7 +24,7 @@ namespace System.SpanTests
         {
             byte[] a = { 4, 5, 6 };
             ReadOnlySpan<byte> span = new ReadOnlySpan<byte>(a);
-            bool b = span.StartsWith(span);
+            bool b = span.StartsWith<byte>(span);
             Assert.True(b);
         }
 
@@ -34,7 +34,7 @@ namespace System.SpanTests
             byte[] a = { 4, 5, 6 };
             ReadOnlySpan<byte> span = new ReadOnlySpan<byte>(a, 0, 2);
             ReadOnlySpan<byte> slice = new ReadOnlySpan<byte>(a, 0, 3);
-            bool b = span.StartsWith(slice);
+            bool b = span.StartsWith<byte>(slice);
             Assert.False(b);
         }
 
@@ -44,7 +44,7 @@ namespace System.SpanTests
             byte[] a = { 4, 5, 6 };
             ReadOnlySpan<byte> span = new ReadOnlySpan<byte>(a, 0, 3);
             ReadOnlySpan<byte> slice = new ReadOnlySpan<byte>(a, 0, 2);
-            bool b = span.StartsWith(slice);
+            bool b = span.StartsWith<byte>(slice);
             Assert.True(b);
         }
 
@@ -55,7 +55,7 @@ namespace System.SpanTests
             byte[] b = { 4, 5, 6 };
             ReadOnlySpan<byte> span = new ReadOnlySpan<byte>(a, 0, 3);
             ReadOnlySpan<byte> slice = new ReadOnlySpan<byte>(b, 0, 3);
-            bool c = span.StartsWith(slice);
+            bool c = span.StartsWith<byte>(slice);
             Assert.True(c);
         }
 
@@ -77,7 +77,7 @@ namespace System.SpanTests
 
                     ReadOnlySpan<byte> firstSpan = new ReadOnlySpan<byte>(first);
                     ReadOnlySpan<byte> secondSpan = new ReadOnlySpan<byte>(second);
-                    bool b = firstSpan.StartsWith(secondSpan);
+                    bool b = firstSpan.StartsWith<byte>(secondSpan);
                     Assert.False(b);
                 }
             }
@@ -96,7 +96,7 @@ namespace System.SpanTests
                 second[length + 1] = 100;
                 ReadOnlySpan<byte> span1 = new ReadOnlySpan<byte>(first, 1, length);
                 ReadOnlySpan<byte> span2 = new ReadOnlySpan<byte>(second, 1, length);
-                bool b = span1.StartsWith(span2);
+                bool b = span1.StartsWith<byte>(span2);
                 Assert.True(b);
             }
         }
index 265bda5..7198163 100644 (file)
@@ -14,7 +14,7 @@ namespace System.SpanTests
         public static void ZeroLengthIndexOf_Byte()
         {
             Span<byte> sp = new Span<byte>(Array.Empty<byte>());
-            int idx = sp.IndexOf(0);
+            int idx = sp.IndexOf<byte>(0);
             Assert.Equal(-1, idx);
         }
 
@@ -29,7 +29,7 @@ namespace System.SpanTests
                 for (int i = 0; i < length; i++)
                 {
                     byte target0 = default(byte);
-                    int idx = span.IndexOf(target0);
+                    int idx = span.IndexOf<byte>(target0);
                     Assert.Equal(0, idx);
                 }
             }
@@ -50,7 +50,7 @@ namespace System.SpanTests
                 for (int targetIndex = 0; targetIndex < length; targetIndex++)
                 {
                     byte target = a[targetIndex];
-                    int idx = span.IndexOf(target);
+                    int idx = span.IndexOf<byte>(target);
                     Assert.Equal(targetIndex, idx);
                 }
             }
@@ -71,7 +71,7 @@ namespace System.SpanTests
                 }
                 Span<byte> span = new Span<byte>(a);
 
-                int idx = span.IndexOf(target);
+                int idx = span.IndexOf<byte>(target);
                 Assert.Equal(-1, idx);
             }
         }
@@ -83,11 +83,11 @@ namespace System.SpanTests
             for (var i = 0; i < Vector<byte>.Count; i++)
             {
                 var span = new Span<byte>(array, i, 3 * Vector<byte>.Count);
-                int idx = span.IndexOf((byte)'1');
+                int idx = span.IndexOf<byte>((byte)'1');
                 Assert.Equal(-1, idx);
 
                 span = new Span<byte>(array, i, 3 * Vector<byte>.Count - 3);
-                idx = span.IndexOf((byte)'1');
+                idx = span.IndexOf<byte>((byte)'1');
                 Assert.Equal(-1, idx);
             }
         }
@@ -103,11 +103,11 @@ namespace System.SpanTests
             for (var i = 0; i < Vector<byte>.Count; i++)
             {
                 var span = new Span<byte>(array, i, 3 * Vector<byte>.Count);
-                int idx = span.IndexOf(5);
+                int idx = span.IndexOf<byte>(5);
                 Assert.Equal(0, idx);
 
                 span = new Span<byte>(array, i, 3 * Vector<byte>.Count - 3);
-                idx = span.IndexOf(5);
+                idx = span.IndexOf<byte>(5);
                 Assert.Equal(0, idx);
             }
         }
@@ -128,7 +128,7 @@ namespace System.SpanTests
                 a[length - 2] = 200;
 
                 Span<byte> span = new Span<byte>(a);
-                int idx = span.IndexOf(200);
+                int idx = span.IndexOf<byte>(200);
                 Assert.Equal(length - 2, idx);
             }
         }
@@ -142,7 +142,7 @@ namespace System.SpanTests
                 a[0] = 99;
                 a[length + 1] = 99;
                 Span<byte> span = new Span<byte>(a, 1, length);
-                int index = span.IndexOf(99);
+                int index = span.IndexOf<byte>(99);
                 Assert.Equal(-1, index);
             }
         }
@@ -177,7 +177,7 @@ namespace System.SpanTests
             var index = -1;
             if (searchFor.Length == 1)
             {
-                index = span.IndexOf((byte)searchFor[0]);
+                index = span.IndexOf<byte>((byte)searchFor[0]);
             }
             else if (searchFor.Length == 2)
             {
index a38519b..a7f4ff4 100644 (file)
@@ -13,7 +13,7 @@ namespace System.SpanTests
         {
             Span<byte> span = new Span<byte>(new byte[] { 5, 1, 77, 2, 3, 77, 77, 4, 5, 77, 77, 77, 88, 6, 6, 77, 77, 88, 9 });
             Span<byte> value = new Span<byte>(new byte[] { 5, 1, 77 });
-            int index = span.IndexOf(value);
+            int index = span.IndexOf<byte>(value);
             Assert.Equal(0, index);
         }
 
@@ -22,7 +22,7 @@ namespace System.SpanTests
         {
             Span<byte> span = new Span<byte>(new byte[] { 1, 2, 3, 1, 2, 3, 1, 2, 3 });
             Span<byte> value = new Span<byte>(new byte[] { 2, 3 });
-            int index = span.IndexOf(value);
+            int index = span.IndexOf<byte>(value);
             Assert.Equal(1, index);
         }
 
@@ -31,7 +31,7 @@ namespace System.SpanTests
         {
             Span<byte> span = new Span<byte>(new byte[] { 0, 1, 77, 2, 3, 77, 77, 4, 5, 77, 77, 77, 88, 6, 6, 77, 77, 88, 9 });
             Span<byte> value = new Span<byte>(new byte[] { 77, 77, 88 });
-            int index = span.IndexOf(value);
+            int index = span.IndexOf<byte>(value);
             Assert.Equal(10, index);
         }
 
@@ -40,7 +40,7 @@ namespace System.SpanTests
         {
             Span<byte> span = new Span<byte>(new byte[] { 0, 1, 77, 2, 3, 77, 77, 4, 5, 77, 77, 77, 88, 6, 6, 77, 77, 88, 9 });
             Span<byte> value = new Span<byte>(new byte[] { 77, 77, 88, 99 });
-            int index = span.IndexOf(value);
+            int index = span.IndexOf<byte>(value);
             Assert.Equal(-1, index);
         }
 
@@ -49,7 +49,7 @@ namespace System.SpanTests
         {
             Span<byte> span = new Span<byte>(new byte[] { 0, 1, 77, 2, 3, 77, 77, 4, 5, 77, 77, 77, 88, 6, 6, 77, 77, 88, 9 });
             Span<byte> value = new Span<byte>(new byte[] { 100, 77, 88, 99 });
-            int index = span.IndexOf(value);
+            int index = span.IndexOf<byte>(value);
             Assert.Equal(-1, index);
         }
 
@@ -58,7 +58,7 @@ namespace System.SpanTests
         {
             Span<byte> span = new Span<byte>(new byte[] { 0, 1, 2, 3, 4, 5 });
             Span<byte> value = new Span<byte>(new byte[] { 3, 4, 5 });
-            int index = span.IndexOf(value);
+            int index = span.IndexOf<byte>(value);
             Assert.Equal(3, index);
         }
 
@@ -67,7 +67,7 @@ namespace System.SpanTests
         {
             Span<byte> span = new Span<byte>(new byte[] { 0, 1, 2, 3, 4, 5 }, 0, 5);
             Span<byte> value = new Span<byte>(new byte[] { 3, 4, 5 });
-            int index = span.IndexOf(value);
+            int index = span.IndexOf<byte>(value);
             Assert.Equal(-1, index);
         }
 
@@ -77,7 +77,7 @@ namespace System.SpanTests
             // A zero-length value is always "found" at the start of the span.
             Span<byte> span = new Span<byte>(new byte[] { 0, 1, 77, 2, 3, 77, 77, 4, 5, 77, 77, 77, 88, 6, 6, 77, 77, 88, 9 });
             Span<byte> value = new Span<byte>(Array.Empty<byte>());
-            int index = span.IndexOf(value);
+            int index = span.IndexOf<byte>(value);
             Assert.Equal(0, index);
         }
 
@@ -86,7 +86,7 @@ namespace System.SpanTests
         {
             Span<byte> span = new Span<byte>(Array.Empty<byte>());
             Span<byte> value = new Span<byte>(new byte[] { 1, 2, 3 });
-            int index = span.IndexOf(value);
+            int index = span.IndexOf<byte>(value);
             Assert.Equal(-1, index);
         }
 
@@ -96,7 +96,7 @@ namespace System.SpanTests
             // A zero-length value is always "found" at the start of the span.
             Span<byte> span = new Span<byte>(new byte[] { 0, 1, 2, 3, 4, 5 });
             Span<byte> value = new Span<byte>(new byte[] { 2 });
-            int index = span.IndexOf(value);
+            int index = span.IndexOf<byte>(value);
             Assert.Equal(2, index);
         }
 
@@ -106,7 +106,7 @@ namespace System.SpanTests
             // A zero-length value is always "found" at the start of the span.
             Span<byte> span = new Span<byte>(new byte[] { 0, 1, 2, 3, 4, 5 });
             Span<byte> value = new Span<byte>(new byte[] { 5 });
-            int index = span.IndexOf(value);
+            int index = span.IndexOf<byte>(value);
             Assert.Equal(5, index);
         }
 
@@ -116,7 +116,7 @@ namespace System.SpanTests
             // A zero-length value is always "found" at the start of the span.
             Span<byte> span = new Span<byte>(new byte[] { 0, 1, 2, 3, 4, 5 }, 0, 5);
             Span<byte> value = new Span<byte>(new byte[] { 5 });
-            int index = span.IndexOf(value);
+            int index = span.IndexOf<byte>(value);
             Assert.Equal(-1, index);
         }
     }
index 8520587..66529fa 100644 (file)
@@ -15,7 +15,7 @@ namespace System.SpanTests
 
             Span<byte> first = new Span<byte>(a, 1, 0);
             Span<byte> second = new Span<byte>(a, 2, 0);
-            bool b = first.SequenceEqual(second);
+            bool b = first.SequenceEqual<byte>(second);
             Assert.True(b);
         }
 
@@ -24,7 +24,7 @@ namespace System.SpanTests
         {
             byte[] a = { 4, 5, 6 };
             Span<byte> span = new Span<byte>(a);
-            bool b = span.SequenceEqual(span);
+            bool b = span.SequenceEqual<byte>(span);
             Assert.True(b);
         }
 
@@ -33,7 +33,7 @@ namespace System.SpanTests
         {
             byte[] a = { 4, 5, 6 };
             Span<byte> first = new Span<byte>(a, 0, 3);
-            bool b = first.SequenceEqual(a);
+            bool b = first.SequenceEqual<byte>(a);
             Assert.True(b);
         }
 
@@ -45,7 +45,7 @@ namespace System.SpanTests
             var segment = new ArraySegment<byte>(dst, 1, 3);
 
             Span<byte> first = new Span<byte>(src, 0, 3);
-            bool b = first.SequenceEqual(segment);
+            bool b = first.SequenceEqual<byte>(segment);
             Assert.True(b);
         }
 
@@ -55,7 +55,7 @@ namespace System.SpanTests
             byte[] a = { 4, 5, 6 };
             Span<byte> first = new Span<byte>(a, 0, 3);
             Span<byte> second = new Span<byte>(a, 0, 2);
-            bool b = first.SequenceEqual(second);
+            bool b = first.SequenceEqual<byte>(second);
             Assert.False(b);
         }
 
@@ -77,7 +77,7 @@ namespace System.SpanTests
 
                     Span<byte> firstSpan = new Span<byte>(first);
                     ReadOnlySpan<byte> secondSpan = new ReadOnlySpan<byte>(second);
-                    bool b = firstSpan.SequenceEqual(secondSpan);
+                    bool b = firstSpan.SequenceEqual<byte>(secondSpan);
                     Assert.False(b);
                 }
             }
@@ -96,7 +96,7 @@ namespace System.SpanTests
                 second[length + 1] = 100;
                 Span<byte> span1 = new Span<byte>(first, 1, length);
                 ReadOnlySpan<byte> span2 = new ReadOnlySpan<byte>(second, 1, length);
-                bool b = span1.SequenceEqual(span2);
+                bool b = span1.SequenceEqual<byte>(span2);
                 Assert.True(b);
             }
         }
index 4e86dce..8877780 100644 (file)
@@ -15,7 +15,7 @@ namespace System.SpanTests
 
             Span<byte> span = new Span<byte>(a);
             ReadOnlySpan<byte> slice = new ReadOnlySpan<byte>(a, 2, 0);
-            bool b = span.StartsWith(slice);
+            bool b = span.StartsWith<byte>(slice);
             Assert.True(b);
         }
 
@@ -24,7 +24,7 @@ namespace System.SpanTests
         {
             byte[] a = { 4, 5, 6 };
             Span<byte> span = new Span<byte>(a);
-            bool b = span.StartsWith(span);
+            bool b = span.StartsWith<byte>(span);
             Assert.True(b);
         }
 
@@ -34,7 +34,7 @@ namespace System.SpanTests
             byte[] a = { 4, 5, 6 };
             Span<byte> span = new Span<byte>(a, 0, 2);
             ReadOnlySpan<byte> slice = new ReadOnlySpan<byte>(a, 0, 3);
-            bool b = span.StartsWith(slice);
+            bool b = span.StartsWith<byte>(slice);
             Assert.False(b);
         }
 
@@ -44,7 +44,7 @@ namespace System.SpanTests
             byte[] a = { 4, 5, 6 };
             Span<byte> span = new Span<byte>(a, 0, 3);
             ReadOnlySpan<byte> slice = new ReadOnlySpan<byte>(a, 0, 2);
-            bool b = span.StartsWith(slice);
+            bool b = span.StartsWith<byte>(slice);
             Assert.True(b);
         }
 
@@ -55,7 +55,7 @@ namespace System.SpanTests
             byte[] b = { 4, 5, 6 };
             Span<byte> span = new Span<byte>(a, 0, 3);
             ReadOnlySpan<byte> slice = new ReadOnlySpan<byte>(b, 0, 3);
-            bool c = span.StartsWith(slice);
+            bool c = span.StartsWith<byte>(slice);
             Assert.True(c);
         }
 
@@ -77,7 +77,7 @@ namespace System.SpanTests
 
                     Span<byte> firstSpan = new Span<byte>(first);
                     ReadOnlySpan<byte> secondSpan = new ReadOnlySpan<byte>(second);
-                    bool b = firstSpan.StartsWith(secondSpan);
+                    bool b = firstSpan.StartsWith<byte>(secondSpan);
                     Assert.False(b);
                 }
             }
@@ -96,7 +96,7 @@ namespace System.SpanTests
                 second[length + 1] = 100;
                 Span<byte> span1 = new Span<byte>(first, 1, length);
                 ReadOnlySpan<byte> span2 = new ReadOnlySpan<byte>(second, 1, length);
-                bool b = span1.StartsWith(span2);
+                bool b = span1.StartsWith<byte>(span2);
                 Assert.True(b);
             }
         }