Skip to content

Commit

Permalink
Use helpers in Guid's ROS<byte> constructor (#78446)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
DaZombieKiller authored Nov 21, 2022
1 parent ee7257a commit 9129083
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/libraries/System.Private.CoreLib/src/System/Guid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public Guid(ReadOnlySpan<byte> b)
{
if (b.Length != 16)
{
throw new ArgumentException(SR.Format(SR.Arg_GuidArrayCtor, "16"), nameof(b));
ThrowArgumentException();
}

if (BitConverter.IsLittleEndian)
Expand All @@ -71,6 +71,12 @@ public Guid(ReadOnlySpan<byte> b)
_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)]
Expand Down

0 comments on commit 9129083

Please sign in to comment.