We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4600382 commit 5f70ec2Copy full SHA for 5f70ec2
src/CommunityToolkit.HighPerformance/Extensions/StreamExtensions.cs
@@ -205,8 +205,14 @@ public static void Write(this Stream stream, ReadOnlySpan<byte> buffer)
205
public static unsafe T Read<T>(this Stream stream)
206
where T : unmanaged
207
{
208
-#if NETSTANDARD2_1_OR_GREATER
209
- T result = default;
+#if NET7_0_OR_GREATER
+ T result;
210
+
211
+ stream.ReadExactly(new Span<byte>(&result, sizeof(T)));
212
213
+ return result;
214
+#elif NETSTANDARD2_1_OR_GREATER
215
216
int bytesOffset = 0;
217
218
// As per Stream.Read's documentation:
0 commit comments