From: Mandar Sahasrabuddhe Date: Sat, 25 Mar 2017 01:21:56 +0000 (+0530) Subject: CoreFx 14486 Remove argument validation in DangerousCreate (dotnet/coreclr#10462) X-Git-Tag: submit/tizen/20210909.063632~11030^2~7560 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4d90827c86abc55144f4bbd5a4e899d7c282a81b;p=platform%2Fupstream%2Fdotnet%2Fruntime.git CoreFx 14486 Remove argument validation in DangerousCreate (dotnet/coreclr#10462) Commit migrated from https://github.com/dotnet/coreclr/commit/7e5aef990eb4c8d7b34fc5f8a9a1fd5ed326410d --- diff --git a/src/coreclr/src/mscorlib/src/System/ReadOnlySpan.cs b/src/coreclr/src/mscorlib/src/System/ReadOnlySpan.cs index ccbca3c..72754d7 100644 --- a/src/coreclr/src/mscorlib/src/System/ReadOnlySpan.cs +++ b/src/coreclr/src/mscorlib/src/System/ReadOnlySpan.cs @@ -120,22 +120,8 @@ namespace System /// The managed object that contains the data to span over. /// A reference to data within that object. /// The number of elements the memory contains. - /// - /// Thrown when the specified object is null. - /// - /// - /// Thrown when the specified is negative. - /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static ReadOnlySpan 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(ref objectData, length); - } + public static ReadOnlySpan DangerousCreate(object obj, ref T objectData, int length) => new ReadOnlySpan(ref objectData, length); // Constructor for internal use only. [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/coreclr/src/mscorlib/src/System/Span.cs b/src/coreclr/src/mscorlib/src/System/Span.cs index e730582..e6620f8 100644 --- a/src/coreclr/src/mscorlib/src/System/Span.cs +++ b/src/coreclr/src/mscorlib/src/System/Span.cs @@ -137,22 +137,8 @@ namespace System /// The managed object that contains the data to span over. /// A reference to data within that object. /// The number of elements the memory contains. - /// - /// Thrown when the specified object is null. - /// - /// - /// Thrown when the specified is negative. - /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Span 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(ref objectData, length); - } + public static Span DangerousCreate(object obj, ref T objectData, int length) => new Span(ref objectData, length); // Constructor for internal use only. [MethodImpl(MethodImplOptions.AggressiveInlining)]