CoreFx 14486 Remove argument validation in DangerousCreate (#10462)
authorMandar Sahasrabuddhe <WinCPP@users.noreply.github.com>
Sat, 25 Mar 2017 01:21:56 +0000 (06:51 +0530)
committerAhson Ahmed Khan <ahsonkhan@users.noreply.github.com>
Sat, 25 Mar 2017 01:21:56 +0000 (18:21 -0700)
src/mscorlib/src/System/ReadOnlySpan.cs
src/mscorlib/src/System/Span.cs

index ccbca3c..72754d7 100644 (file)
@@ -120,22 +120,8 @@ namespace System
         /// <param name="obj">The managed object that contains the data to span over.</param>
         /// <param name="objectData">A reference to data within that object.</param>
         /// <param name="length">The number of <typeparamref name="T"/> elements the memory contains.</param>
-        /// <exception cref="System.ArgumentNullException">
-        /// Thrown when the specified object is null.
-        /// </exception>
-        /// <exception cref="System.ArgumentOutOfRangeException">
-        /// Thrown when the specified <paramref name="length"/> is negative.
-        /// </exception>
         [MethodImpl(MethodImplOptions.AggressiveInlining)]
-        public static ReadOnlySpan<T> DangerousCreate(object obj, ref T objectData, int length)
-        {
-            if (obj == null)
-                ThrowHelper.ThrowArgumentNullException(ExceptionArgument.obj);
-            if (length < 0)
-                ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.length);
-
-            return new ReadOnlySpan<T>(ref objectData, length);
-        }
+        public static ReadOnlySpan<T> DangerousCreate(object obj, ref T objectData, int length) => new ReadOnlySpan<T>(ref objectData, length);
 
         // Constructor for internal use only.
         [MethodImpl(MethodImplOptions.AggressiveInlining)]
index e730582..e6620f8 100644 (file)
@@ -137,22 +137,8 @@ namespace System
         /// <param name="obj">The managed object that contains the data to span over.</param>
         /// <param name="objectData">A reference to data within that object.</param>
         /// <param name="length">The number of <typeparamref name="T"/> elements the memory contains.</param>
-        /// <exception cref="System.ArgumentNullException">
-        /// Thrown when the specified object is null.
-        /// </exception>
-        /// <exception cref="System.ArgumentOutOfRangeException">
-        /// Thrown when the specified <paramref name="length"/> is negative.
-        /// </exception>
         [MethodImpl(MethodImplOptions.AggressiveInlining)]
-        public static Span<T> DangerousCreate(object obj, ref T objectData, int length)
-        {
-            if (obj == null)
-                ThrowHelper.ThrowArgumentNullException(ExceptionArgument.obj);
-            if (length < 0)
-                ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.length);
-
-            return new Span<T>(ref objectData, length);
-        }
+        public static Span<T> DangerousCreate(object obj, ref T objectData, int length) => new Span<T>(ref objectData, length);
 
         // Constructor for internal use only.
         [MethodImpl(MethodImplOptions.AggressiveInlining)]