BinaryReaderExtensions.cs
1 using System.IO; 2 using System.Runtime.CompilerServices; 3 using System.Runtime.InteropServices; 4 5 namespace Ryujinx.Common 6 { 7 public static class BinaryReaderExtensions 8 { 9 public static T ReadStruct<T>(this BinaryReader reader) where T : unmanaged 10 { 11 return MemoryMarshal.Cast<byte, T>(reader.ReadBytes(Unsafe.SizeOf<T>()))[0]; 12 } 13 } 14 }