Skip to content

Commit bc2ac2f

Browse files
authored
Do not ignore MemoryMarshal.TryWrite result (#108661)
1 parent f1c94c4 commit bc2ac2f

File tree

1 file changed

+8
-8
lines changed
  • src/libraries/System.Private.CoreLib/src/System

1 file changed

+8
-8
lines changed

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -900,13 +900,13 @@ public byte[] ToByteArray()
900900
var g = new byte[16];
901901
if (BitConverter.IsLittleEndian)
902902
{
903-
MemoryMarshal.TryWrite(g, in this);
903+
MemoryMarshal.Write(g, in this);
904904
}
905905
else
906906
{
907907
// slower path for BigEndian
908908
Guid guid = new Guid(MemoryMarshal.AsBytes(new ReadOnlySpan<Guid>(in this)), false);
909-
MemoryMarshal.TryWrite(g, in guid);
909+
MemoryMarshal.Write(g, in guid);
910910
}
911911
return g;
912912
}
@@ -918,13 +918,13 @@ public byte[] ToByteArray(bool bigEndian)
918918
var g = new byte[16];
919919
if (BitConverter.IsLittleEndian != bigEndian)
920920
{
921-
MemoryMarshal.TryWrite(g, in this);
921+
MemoryMarshal.Write(g, in this);
922922
}
923923
else
924924
{
925925
// slower path for Reverse
926926
Guid guid = new Guid(MemoryMarshal.AsBytes(new ReadOnlySpan<Guid>(in this)), bigEndian);
927-
MemoryMarshal.TryWrite(g, in guid);
927+
MemoryMarshal.Write(g, in guid);
928928
}
929929
return g;
930930
}
@@ -937,13 +937,13 @@ public bool TryWriteBytes(Span<byte> destination)
937937

938938
if (BitConverter.IsLittleEndian)
939939
{
940-
MemoryMarshal.TryWrite(destination, in this);
940+
MemoryMarshal.Write(destination, in this);
941941
}
942942
else
943943
{
944944
// slower path for BigEndian
945945
Guid guid = new Guid(MemoryMarshal.AsBytes(new ReadOnlySpan<Guid>(in this)), false);
946-
MemoryMarshal.TryWrite(destination, in guid);
946+
MemoryMarshal.Write(destination, in guid);
947947
}
948948
return true;
949949
}
@@ -959,13 +959,13 @@ public bool TryWriteBytes(Span<byte> destination, bool bigEndian, out int bytesW
959959

960960
if (BitConverter.IsLittleEndian != bigEndian)
961961
{
962-
MemoryMarshal.TryWrite(destination, in this);
962+
MemoryMarshal.Write(destination, in this);
963963
}
964964
else
965965
{
966966
// slower path for Reverse
967967
Guid guid = new Guid(MemoryMarshal.AsBytes(new ReadOnlySpan<Guid>(in this)), bigEndian);
968-
MemoryMarshal.TryWrite(destination, in guid);
968+
MemoryMarshal.Write(destination, in guid);
969969
}
970970
bytesWritten = 16;
971971
return true;

0 commit comments

Comments
 (0)