Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Common/src/System/Security/Cryptography/DerEncoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ internal static byte[][] SegmentedEncodeUnsignedInteger(ReadOnlySpan<byte> bigEn
int length = end - start;
int writeStart = bigEndianBytes[start] > 0x7F ? 1 : 0;
var dataBytes = new byte[length + writeStart];
bigEndianBytes.Slice(start, length).CopyTo(new Span<byte>(dataBytes, writeStart));
bigEndianBytes.Slice(start, length).CopyTo(new Span<byte>(dataBytes).Slice(writeStart));

return new[]
{
Expand Down
2 changes: 0 additions & 2 deletions src/System.Memory/ref/System.Memory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ public partial struct ReadOnlySpan<T>
{
public static ReadOnlySpan<T> Empty { get { throw null; } }
public ReadOnlySpan(T[] array) { throw null;}
public ReadOnlySpan(T[] array, int start) { throw null;}
public ReadOnlySpan(T[] array, int start, int length) { throw null;}
public unsafe ReadOnlySpan(void* pointer, int length) { throw null;}
public bool IsEmpty { get { throw null; } }
Expand Down Expand Up @@ -43,7 +42,6 @@ public partial struct Span<T>
{
public static Span<T> Empty { get { throw null; } }
public Span(T[] array) { throw null;}
public Span(T[] array, int start) { throw null;}
public Span(T[] array, int start, int length) { throw null;}
public unsafe Span(void* pointer, int length) { throw null;}
public bool IsEmpty { get { throw null; } }
Expand Down
27 changes: 0 additions & 27 deletions src/System.Memory/src/System/ReadOnlySpan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,33 +35,6 @@ public ReadOnlySpan(T[] array)
_byteOffset = SpanHelpers.PerTypeValues<T>.ArrayAdjustment;
}

/// <summary>
/// Creates a new read-only span over the portion of the target array beginning
/// at 'start' index and covering the remainder of the array.
/// </summary>
/// <param name="array">The target array.</param>
/// <param name="start">The index at which to begin the read-only span.</param>
/// <exception cref="System.ArgumentNullException">Thrown when <paramref name="array"/> is a null
/// reference (Nothing in Visual Basic).</exception>
/// <exception cref="System.ArrayTypeMismatchException">Thrown when <paramref name="array"/> is covariant and array's type is not exactly T[].</exception>
/// <exception cref="System.ArgumentOutOfRangeException">
/// Thrown when the specified <paramref name="start"/> is not in the range (&lt;0 or &gt;=Length).
/// </exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ReadOnlySpan(T[] array, int start)
{
if (array == null)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);

int arrayLength = array.Length;
if ((uint)start > (uint)arrayLength)
ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.start);

_length = arrayLength - start;
_pinnable = Unsafe.As<Pinnable<T>>(array);
_byteOffset = SpanHelpers.PerTypeValues<T>.ArrayAdjustment.Add<T>(start);
}

/// <summary>
/// Creates a new read-only span over the portion of the target array beginning
/// at 'start' index and ending at 'end' index (exclusive).
Expand Down
29 changes: 0 additions & 29 deletions src/System.Memory/src/System/Span.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,35 +39,6 @@ public Span(T[] array)
_byteOffset = SpanHelpers.PerTypeValues<T>.ArrayAdjustment;
}

/// <summary>
/// Creates a new span over the portion of the target array beginning
/// at 'start' index and covering the remainder of the array.
/// </summary>
/// <param name="array">The target array.</param>
/// <param name="start">The index at which to begin the span.</param>
/// <exception cref="System.ArgumentNullException">Thrown when <paramref name="array"/> is a null
/// reference (Nothing in Visual Basic).</exception>
/// <exception cref="System.ArrayTypeMismatchException">Thrown when <paramref name="array"/> is covariant and array's type is not exactly T[].</exception>
/// <exception cref="System.ArgumentOutOfRangeException">
/// Thrown when the specified <paramref name="start"/> is not in the range (&lt;0 or &gt;=Length).
/// </exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Span(T[] array, int start)
{
if (array == null)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
if (default(T) == null && array.GetType() != typeof(T[]))
ThrowHelper.ThrowArrayTypeMismatchException_ArrayTypeMustBeExactMatch(typeof(T));

int arrayLength = array.Length;
if ((uint)start > (uint)arrayLength)
ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.start);

_length = arrayLength - start;
_pinnable = Unsafe.As<Pinnable<T>>(array);
_byteOffset = SpanHelpers.PerTypeValues<T>.ArrayAdjustment.Add<T>(start);
}

/// <summary>
/// Creates a new span over the portion of the target array beginning
/// at 'start' index and ending at 'end' index (exclusive).
Expand Down
20 changes: 0 additions & 20 deletions src/System.Memory/tests/ReadOnlySpan/CtorArray.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ public static void CtorArray1()
span = new ReadOnlySpan<int>(a);
span.Validate<int>(91, 92, -93, 94);

span = new ReadOnlySpan<int>(a, 0);
span.Validate<int>(91, 92, -93, 94);

span = new ReadOnlySpan<int>(a, 0, a.Length);
span.Validate<int>(91, 92, -93, 94);
}
Expand All @@ -39,9 +36,6 @@ public static void CtorArray2()
span = new ReadOnlySpan<long>(a);
span.Validate<long>(91, -92, 93, 94, -95);

span = new ReadOnlySpan<long>(a, 0);
span.Validate<long>(91, -92, 93, 94, -95);

span = new ReadOnlySpan<long>(a, 0, a.Length);
span.Validate<long>(91, -92, 93, 94, -95);
}
Expand All @@ -57,9 +51,6 @@ public static void CtorArray3()
span = new ReadOnlySpan<object>(a);
span.Validate<object>(o1, o2);

span = new ReadOnlySpan<object>(a, 0);
span.Validate<object>(o1, o2);

span = new ReadOnlySpan<object>(a, 0, a.Length);
span.Validate<object>(o1, o2);
}
Expand All @@ -73,9 +64,6 @@ public static void CtorArrayZeroLength()
span = new ReadOnlySpan<int>(empty);
span.Validate<int>();

span = new ReadOnlySpan<int>(empty, 0);
span.Validate<int>();

span = new ReadOnlySpan<int>(empty, 0, empty.Length);
span.Validate<int>();
}
Expand All @@ -84,7 +72,6 @@ public static void CtorArrayZeroLength()
public static void CtorArrayNullArray()
{
Assert.Throws<ArgumentNullException>(() => new ReadOnlySpan<int>((int[])null).DontBox());
Assert.Throws<ArgumentNullException>(() => new ReadOnlySpan<int>((int[])null, 0).DontBox());
Assert.Throws<ArgumentNullException>(() => new ReadOnlySpan<int>((int[])null, 0, 0).DontBox());
}

Expand All @@ -100,9 +87,6 @@ public static void CtorArrayWrongValueType()
span = new ReadOnlySpan<int>(aAsIntArray);
span.Validate<int>(42, -1);

span = new ReadOnlySpan<int>(aAsIntArray, 0);
span.Validate<int>(42, -1);

span = new ReadOnlySpan<int>(aAsIntArray, 0, aAsIntArray.Length);
span.Validate<int>(42, -1);
}
Expand All @@ -118,8 +102,6 @@ public static void CtorVariantArrayType()
string[] strArray = { "Hello" };
span = new ReadOnlySpan<object>(strArray);
span.Validate("Hello");
span = new ReadOnlySpan<object>(strArray, 0);
span.Validate("Hello");
span = new ReadOnlySpan<object>(strArray, 0, strArray.Length);
span.Validate("Hello");

Expand All @@ -128,8 +110,6 @@ public static void CtorVariantArrayType()
TestClass[] clsArray = { c1, c2 };
span = new ReadOnlySpan<object>(clsArray);
span.Validate(c1, c2);
span = new ReadOnlySpan<object>(clsArray, 0);
span.Validate(c1, c2);
span = new ReadOnlySpan<object>(clsArray, 0, clsArray.Length);
span.Validate(c1, c2);
}
Expand Down
54 changes: 0 additions & 54 deletions src/System.Memory/tests/ReadOnlySpan/CtorArrayInt.cs

This file was deleted.

17 changes: 0 additions & 17 deletions src/System.Memory/tests/Span/CtorArray.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ public static void CtorArray1()
span = new Span<int>(a);
span.Validate<int>(91, 92, -93, 94);

span = new Span<int>(a, 0);
span.Validate<int>(91, 92, -93, 94);

span = new Span<int>(a, 0, a.Length);
span.Validate<int>(91, 92, -93, 94);
}
Expand All @@ -39,9 +36,6 @@ public static void CtorArray2()
span = new Span<long>(a);
span.Validate<long>(91, -92, 93, 94, -95);

span = new Span<long>(a, 0);
span.Validate<long>(91, -92, 93, 94, -95);

span = new Span<long>(a, 0, a.Length);
span.Validate<long>(91, -92, 93, 94, -95);
}
Expand All @@ -57,9 +51,6 @@ public static void CtorArray3()
span = new Span<object>(a);
span.Validate<object>(o1, o2);

span = new Span<object>(a, 0);
span.Validate<object>(o1, o2);

span = new Span<object>(a, 0, a.Length);
span.Validate<object>(o1, o2);
}
Expand All @@ -73,9 +64,6 @@ public static void CtorArrayZeroLength()
span = new Span<int>(empty);
span.Validate<int>();

span = new Span<int>(empty, 0);
span.Validate<int>();

span = new Span<int>(empty, 0, empty.Length);
span.Validate<int>();
}
Expand All @@ -84,7 +72,6 @@ public static void CtorArrayZeroLength()
public static void CtorArrayNullArray()
{
Assert.Throws<ArgumentNullException>(() => new Span<int>((int[])null).DontBox());
Assert.Throws<ArgumentNullException>(() => new Span<int>((int[])null, 0).DontBox());
Assert.Throws<ArgumentNullException>(() => new Span<int>((int[])null, 0, 0).DontBox());
}

Expand All @@ -94,7 +81,6 @@ public static void CtorArrayWrongArrayType()
// Cannot pass variant array, if array type is not a valuetype.
string[] a = { "Hello" };
Assert.Throws<ArrayTypeMismatchException>(() => new Span<object>(a).DontBox());
Assert.Throws<ArrayTypeMismatchException>(() => new Span<object>(a, 0).DontBox());
Assert.Throws<ArrayTypeMismatchException>(() => new Span<object>(a, 0, a.Length).DontBox());
}

Expand All @@ -110,9 +96,6 @@ public static void CtorArrayWrongValueType()
span = new Span<int>(aAsIntArray);
span.Validate<int>(42, -1);

span = new Span<int>(aAsIntArray, 0);
span.Validate<int>(42, -1);

span = new Span<int>(aAsIntArray, 0, aAsIntArray.Length);
span.Validate<int>(42, -1);
}
Expand Down
54 changes: 0 additions & 54 deletions src/System.Memory/tests/Span/CtorArrayInt.cs

This file was deleted.

2 changes: 0 additions & 2 deletions src/System.Memory/tests/System.Memory.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
<Compile Include="Span\Clear.cs" />
<Compile Include="Span\CopyTo.cs" />
<Compile Include="Span\CtorArray.cs" />
<Compile Include="Span\CtorArrayInt.cs" />
<Compile Include="Span\CtorArrayIntInt.cs" />
<Compile Include="Span\CtorPointerInt.cs" />
<Compile Include="Span\DangerousCreate.cs" />
Expand Down Expand Up @@ -52,7 +51,6 @@
<Compile Include="ReadOnlySpan\AsSpan.cs" />
<Compile Include="ReadOnlySpan\CopyTo.cs" />
<Compile Include="ReadOnlySpan\CtorArray.cs" />
<Compile Include="ReadOnlySpan\CtorArrayInt.cs" />
<Compile Include="ReadOnlySpan\CtorArrayIntInt.cs" />
<Compile Include="ReadOnlySpan\CtorPointerInt.cs" />
<Compile Include="ReadOnlySpan\DangerousCreate.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ namespace System.Xml {
if ( !stream.CanSeek || stream.Position == 0 ) {
ReadOnlySpan<byte> bom = encoding.Preamble;
if ( bom.Length != 0 ) {
bom.CopyTo(new Span<byte>(bufBytes, 1));
bom.CopyTo(new Span<byte>(bufBytes).Slice(1));
bufPos += bom.Length;
textPos += bom.Length;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public XmlUtf8RawTextWriter(Stream stream, XmlWriterSettings settings) : this(se
ReadOnlySpan<byte> bom = encoding.Preamble;
if (bom.Length != 0)
{
bom.CopyTo(new Span<byte>(bufBytes, 1));
bom.CopyTo(new Span<byte>(bufBytes).Slice(1));
bufPos += bom.Length;
textPos += bom.Length;
}
Expand Down