Fix SizeOf issue in old .NET

This commit is contained in:
Matt Nadareski
2024-11-27 20:37:07 -05:00
parent d5cef39f1b
commit cb270d3185

View File

@@ -280,7 +280,11 @@ namespace SabreTools.Serialization.Deserializers
/// <returns>Filled sector full of directory entries on success, null on error</returns>
private static DirectoryEntry[]? ParseDirectoryEntries(Stream data, ushort sectorShift, ushort majorVersion)
{
#if NET20 || NET35 || NET40
int directoryEntrySize = Marshal.SizeOf(new DirectoryEntry());
#else
int directoryEntrySize = Marshal.SizeOf<DirectoryEntry>();
#endif
int sectorCount = (int)(Math.Pow(2, sectorShift) / directoryEntrySize);
var directoryEntries = new DirectoryEntry[sectorCount];