Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit e0b8c96

Browse files
authored
Move Span/ReadOnlySpan to shared CoreLib partition (#10988)
Fix a few method names to better names used in CoreRT Contributes to dotnet/corert#2966
1 parent 6cb9a6f commit e0b8c96

File tree

9 files changed

+417
-420
lines changed

9 files changed

+417
-420
lines changed

src/mscorlib/System.Private.CoreLib.csproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,8 +381,6 @@
381381
<Compile Condition="'$(FeatureCominterop)' == 'true'" Include="$(BclSourcesRoot)\System\Variant.cs" />
382382
<Compile Condition="'$(FeatureClassicCominterop)' == 'true'" Include="$(BclSourcesRoot)\System\OleAutBinder.cs" />
383383
<Compile Include="$(BclSourcesRoot)\System\ByReference.cs" />
384-
<Compile Include="$(BclSourcesRoot)\System\Span.cs" />
385-
<Compile Include="$(BclSourcesRoot)\System\ReadOnlySpan.cs" />
386384
</ItemGroup>
387385
<ItemGroup>
388386
<Compile Include="$(BclSourcesRoot)\Internal\Runtime\Augments\EnvironmentAugments.cs" />

src/mscorlib/shared/System.Private.CoreLib.Shared.projitems

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@
169169
<Compile Include="$(MSBuildThisFileDirectory)System\Progress.cs"/>
170170
<Compile Include="$(MSBuildThisFileDirectory)System\Random.cs"/>
171171
<Compile Include="$(MSBuildThisFileDirectory)System\RankException.cs"/>
172+
<Compile Include="$(MSBuildThisFileDirectory)System\ReadOnlySpan.cs"/>
172173
<Compile Include="$(MSBuildThisFileDirectory)System\Reflection\AmbiguousMatchException.cs" />
173174
<Compile Include="$(MSBuildThisFileDirectory)System\Reflection\Assembly.cs" />
174175
<Compile Include="$(MSBuildThisFileDirectory)System\Reflection\AssemblyAlgorithmIdAttribute.cs" />
@@ -338,6 +339,8 @@
338339
<Compile Include="$(MSBuildThisFileDirectory)System\Security\SuppressUnmanagedCodeSecurityAttribute.cs"/>
339340
<Compile Include="$(MSBuildThisFileDirectory)System\Security\UnverifiableCodeAttribute.cs"/>
340341
<Compile Include="$(MSBuildThisFileDirectory)System\Security\VerificationException.cs"/>
342+
<Compile Include="$(MSBuildThisFileDirectory)System\Span.cs"/>
343+
<Compile Include="$(MSBuildThisFileDirectory)System\Span.NonGeneric.cs"/>
341344
<Compile Include="$(MSBuildThisFileDirectory)System\StackOverflowException.cs"/>
342345
<Compile Include="$(MSBuildThisFileDirectory)System\StringComparer.cs"/>
343346
<Compile Include="$(MSBuildThisFileDirectory)System\StringComparison.cs"/>

src/mscorlib/src/System/ReadOnlySpan.cs renamed to src/mscorlib/shared/System/ReadOnlySpan.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public ReadOnlySpan(T[] array)
3434
if (array == null)
3535
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
3636

37-
_pointer = new ByReference<T>(ref JitHelpers.GetArrayData(array));
37+
_pointer = new ByReference<T>(ref Unsafe.As<byte, T>(ref array.GetRawSzArrayData()));
3838
_length = array.Length;
3939
}
4040

@@ -57,7 +57,7 @@ public ReadOnlySpan(T[] array, int start)
5757
if ((uint)start > (uint)array.Length)
5858
ThrowHelper.ThrowArgumentOutOfRangeException();
5959

60-
_pointer = new ByReference<T>(ref Unsafe.Add(ref JitHelpers.GetArrayData(array), start));
60+
_pointer = new ByReference<T>(ref Unsafe.Add(ref Unsafe.As<byte, T>(ref array.GetRawSzArrayData()), start));
6161
_length = array.Length - start;
6262
}
6363

@@ -81,7 +81,7 @@ public ReadOnlySpan(T[] array, int start, int length)
8181
if ((uint)start > (uint)array.Length || (uint)length > (uint)(array.Length - start))
8282
ThrowHelper.ThrowArgumentOutOfRangeException();
8383

84-
_pointer = new ByReference<T>(ref Unsafe.Add(ref JitHelpers.GetArrayData(array), start));
84+
_pointer = new ByReference<T>(ref Unsafe.Add(ref Unsafe.As<byte, T>(ref array.GetRawSzArrayData()), start));
8585
_length = length;
8686
}
8787

@@ -202,7 +202,7 @@ public bool TryCopyTo(Span<T> destination)
202202
if ((uint)_length > (uint)destination.Length)
203203
return false;
204204

205-
SpanHelper.CopyTo<T>(ref destination.DangerousGetPinnableReference(), ref _pointer.Value, _length);
205+
Span.CopyTo<T>(ref destination.DangerousGetPinnableReference(), ref _pointer.Value, _length);
206206
return true;
207207
}
208208

@@ -301,7 +301,7 @@ public T[] ToArray()
301301
return Array.Empty<T>();
302302

303303
var destination = new T[_length];
304-
SpanHelper.CopyTo<T>(ref JitHelpers.GetArrayData(destination), ref _pointer.Value, _length);
304+
Span.CopyTo<T>(ref Unsafe.As<byte, T>(ref destination.GetRawSzArrayData()), ref _pointer.Value, _length);
305305
return destination;
306306
}
307307

0 commit comments

Comments
 (0)