diff options
author | Jan Kotas <jkotas@microsoft.com> | 2018-03-27 10:31:55 +0300 |
---|---|---|
committer | Jan Kotas <jkotas@microsoft.com> | 2018-03-27 19:50:33 +0300 |
commit | 2e52581633f994ca6f548b629a363dd94a9aa96e (patch) | |
tree | 85f15b7b36b405f737248cad9860bf7384076aa7 /src | |
parent | 4fc352f3863dc36af329c4e6af7da7bcb4a0adb2 (diff) |
Delete MemoryExtensions.AsBytes (dotnet/coreclr#17245)
Moved to MemoryMarshal
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/System.Private.CoreLib/shared/System/MemoryExtensions.Fast.cs | 46 |
1 files changed, 0 insertions, 46 deletions
diff --git a/src/System.Private.CoreLib/shared/System/MemoryExtensions.Fast.cs b/src/System.Private.CoreLib/shared/System/MemoryExtensions.Fast.cs index a814d4fb2..d9e3af880 100644 --- a/src/System.Private.CoreLib/shared/System/MemoryExtensions.Fast.cs +++ b/src/System.Private.CoreLib/shared/System/MemoryExtensions.Fast.cs @@ -357,52 +357,6 @@ namespace System } /// <summary> - /// Casts a Span of one primitive type <typeparamref name="T"/> to Span of bytes. - /// That type may not contain pointers or references. This is checked at runtime in order to preserve type safety. - /// </summary> - /// <param name="span">The source slice, of type <typeparamref name="T"/>.</param> - /// <exception cref="System.ArgumentException"> - /// Thrown when <typeparamref name="T"/> contains pointers. - /// </exception> - /// <exception cref="System.OverflowException"> - /// Thrown if the Length property of the new Span would exceed Int32.MaxValue. - /// </exception> - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Span<byte> AsBytes<T>(this Span<T> span) - where T : struct - { - if (RuntimeHelpers.IsReferenceOrContainsReferences<T>()) - ThrowHelper.ThrowInvalidTypeWithPointersNotSupported(typeof(T)); - - return new Span<byte>( - ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), - checked(span.Length * Unsafe.SizeOf<T>())); - } - - /// <summary> - /// Casts a ReadOnlySpan of one primitive type <typeparamref name="T"/> to ReadOnlySpan of bytes. - /// That type may not contain pointers or references. This is checked at runtime in order to preserve type safety. - /// </summary> - /// <param name="span">The source slice, of type <typeparamref name="T"/>.</param> - /// <exception cref="System.ArgumentException"> - /// Thrown when <typeparamref name="T"/> contains pointers. - /// </exception> - /// <exception cref="System.OverflowException"> - /// Thrown if the Length property of the new Span would exceed Int32.MaxValue. - /// </exception> - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static ReadOnlySpan<byte> AsBytes<T>(this ReadOnlySpan<T> span) - where T : struct - { - if (RuntimeHelpers.IsReferenceOrContainsReferences<T>()) - ThrowHelper.ThrowInvalidTypeWithPointersNotSupported(typeof(T)); - - return new ReadOnlySpan<byte>( - ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), - checked(span.Length * Unsafe.SizeOf<T>())); - } - - /// <summary> /// Creates a new span over the portion of the target array. /// </summary> public static Span<T> AsSpan<T>(this T[] array, int start) |