Use helpers in Guid's ROS<byte> constructor (#78446)
authorBenjamin Moir <DaZombieKiller@users.noreply.github.com>
Mon, 21 Nov 2022 03:20:13 +0000 (14:20 +1100)
committerGitHub <noreply@github.com>
Mon, 21 Nov 2022 03:20:13 +0000 (22:20 -0500)
* Use helpers in Guid's ROS<byte> constructor

* Condense Guid ROS<byte> constructor with a ternary

* Remove ReadGuidLittleEndian helper

* Add [StackTraceHidden] to Guid.ThrowArgumentException

* Revert accidental whitespace change

src/libraries/System.Private.CoreLib/src/System/Guid.cs

index 63f4466..1ce66bb 100644 (file)
@@ -50,7 +50,7 @@ namespace System
         {
             if (b.Length != 16)
             {
-                throw new ArgumentException(SR.Format(SR.Arg_GuidArrayCtor, "16"), nameof(b));
+                ThrowArgumentException();
             }
 
             if (BitConverter.IsLittleEndian)
@@ -71,6 +71,12 @@ namespace System
             _h = b[12];
             _i = b[13];
             _j = b[14];
+
+            [StackTraceHidden]
+            static void ThrowArgumentException()
+            {
+                throw new ArgumentException(SR.Format(SR.Arg_GuidArrayCtor, "16"), nameof(b));
+            }
         }
 
         [CLSCompliant(false)]