From d8cd5854cebe1ddc3268ffe744258841473d1c6d Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Tue, 7 Nov 2023 23:30:26 -0500 Subject: [PATCH] Enable latest language version --- Bytes/AACS.Deserializer.cs | 4 - Bytes/BDPlus.Deserializer.cs | 4 - Bytes/BFPK.Deserializer.cs | 4 - Bytes/BSP.Deserializer.cs | 4 - Bytes/CFB.Deserializer.cs | 4 - Bytes/CIA.Deserializer.cs | 4 - Bytes/GCF.Deserializer.cs | 4 - Bytes/IRD.Deserializer.cs | 4 - Bytes/InstallShieldCabinet.Deserializer.cs | 4 - Bytes/LinearExecutable.Deserializer.cs | 4 - Bytes/MSDOS.Deserializer.cs | 4 - Bytes/MicrosoftCabinet.Deserializer.cs | 4 - Bytes/MoPaQ.Deserializer.cs | 4 - Bytes/N3DS.Deserializer.cs | 4 - Bytes/NCF.Deserializer.cs | 4 - Bytes/NewExecutable.Deserializer.cs | 4 - Bytes/Nitro.Deserializer.cs | 4 - Bytes/PAK.Deserializer.cs | 4 - Bytes/PFF.Deserializer.cs | 4 - Bytes/PlayJAudio.Deserializer.cs | 4 - Bytes/PlayJPlaylist.Deserializer.cs | 4 - Bytes/PortableExecutable.Deserializer.cs | 4 - Bytes/Quantum.Deserializer.cs | 4 - Bytes/SGA.Deserializer.cs | 4 - Bytes/VBSP.Deserializer.cs | 4 - Bytes/VPK.Deserializer.cs | 4 - Bytes/WAD.Deserializer.cs | 4 - Bytes/XCP.Deserializer.cs | 4 - CrossModel/ArchiveDotOrg.Deserializer.cs | 4 - CrossModel/ArchiveDotOrg.Serializer.cs | 12 - CrossModel/AttractMode.Deserializer.cs | 4 - CrossModel/AttractMode.Serializer.cs | 8 - CrossModel/ClrMamePro.Deserializer.cs | 16 - CrossModel/ClrMamePro.Serializer.cs | 8 - CrossModel/DosCenter.Deserializer.cs | 4 - CrossModel/DosCenter.Serializer.cs | 4 - CrossModel/EverdriveSMDB.Deserializer.cs | 4 - CrossModel/EverdriveSMDB.Serializer.cs | 4 - CrossModel/Hashfile.Deserializer.cs | 12 - CrossModel/Hashfile.Serializer.cs | 4 - CrossModel/Listrom.Deserializer.cs | 4 - CrossModel/Listrom.Serializer.cs | 4 - CrossModel/Listxml.Deserializer.cs | 8 - CrossModel/Listxml.Serializer.cs | 4 - CrossModel/Logiqx.Deserializer.cs | 16 - CrossModel/Logiqx.Serializer.cs | 4 - CrossModel/M1.Deserializer.cs | 4 - CrossModel/M1.Serializer.cs | 4 - CrossModel/OfflineList.Deserializer.cs | 4 - CrossModel/OfflineList.Serializer.cs | 4 - CrossModel/OpenMSX.Deserializer.cs | 4 - CrossModel/OpenMSX.Serializer.cs | 4 - CrossModel/RomCenter.Deserializer.cs | 4 - CrossModel/RomCenter.Serializer.cs | 4 - CrossModel/SeparatedValue.Deserializer.cs | 4 - CrossModel/SeparatedValue.Serializer.cs | 52 --- CrossModel/SoftwareList.Deserializer.cs | 4 - CrossModel/SoftwareList.Serializer.cs | 4 - Extensions.PortableExecutable.cs | 96 ----- Files/AttractMode.Deserializer.cs | 4 - Files/AttractMode.Serializer.cs | 4 - Files/ClrMamePro.Deserializer.cs | 8 - Files/ClrMamePro.Serializer.cs | 8 - Files/CueSheet.Deserializer.cs | 46 +-- Files/CueSheet.Serializer.cs | 4 - Files/DosCenter.Deserializer.cs | 4 - Files/DosCenter.Serializer.cs | 4 - Files/EverdriveSMDB.Deserializer.cs | 4 - Files/EverdriveSMDB.Serializer.cs | 4 - Files/Hashfile.Deserializer.cs | 8 - Files/Hashfile.Serializer.cs | 8 - Files/IRD.Deserializer.cs | 4 - Files/IRD.Serializer.cs | 4 - Files/Listrom.Deserializer.cs | 4 - Files/Listrom.Serializer.cs | 4 - Files/PIC.Deserializer.cs | 4 - Files/PIC.Serializer.cs | 4 - Files/RomCenter.Deserializer.cs | 4 - Files/RomCenter.Serializer.cs | 4 - Files/SeparatedValue.Deserializer.cs | 8 - Files/SeparatedValue.Serializer.cs | 8 - Files/XmlFile.Deserializer.cs | 4 - Files/XmlFile.Serializer.cs | 8 - Interfaces/IByteSerializer.cs | 4 - Interfaces/IFileSerializer.cs | 8 - Interfaces/IModelSerializer.cs | 8 - Interfaces/IStreamSerializer.cs | 8 - Interfaces/IStringSerializer.cs | 8 - Interfaces/IWrapper.cs | 2 +- Internal.cs | 8 - Logiqx.cs | 4 - OpenMSX.cs | 8 - PathProcessor.cs | 4 - SabreTools.Serialization.csproj | 9 +- SoftwareList.cs | 8 - Streams/AACS.Deserializer.cs | 56 --- Streams/AACS.Serializer.cs | 4 - Streams/AttractMode.Deserializer.cs | 4 - Streams/AttractMode.Serializer.cs | 12 - Streams/BDPlus.Deserializer.cs | 12 - Streams/BDPlus.Serializer.cs | 4 - Streams/BFPK.Deserializer.cs | 16 - Streams/BFPK.Serializer.cs | 4 - Streams/BSP.Deserializer.cs | 16 - Streams/BSP.Serializer.cs | 4 - Streams/CFB.Deserializer.cs | 40 -- Streams/CFB.Serializer.cs | 4 - Streams/CIA.Deserializer.cs | 40 -- Streams/CIA.Serializer.cs | 4 - Streams/ClrMamePro.Deserializer.cs | 95 ----- Streams/ClrMamePro.Serializer.cs | 79 ---- Streams/CueSheet.Deserializer.cs | 4 - Streams/CueSheet.Serializer.cs | 16 - Streams/DosCenter.Deserializer.cs | 24 -- Streams/DosCenter.Serializer.cs | 16 - Streams/EverdriveSMDB.Deserializer.cs | 4 - Streams/EverdriveSMDB.Serializer.cs | 12 - Streams/GCF.Deserializer.cs | 36 -- Streams/GCF.Serializer.cs | 4 - Streams/HashFile.Deserializer.cs | 29 +- Streams/Hashfile.Serializer.cs | 36 -- Streams/IRD.Deserializer.cs | 4 - Streams/IRD.Serializer.cs | 4 - Streams/InstallShieldCabinet.Deserializer.cs | 48 --- Streams/InstallShieldCabinet.Serializer.cs | 4 - Streams/LinearExecutable.Deserializer.cs | 44 --- Streams/LinearExecutable.Serializer.cs | 4 - Streams/Listrom.Deserializer.cs | 34 +- Streams/Listrom.Serializer.cs | 12 - Streams/Logiqx.Serializer.cs | 4 - Streams/MSDOS.Deserializer.cs | 12 - Streams/MSDOS.Serializer.cs | 4 - Streams/MicrosoftCabinet.Deserializer.cs | 12 - Streams/MicrosoftCabinet.Serializer.cs | 4 - Streams/MoPaQ.Deserializer.cs | 40 -- Streams/MoPaQ.Serializer.cs | 4 - Streams/N3DS.Deserializer.cs | 84 ----- Streams/N3DS.Serializer.cs | 4 - Streams/NCF.Deserialization.cs | 36 -- Streams/NCF.Serialization.cs | 4 - Streams/NewExecutable.Deserializer.cs | 35 -- Streams/NewExecutable.Serializer.cs | 4 - Streams/Nitro.Deserializer.cs | 20 - Streams/Nitro.Serializer.cs | 4 - Streams/OpenMSX.Serializer.cs | 4 - Streams/PAK.Deserializer.cs | 16 - Streams/PAK.Serializer.cs | 4 - Streams/PFF.Deserializer.cs | 20 - Streams/PFF.Serializer.cs | 4 - Streams/PIC.Deserializer.cs | 24 -- Streams/PIC.Serializer.cs | 4 - Streams/PlayJAudio.Deserializer.cs | 44 --- Streams/PlayJAudio.Serializer.cs | 4 - Streams/PlayJPlaylist.Deserializer.cs | 4 - Streams/PlayJPlaylist.Serializer.cs | 4 - Streams/PortableExecutable.Deserializer.cs | 72 ---- Streams/PortableExecutable.Serializer.cs | 4 - Streams/Quantum.Deserializer.cs | 20 - Streams/Quantum.Serializer.cs | 4 - Streams/RomCenter.Deserializer.cs | 39 -- Streams/RomCenter.Serializer.cs | 20 - Streams/SGA.Deserializer.cs | 167 --------- Streams/SGA.Serializer.cs | 4 - Streams/SeparatedValue.Deserializer.cs | 12 - Streams/SeparatedValue.Serializer.cs | 20 - Streams/SoftwareList.Serializer.cs | 4 - Streams/VBSP.Deserializer.cs | 12 - Streams/VBSP.Serializer.cs | 4 - Streams/VPK.Deserializer.cs | 24 -- Streams/VPK.Serializer.cs | 4 - Streams/WAD.Deserializer.cs | 28 -- Streams/WAD.Serializer.cs | 4 - Streams/XCP.Deserializer.cs | 20 - Streams/XCP.Serializer.cs | 4 - Streams/XmlFile.Deserializer.cs | 8 - Streams/XmlFile.Serializer.cs | 8 - Strings/XMID.Deserializer.cs | 14 +- Strings/XMID.Serializer.cs | 4 - Strings/XeMID.Deserializer.cs | 14 +- Strings/XeMID.Serializer.cs | 4 - Wrappers/AACSMediaKeyBlock.cs | 16 - Wrappers/BDPlusSVM.cs | 16 - Wrappers/BFPK.cs | 16 - Wrappers/BSP.cs | 16 - Wrappers/CFB.cs | 84 ----- Wrappers/CIA.cs | 16 - Wrappers/ConcreteInterfaceSerializer.cs | 2 +- Wrappers/GCF.cs | 46 --- Wrappers/IRD.cs | 16 - Wrappers/InstallShieldCabinet.cs | 16 - Wrappers/LinearExecutable.cs | 28 -- Wrappers/MSDOS.cs | 16 - Wrappers/MicrosoftCabinet.cs | 16 - Wrappers/N3DS.cs | 16 - Wrappers/NCF.cs | 16 - Wrappers/NewExecutable.cs | 28 -- Wrappers/Nitro.cs | 16 - Wrappers/PAK.cs | 16 - Wrappers/PFF.cs | 16 - Wrappers/PlayJAudioFile.cs | 16 - Wrappers/PortableExecutable.cs | 369 +------------------ Wrappers/Quantum.cs | 16 - Wrappers/SGA.cs | 16 - Wrappers/VBSP.cs | 16 - Wrappers/VPK.cs | 28 -- Wrappers/WAD.cs | 16 - Wrappers/WrapperBase.cs | 64 +--- Wrappers/XMID.cs | 12 - Wrappers/XZP.cs | 16 - Wrappers/XeMID.cs | 12 - 210 files changed, 40 insertions(+), 3276 deletions(-) diff --git a/Bytes/AACS.Deserializer.cs b/Bytes/AACS.Deserializer.cs index 4e2039ef..8d468f92 100644 --- a/Bytes/AACS.Deserializer.cs +++ b/Bytes/AACS.Deserializer.cs @@ -7,11 +7,7 @@ namespace SabreTools.Serialization.Bytes public partial class AACS : IByteSerializer { /// -#if NET48 - public MediaKeyBlock Deserialize(byte[] data, int offset) -#else public MediaKeyBlock? Deserialize(byte[]? data, int offset) -#endif { // If the data is invalid if (data == null) diff --git a/Bytes/BDPlus.Deserializer.cs b/Bytes/BDPlus.Deserializer.cs index 0dfd5c16..775a98c2 100644 --- a/Bytes/BDPlus.Deserializer.cs +++ b/Bytes/BDPlus.Deserializer.cs @@ -7,11 +7,7 @@ namespace SabreTools.Serialization.Bytes public partial class BDPlus : IByteSerializer { /// -#if NET48 - public SVM Deserialize(byte[] data, int offset) -#else public SVM? Deserialize(byte[]? data, int offset) -#endif { // If the data is invalid if (data == null) diff --git a/Bytes/BFPK.Deserializer.cs b/Bytes/BFPK.Deserializer.cs index ffc632e5..56f23bfe 100644 --- a/Bytes/BFPK.Deserializer.cs +++ b/Bytes/BFPK.Deserializer.cs @@ -7,11 +7,7 @@ namespace SabreTools.Serialization.Bytes public partial class BFPK : IByteSerializer { /// -#if NET48 - public Archive Deserialize(byte[] data, int offset) -#else public Archive? Deserialize(byte[]? data, int offset) -#endif { // If the data is invalid if (data == null) diff --git a/Bytes/BSP.Deserializer.cs b/Bytes/BSP.Deserializer.cs index 4ce65340..e299a89e 100644 --- a/Bytes/BSP.Deserializer.cs +++ b/Bytes/BSP.Deserializer.cs @@ -6,11 +6,7 @@ namespace SabreTools.Serialization.Bytes public partial class BSP : IByteSerializer { /// -#if NET48 - public Models.BSP.File Deserialize(byte[] data, int offset) -#else public Models.BSP.File? Deserialize(byte[]? data, int offset) -#endif { // If the data is invalid if (data == null) diff --git a/Bytes/CFB.Deserializer.cs b/Bytes/CFB.Deserializer.cs index 7025f96e..774efbd5 100644 --- a/Bytes/CFB.Deserializer.cs +++ b/Bytes/CFB.Deserializer.cs @@ -7,11 +7,7 @@ namespace SabreTools.Serialization.Bytes public partial class CFB : IByteSerializer { /// -#if NET48 - public Binary Deserialize(byte[] data, int offset) -#else public Binary? Deserialize(byte[]? data, int offset) -#endif { // If the data is invalid if (data == null) diff --git a/Bytes/CIA.Deserializer.cs b/Bytes/CIA.Deserializer.cs index d28c3009..84a12dfa 100644 --- a/Bytes/CIA.Deserializer.cs +++ b/Bytes/CIA.Deserializer.cs @@ -6,11 +6,7 @@ namespace SabreTools.Serialization.Bytes public partial class CIA : IByteSerializer { /// -#if NET48 - public Models.N3DS.CIA Deserialize(byte[] data, int offset) -#else public Models.N3DS.CIA? Deserialize(byte[]? data, int offset) -#endif { // If the data is invalid if (data == null) diff --git a/Bytes/GCF.Deserializer.cs b/Bytes/GCF.Deserializer.cs index 0f79299d..f5f798b8 100644 --- a/Bytes/GCF.Deserializer.cs +++ b/Bytes/GCF.Deserializer.cs @@ -6,11 +6,7 @@ namespace SabreTools.Serialization.Bytes public partial class GCF : IByteSerializer { /// -#if NET48 - public Models.GCF.File Deserialize(byte[] data, int offset) -#else public Models.GCF.File? Deserialize(byte[]? data, int offset) -#endif { // If the data is invalid if (data == null) diff --git a/Bytes/IRD.Deserializer.cs b/Bytes/IRD.Deserializer.cs index 8ea4bfd6..1d0299e1 100644 --- a/Bytes/IRD.Deserializer.cs +++ b/Bytes/IRD.Deserializer.cs @@ -6,11 +6,7 @@ namespace SabreTools.Serialization.Bytes public partial class IRD : IByteSerializer { /// -#if NET48 - public Models.IRD.IRD Deserialize(byte[] data, int offset) -#else public Models.IRD.IRD? Deserialize(byte[]? data, int offset) -#endif { // If the data is invalid if (data == null) diff --git a/Bytes/InstallShieldCabinet.Deserializer.cs b/Bytes/InstallShieldCabinet.Deserializer.cs index 804ef876..a2c47af5 100644 --- a/Bytes/InstallShieldCabinet.Deserializer.cs +++ b/Bytes/InstallShieldCabinet.Deserializer.cs @@ -8,11 +8,7 @@ namespace SabreTools.Serialization.Bytes public partial class InstallShieldCabinet : IByteSerializer { /// -#if NET48 - public Cabinet Deserialize(byte[] data, int offset) -#else public Cabinet? Deserialize(byte[]? data, int offset) -#endif { // If the data is invalid if (data == null) diff --git a/Bytes/LinearExecutable.Deserializer.cs b/Bytes/LinearExecutable.Deserializer.cs index 17980d97..ba2630c9 100644 --- a/Bytes/LinearExecutable.Deserializer.cs +++ b/Bytes/LinearExecutable.Deserializer.cs @@ -7,11 +7,7 @@ namespace SabreTools.Serialization.Bytes public partial class LinearExecutable : IByteSerializer { /// -#if NET48 - public Executable Deserialize(byte[] data, int offset) -#else public Executable? Deserialize(byte[]? data, int offset) -#endif { // If the data is invalid if (data == null) diff --git a/Bytes/MSDOS.Deserializer.cs b/Bytes/MSDOS.Deserializer.cs index fc969112..dbd29d2e 100644 --- a/Bytes/MSDOS.Deserializer.cs +++ b/Bytes/MSDOS.Deserializer.cs @@ -7,11 +7,7 @@ namespace SabreTools.Serialization.Bytes public partial class MSDOS : IByteSerializer { /// -#if NET48 - public Executable Deserialize(byte[] data, int offset) -#else public Executable? Deserialize(byte[]? data, int offset) -#endif { // If the data is invalid if (data == null) diff --git a/Bytes/MicrosoftCabinet.Deserializer.cs b/Bytes/MicrosoftCabinet.Deserializer.cs index 16840ff8..96292598 100644 --- a/Bytes/MicrosoftCabinet.Deserializer.cs +++ b/Bytes/MicrosoftCabinet.Deserializer.cs @@ -8,11 +8,7 @@ namespace SabreTools.Serialization.Bytes public partial class MicrosoftCabinet : IByteSerializer { /// -#if NET48 - public Cabinet Deserialize(byte[] data, int offset) -#else public Cabinet? Deserialize(byte[]? data, int offset) -#endif { // If the data is invalid if (data == null) diff --git a/Bytes/MoPaQ.Deserializer.cs b/Bytes/MoPaQ.Deserializer.cs index 5e1ec93d..218211d4 100644 --- a/Bytes/MoPaQ.Deserializer.cs +++ b/Bytes/MoPaQ.Deserializer.cs @@ -7,11 +7,7 @@ namespace SabreTools.Serialization.Bytes public partial class MoPaQ : IByteSerializer { /// -#if NET48 - public Archive Deserialize(byte[] data, int offset) -#else public Archive? Deserialize(byte[]? data, int offset) -#endif { // If the data is invalid if (data == null) diff --git a/Bytes/N3DS.Deserializer.cs b/Bytes/N3DS.Deserializer.cs index 40ff54a8..d4b18b38 100644 --- a/Bytes/N3DS.Deserializer.cs +++ b/Bytes/N3DS.Deserializer.cs @@ -7,11 +7,7 @@ namespace SabreTools.Serialization.Bytes public partial class N3DS : IByteSerializer { /// -#if NET48 - public Cart Deserialize(byte[] data, int offset) -#else public Cart? Deserialize(byte[]? data, int offset) -#endif { // If the data is invalid if (data == null) diff --git a/Bytes/NCF.Deserializer.cs b/Bytes/NCF.Deserializer.cs index 5d0126d2..a04a2f0c 100644 --- a/Bytes/NCF.Deserializer.cs +++ b/Bytes/NCF.Deserializer.cs @@ -6,11 +6,7 @@ namespace SabreTools.Serialization.Bytes public partial class NCF : IByteSerializer { /// -#if NET48 - public Models.NCF.File Deserialize(byte[] data, int offset) -#else public Models.NCF.File? Deserialize(byte[]? data, int offset) -#endif { // If the data is invalid if (data == null) diff --git a/Bytes/NewExecutable.Deserializer.cs b/Bytes/NewExecutable.Deserializer.cs index 55388cdb..d1364080 100644 --- a/Bytes/NewExecutable.Deserializer.cs +++ b/Bytes/NewExecutable.Deserializer.cs @@ -7,11 +7,7 @@ namespace SabreTools.Serialization.Bytes public partial class NewExecutable : IByteSerializer { /// -#if NET48 - public Executable Deserialize(byte[] data, int offset) -#else public Executable? Deserialize(byte[]? data, int offset) -#endif { // If the data is invalid if (data == null) diff --git a/Bytes/Nitro.Deserializer.cs b/Bytes/Nitro.Deserializer.cs index 1335ddd5..8d97a586 100644 --- a/Bytes/Nitro.Deserializer.cs +++ b/Bytes/Nitro.Deserializer.cs @@ -7,11 +7,7 @@ namespace SabreTools.Serialization.Bytes public partial class Nitro : IByteSerializer { /// -#if NET48 - public Cart Deserialize(byte[] data, int offset) -#else public Cart? Deserialize(byte[]? data, int offset) -#endif { // If the data is invalid if (data == null) diff --git a/Bytes/PAK.Deserializer.cs b/Bytes/PAK.Deserializer.cs index 99a648e3..0a285865 100644 --- a/Bytes/PAK.Deserializer.cs +++ b/Bytes/PAK.Deserializer.cs @@ -6,11 +6,7 @@ namespace SabreTools.Serialization.Bytes public partial class PAK : IByteSerializer { /// -#if NET48 - public Models.PAK.File Deserialize(byte[] data, int offset) -#else public Models.PAK.File? Deserialize(byte[]? data, int offset) -#endif { // If the data is invalid if (data == null) diff --git a/Bytes/PFF.Deserializer.cs b/Bytes/PFF.Deserializer.cs index 361027cb..fe93da8a 100644 --- a/Bytes/PFF.Deserializer.cs +++ b/Bytes/PFF.Deserializer.cs @@ -7,11 +7,7 @@ namespace SabreTools.Serialization.Bytes public partial class PFF : IByteSerializer { /// -#if NET48 - public Archive Deserialize(byte[] data, int offset) -#else public Archive? Deserialize(byte[]? data, int offset) -#endif { // If the data is invalid if (data == null) diff --git a/Bytes/PlayJAudio.Deserializer.cs b/Bytes/PlayJAudio.Deserializer.cs index d6529968..a0238d4c 100644 --- a/Bytes/PlayJAudio.Deserializer.cs +++ b/Bytes/PlayJAudio.Deserializer.cs @@ -7,11 +7,7 @@ namespace SabreTools.Serialization.Bytes public partial class PlayJAudio : IByteSerializer { /// -#if NET48 - public AudioFile Deserialize(byte[] data, int offset) -#else public AudioFile? Deserialize(byte[]? data, int offset) -#endif { // If the data is invalid if (data == null) diff --git a/Bytes/PlayJPlaylist.Deserializer.cs b/Bytes/PlayJPlaylist.Deserializer.cs index c5e0bf32..d12762cb 100644 --- a/Bytes/PlayJPlaylist.Deserializer.cs +++ b/Bytes/PlayJPlaylist.Deserializer.cs @@ -7,11 +7,7 @@ namespace SabreTools.Serialization.Bytes public partial class PlayJPlaylist : IByteSerializer { /// -#if NET48 - public Playlist Deserialize(byte[] data, int offset) -#else public Playlist? Deserialize(byte[]? data, int offset) -#endif { // If the data is invalid if (data == null) diff --git a/Bytes/PortableExecutable.Deserializer.cs b/Bytes/PortableExecutable.Deserializer.cs index 26ddb555..b4a8e722 100644 --- a/Bytes/PortableExecutable.Deserializer.cs +++ b/Bytes/PortableExecutable.Deserializer.cs @@ -7,11 +7,7 @@ namespace SabreTools.Serialization.Bytes public partial class PortableExecutable : IByteSerializer { /// -#if NET48 - public Executable Deserialize(byte[] data, int offset) -#else public Executable? Deserialize(byte[]? data, int offset) -#endif { // If the data is invalid if (data == null) diff --git a/Bytes/Quantum.Deserializer.cs b/Bytes/Quantum.Deserializer.cs index 112e695b..027ede95 100644 --- a/Bytes/Quantum.Deserializer.cs +++ b/Bytes/Quantum.Deserializer.cs @@ -7,11 +7,7 @@ namespace SabreTools.Serialization.Bytes public partial class Quantum : IByteSerializer { /// -#if NET48 - public Archive Deserialize(byte[] data, int offset) -#else public Archive? Deserialize(byte[]? data, int offset) -#endif { // If the data is invalid if (data == null) diff --git a/Bytes/SGA.Deserializer.cs b/Bytes/SGA.Deserializer.cs index 820a9cce..7bbb8a01 100644 --- a/Bytes/SGA.Deserializer.cs +++ b/Bytes/SGA.Deserializer.cs @@ -6,11 +6,7 @@ namespace SabreTools.Serialization.Bytes public partial class SGA : IByteSerializer { /// -#if NET48 - public Models.SGA.File Deserialize(byte[] data, int offset) -#else public Models.SGA.File? Deserialize(byte[]? data, int offset) -#endif { // If the data is invalid if (data == null) diff --git a/Bytes/VBSP.Deserializer.cs b/Bytes/VBSP.Deserializer.cs index f0688bbe..ace836b1 100644 --- a/Bytes/VBSP.Deserializer.cs +++ b/Bytes/VBSP.Deserializer.cs @@ -6,11 +6,7 @@ namespace SabreTools.Serialization.Bytes public partial class VBSP : IByteSerializer { /// -#if NET48 - public Models.VBSP.File Deserialize(byte[] data, int offset) -#else public Models.VBSP.File? Deserialize(byte[]? data, int offset) -#endif { // If the data is invalid if (data == null) diff --git a/Bytes/VPK.Deserializer.cs b/Bytes/VPK.Deserializer.cs index 68197917..d6a39946 100644 --- a/Bytes/VPK.Deserializer.cs +++ b/Bytes/VPK.Deserializer.cs @@ -6,11 +6,7 @@ namespace SabreTools.Serialization.Bytes public partial class VPK : IByteSerializer { /// -#if NET48 - public Models.VPK.File Deserialize(byte[] data, int offset) -#else public Models.VPK.File? Deserialize(byte[]? data, int offset) -#endif { // If the data is invalid if (data == null) diff --git a/Bytes/WAD.Deserializer.cs b/Bytes/WAD.Deserializer.cs index 02929e94..ef3d89f7 100644 --- a/Bytes/WAD.Deserializer.cs +++ b/Bytes/WAD.Deserializer.cs @@ -6,11 +6,7 @@ namespace SabreTools.Serialization.Bytes public partial class WAD : IByteSerializer { /// -#if NET48 - public Models.WAD.File Deserialize(byte[] data, int offset) -#else public Models.WAD.File? Deserialize(byte[]? data, int offset) -#endif { // If the data is invalid if (data == null) diff --git a/Bytes/XCP.Deserializer.cs b/Bytes/XCP.Deserializer.cs index 7d3f5fd6..f50f72eb 100644 --- a/Bytes/XCP.Deserializer.cs +++ b/Bytes/XCP.Deserializer.cs @@ -6,11 +6,7 @@ namespace SabreTools.Serialization.Bytes public partial class XZP : IByteSerializer { /// -#if NET48 - public Models.XZP.File Deserialize(byte[] data, int offset) -#else public Models.XZP.File? Deserialize(byte[]? data, int offset) -#endif { // If the data is invalid if (data == null) diff --git a/CrossModel/ArchiveDotOrg.Deserializer.cs b/CrossModel/ArchiveDotOrg.Deserializer.cs index 9574e8de..b150f23b 100644 --- a/CrossModel/ArchiveDotOrg.Deserializer.cs +++ b/CrossModel/ArchiveDotOrg.Deserializer.cs @@ -8,11 +8,7 @@ namespace SabreTools.Serialization.CrossModel public partial class ArchiveDotOrg : IModelSerializer { /// -#if NET48 - public Models.ArchiveDotOrg.Files Deserialize(Models.Metadata.MetadataFile obj) -#else public Models.ArchiveDotOrg.Files? Deserialize(Models.Metadata.MetadataFile? obj) -#endif { if (obj == null) return null; diff --git a/CrossModel/ArchiveDotOrg.Serializer.cs b/CrossModel/ArchiveDotOrg.Serializer.cs index 61369f26..ff9762f8 100644 --- a/CrossModel/ArchiveDotOrg.Serializer.cs +++ b/CrossModel/ArchiveDotOrg.Serializer.cs @@ -6,11 +6,7 @@ namespace SabreTools.Serialization.CrossModel public partial class ArchiveDotOrg : IModelSerializer { /// -#if NET48 - public Models.Metadata.MetadataFile Serialize(Models.ArchiveDotOrg.Files item) -#else public Models.Metadata.MetadataFile? Serialize(Models.ArchiveDotOrg.Files? item) -#endif { if (item == null) return null; @@ -47,11 +43,7 @@ namespace SabreTools.Serialization.CrossModel /// /// Convert from to /// -#if NET48 - private static Models.Metadata.Machine ConvertMachineToInternalModel(Models.ArchiveDotOrg.File item) -#else private static Models.Metadata.Machine ConvertMachineToInternalModel(Models.ArchiveDotOrg.File? item) -#endif { var machine = new Models.Metadata.Machine { @@ -63,11 +55,7 @@ namespace SabreTools.Serialization.CrossModel /// /// Convert from to /// -#if NET48 - private static Models.Metadata.Rom ConvertToInternalModel(Models.ArchiveDotOrg.File item) -#else private static Models.Metadata.Rom? ConvertToInternalModel(Models.ArchiveDotOrg.File? item) -#endif { if (item == null) return null; diff --git a/CrossModel/AttractMode.Deserializer.cs b/CrossModel/AttractMode.Deserializer.cs index 6ec354ae..57c56a5b 100644 --- a/CrossModel/AttractMode.Deserializer.cs +++ b/CrossModel/AttractMode.Deserializer.cs @@ -8,11 +8,7 @@ namespace SabreTools.Serialization.CrossModel public partial class AttractMode : IModelSerializer { /// -#if NET48 - public MetadataFile Deserialize(Models.Metadata.MetadataFile obj) -#else public MetadataFile? Deserialize(Models.Metadata.MetadataFile? obj) -#endif { if (obj == null) return null; diff --git a/CrossModel/AttractMode.Serializer.cs b/CrossModel/AttractMode.Serializer.cs index 9bb9a7aa..30e6c10e 100644 --- a/CrossModel/AttractMode.Serializer.cs +++ b/CrossModel/AttractMode.Serializer.cs @@ -7,11 +7,7 @@ namespace SabreTools.Serialization.CrossModel public partial class AttractMode : IModelSerializer { /// -#if NET48 - public Models.Metadata.MetadataFile Serialize(MetadataFile obj) -#else public Models.Metadata.MetadataFile? Serialize(MetadataFile? obj) -#endif { if (obj == null) return null; @@ -48,11 +44,7 @@ namespace SabreTools.Serialization.CrossModel /// /// Convert from to /// -#if NET48 - private static Models.Metadata.Machine ConvertMachineToInternalModel(Row item) -#else private static Models.Metadata.Machine? ConvertMachineToInternalModel(Row? item) -#endif { if (item == null) return null; diff --git a/CrossModel/ClrMamePro.Deserializer.cs b/CrossModel/ClrMamePro.Deserializer.cs index 0b905841..80df287f 100644 --- a/CrossModel/ClrMamePro.Deserializer.cs +++ b/CrossModel/ClrMamePro.Deserializer.cs @@ -7,18 +7,10 @@ namespace SabreTools.Serialization.CrossModel public partial class ClrMamePro : IModelSerializer { /// -#if NET48 - public MetadataFile Deserialize(Models.Metadata.MetadataFile obj) => Deserialize(obj, false); -#else public MetadataFile? Deserialize(Models.Metadata.MetadataFile? obj) => Deserialize(obj, false); -#endif /// -#if NET48 - public MetadataFile Deserialize(Models.Metadata.MetadataFile obj, bool game) -#else public MetadataFile? Deserialize(Models.Metadata.MetadataFile? obj, bool game) -#endif { if (obj == null) return null; @@ -72,15 +64,7 @@ namespace SabreTools.Serialization.CrossModel /// private static GameBase ConvertMachineFromInternalModel(Models.Metadata.Machine item, bool game = false) { -#if NET48 - GameBase gameBase; - if (game) - gameBase = new Game(); - else - gameBase = new Machine(); -#else GameBase gameBase = game ? new Models.ClrMamePro.Game() : new Models.ClrMamePro.Machine(); -#endif gameBase.Name = item.ReadString(Models.Metadata.Machine.NameKey); gameBase.Description = item.ReadString(Models.Metadata.Machine.DescriptionKey); diff --git a/CrossModel/ClrMamePro.Serializer.cs b/CrossModel/ClrMamePro.Serializer.cs index 793db969..662b0d7b 100644 --- a/CrossModel/ClrMamePro.Serializer.cs +++ b/CrossModel/ClrMamePro.Serializer.cs @@ -7,11 +7,7 @@ namespace SabreTools.Serialization.CrossModel public partial class ClrMamePro : IModelSerializer { /// -#if NET48 - public Models.Metadata.MetadataFile Serialize(MetadataFile obj) -#else public Models.Metadata.MetadataFile? Serialize(MetadataFile? obj) -#endif { if (obj == null) return null; @@ -62,11 +58,7 @@ namespace SabreTools.Serialization.CrossModel /// /// Convert from to /// -#if NET48 - private static Models.Metadata.Machine ConvertMachineToInternalModel(GameBase item) -#else private static Models.Metadata.Machine? ConvertMachineToInternalModel(GameBase? item) -#endif { if (item == null) return null; diff --git a/CrossModel/DosCenter.Deserializer.cs b/CrossModel/DosCenter.Deserializer.cs index 78824038..190015ba 100644 --- a/CrossModel/DosCenter.Deserializer.cs +++ b/CrossModel/DosCenter.Deserializer.cs @@ -7,11 +7,7 @@ namespace SabreTools.Serialization.CrossModel public partial class DosCenter : IModelSerializer { /// -#if NET48 - public MetadataFile Deserialize(Models.Metadata.MetadataFile obj) -#else public MetadataFile? Deserialize(Models.Metadata.MetadataFile? obj) -#endif { if (obj == null) return null; diff --git a/CrossModel/DosCenter.Serializer.cs b/CrossModel/DosCenter.Serializer.cs index aa37978d..e9bd0207 100644 --- a/CrossModel/DosCenter.Serializer.cs +++ b/CrossModel/DosCenter.Serializer.cs @@ -7,11 +7,7 @@ namespace SabreTools.Serialization.CrossModel public partial class DosCenter : IModelSerializer { /// -#if NET48 - public Models.Metadata.MetadataFile Serialize(MetadataFile obj) -#else public Models.Metadata.MetadataFile? Serialize(MetadataFile? obj) -#endif { if (obj == null) return null; diff --git a/CrossModel/EverdriveSMDB.Deserializer.cs b/CrossModel/EverdriveSMDB.Deserializer.cs index 42802c23..b30a6abd 100644 --- a/CrossModel/EverdriveSMDB.Deserializer.cs +++ b/CrossModel/EverdriveSMDB.Deserializer.cs @@ -8,11 +8,7 @@ namespace SabreTools.Serialization.CrossModel public partial class EverdriveSMDB : IModelSerializer { /// -#if NET48 - public MetadataFile Deserialize(Models.Metadata.MetadataFile obj) -#else public MetadataFile? Deserialize(Models.Metadata.MetadataFile? obj) -#endif { if (obj == null) return null; diff --git a/CrossModel/EverdriveSMDB.Serializer.cs b/CrossModel/EverdriveSMDB.Serializer.cs index a76fc37d..1c655a47 100644 --- a/CrossModel/EverdriveSMDB.Serializer.cs +++ b/CrossModel/EverdriveSMDB.Serializer.cs @@ -7,11 +7,7 @@ namespace SabreTools.Serialization.CrossModel public partial class EverdriveSMDB : IModelSerializer { /// -#if NET48 - public Models.Metadata.MetadataFile Serialize(MetadataFile obj) -#else public Models.Metadata.MetadataFile? Serialize(MetadataFile? obj) -#endif { if (obj == null) return null; diff --git a/CrossModel/Hashfile.Deserializer.cs b/CrossModel/Hashfile.Deserializer.cs index bab7b923..c3b68ecb 100644 --- a/CrossModel/Hashfile.Deserializer.cs +++ b/CrossModel/Hashfile.Deserializer.cs @@ -8,18 +8,10 @@ namespace SabreTools.Serialization.CrossModel public partial class Hashfile : IModelSerializer { /// -#if NET48 - public Models.Hashfile.Hashfile Deserialize(Models.Metadata.MetadataFile obj) => Deserialize(obj, Hash.CRC); -#else public Models.Hashfile.Hashfile? Deserialize(Models.Metadata.MetadataFile? obj) => Deserialize(obj, Hash.CRC); -#endif /// -#if NET48 - public Models.Hashfile.Hashfile Deserialize(Models.Metadata.MetadataFile obj, Hash hash) -#else public Models.Hashfile.Hashfile? Deserialize(Models.Metadata.MetadataFile? obj, Hash hash) -#endif { if (obj == null) return null; @@ -81,11 +73,7 @@ namespace SabreTools.Serialization.CrossModel /// /// Convert from to an array of /// -#if NET48 - public static Models.Hashfile.Hashfile[] ConvertArrayFromInternalModel(Models.Metadata.MetadataFile item, Hash hash) -#else public static Models.Hashfile.Hashfile[]? ConvertArrayFromInternalModel(Models.Metadata.MetadataFile? item, Hash hash) -#endif { if (item == null) return null; diff --git a/CrossModel/Hashfile.Serializer.cs b/CrossModel/Hashfile.Serializer.cs index b5175fa0..d37f79fe 100644 --- a/CrossModel/Hashfile.Serializer.cs +++ b/CrossModel/Hashfile.Serializer.cs @@ -7,11 +7,7 @@ namespace SabreTools.Serialization.CrossModel public partial class Hashfile : IModelSerializer { /// -#if NET48 - public Models.Metadata.MetadataFile Serialize(Models.Hashfile.Hashfile obj) -#else public Models.Metadata.MetadataFile? Serialize(Models.Hashfile.Hashfile? obj) -#endif { if (obj == null) return null; diff --git a/CrossModel/Listrom.Deserializer.cs b/CrossModel/Listrom.Deserializer.cs index 7d4950fb..cc731d4d 100644 --- a/CrossModel/Listrom.Deserializer.cs +++ b/CrossModel/Listrom.Deserializer.cs @@ -8,11 +8,7 @@ namespace SabreTools.Serialization.CrossModel public partial class Listrom : IModelSerializer { /// -#if NET48 - public MetadataFile Deserialize(Models.Metadata.MetadataFile obj) -#else public MetadataFile? Deserialize(Models.Metadata.MetadataFile? obj) -#endif { if (obj == null) return null; diff --git a/CrossModel/Listrom.Serializer.cs b/CrossModel/Listrom.Serializer.cs index 4e4cc6af..654ae3c6 100644 --- a/CrossModel/Listrom.Serializer.cs +++ b/CrossModel/Listrom.Serializer.cs @@ -8,11 +8,7 @@ namespace SabreTools.Serialization.CrossModel public partial class Listrom : IModelSerializer { /// -#if NET48 - public Models.Metadata.MetadataFile Serialize(MetadataFile obj) -#else public Models.Metadata.MetadataFile? Serialize(MetadataFile? obj) -#endif { if (obj == null) return null; diff --git a/CrossModel/Listxml.Deserializer.cs b/CrossModel/Listxml.Deserializer.cs index fdcaed7c..56788897 100644 --- a/CrossModel/Listxml.Deserializer.cs +++ b/CrossModel/Listxml.Deserializer.cs @@ -7,11 +7,7 @@ namespace SabreTools.Serialization.CrossModel public partial class Listxml : IModelSerializer { /// -#if NET48 - public Mame Deserialize(Models.Metadata.MetadataFile obj) -#else public Mame? Deserialize(Models.Metadata.MetadataFile? obj) -#endif { if (obj == null) return null; @@ -34,11 +30,7 @@ namespace SabreTools.Serialization.CrossModel /// /// Convert from to /// -#if NET48 - private static Mame ConvertMameFromInternalModel(Models.Metadata.MetadataFile item) -#else public static Mame? ConvertMameFromInternalModel(Models.Metadata.MetadataFile? item) -#endif { if (item == null) return null; diff --git a/CrossModel/Listxml.Serializer.cs b/CrossModel/Listxml.Serializer.cs index 23edfdd8..3c0a589f 100644 --- a/CrossModel/Listxml.Serializer.cs +++ b/CrossModel/Listxml.Serializer.cs @@ -7,11 +7,7 @@ namespace SabreTools.Serialization.CrossModel public partial class Listxml : IModelSerializer { /// -#if NET48 - public Models.Metadata.MetadataFile Serialize(Mame item) -#else public Models.Metadata.MetadataFile? Serialize(Mame? item) -#endif { if (item == null) return null; diff --git a/CrossModel/Logiqx.Deserializer.cs b/CrossModel/Logiqx.Deserializer.cs index 9f20b4a3..180c3092 100644 --- a/CrossModel/Logiqx.Deserializer.cs +++ b/CrossModel/Logiqx.Deserializer.cs @@ -7,18 +7,10 @@ namespace SabreTools.Serialization.CrossModel public partial class Logiqx : IModelSerializer { /// -#if NET48 - public Datafile Deserialize(Models.Metadata.MetadataFile obj) => Deserialize(obj, false); -#else public Datafile? Deserialize(Models.Metadata.MetadataFile? obj) => Deserialize(obj, false); -#endif /// -#if NET48 - public Datafile Deserialize(Models.Metadata.MetadataFile obj, bool game) -#else public Datafile? Deserialize(Models.Metadata.MetadataFile? obj, bool game) -#endif { if (obj == null) return null; @@ -111,15 +103,7 @@ namespace SabreTools.Serialization.CrossModel /// private static GameBase ConvertMachineFromInternalModel(Models.Metadata.Machine item, bool game = false) { -#if NET48 - GameBase gameBase; - if (game) - gameBase = new Game(); - else - gameBase = new Machine(); -#else GameBase gameBase = game ? new Game() : new Machine(); -#endif gameBase.Name = item.ReadString(Models.Metadata.Machine.NameKey); gameBase.SourceFile = item.ReadString(Models.Metadata.Machine.SourceFileKey); diff --git a/CrossModel/Logiqx.Serializer.cs b/CrossModel/Logiqx.Serializer.cs index c4fedc58..6c9b8844 100644 --- a/CrossModel/Logiqx.Serializer.cs +++ b/CrossModel/Logiqx.Serializer.cs @@ -8,11 +8,7 @@ namespace SabreTools.Serialization.CrossModel { public partial class Logiqx : IModelSerializer { -#if NET48 - public Models.Metadata.MetadataFile Serialize(Datafile item) -#else public Models.Metadata.MetadataFile? Serialize(Datafile? item) -#endif { if (item == null) return null; diff --git a/CrossModel/M1.Deserializer.cs b/CrossModel/M1.Deserializer.cs index d3e66bb1..929574b5 100644 --- a/CrossModel/M1.Deserializer.cs +++ b/CrossModel/M1.Deserializer.cs @@ -6,11 +6,7 @@ namespace SabreTools.Serialization.CrossModel public partial class M1 : IModelSerializer { /// -#if NET48 - public Models.Listxml.M1 Deserialize(Models.Metadata.MetadataFile obj) -#else public Models.Listxml.M1? Deserialize(Models.Metadata.MetadataFile? obj) -#endif { if (obj == null) return null; diff --git a/CrossModel/M1.Serializer.cs b/CrossModel/M1.Serializer.cs index 9f1ccf53..054cd920 100644 --- a/CrossModel/M1.Serializer.cs +++ b/CrossModel/M1.Serializer.cs @@ -6,11 +6,7 @@ namespace SabreTools.Serialization.CrossModel public partial class M1 : IModelSerializer { /// -#if NET48 - public Models.Metadata.MetadataFile Serialize(Models.Listxml.M1 item) -#else public Models.Metadata.MetadataFile? Serialize(Models.Listxml.M1? item) -#endif { if (item == null) return null; diff --git a/CrossModel/OfflineList.Deserializer.cs b/CrossModel/OfflineList.Deserializer.cs index b08217ce..dcb94780 100644 --- a/CrossModel/OfflineList.Deserializer.cs +++ b/CrossModel/OfflineList.Deserializer.cs @@ -7,11 +7,7 @@ namespace SabreTools.Serialization.CrossModel public partial class OfflineList : IModelSerializer { /// -#if NET48 - public Dat Deserialize(Models.Metadata.MetadataFile obj) -#else public Dat? Deserialize(Models.Metadata.MetadataFile? obj) -#endif { if (obj == null) return null; diff --git a/CrossModel/OfflineList.Serializer.cs b/CrossModel/OfflineList.Serializer.cs index 51f731bd..897e6387 100644 --- a/CrossModel/OfflineList.Serializer.cs +++ b/CrossModel/OfflineList.Serializer.cs @@ -7,11 +7,7 @@ namespace SabreTools.Serialization.CrossModel public partial class OfflineList : IModelSerializer { /// -#if NET48 - public Models.Metadata.MetadataFile Serialize(Dat item) -#else public Models.Metadata.MetadataFile? Serialize(Dat? item) -#endif { if (item == null) return null; diff --git a/CrossModel/OpenMSX.Deserializer.cs b/CrossModel/OpenMSX.Deserializer.cs index bfbcab8e..bd869ed8 100644 --- a/CrossModel/OpenMSX.Deserializer.cs +++ b/CrossModel/OpenMSX.Deserializer.cs @@ -7,11 +7,7 @@ namespace SabreTools.Serialization.CrossModel public partial class OpenMSX : IModelSerializer { /// -#if NET48 - public SoftwareDb Deserialize(Models.Metadata.MetadataFile obj) -#else public SoftwareDb? Deserialize(Models.Metadata.MetadataFile? obj) -#endif { if (obj == null) return null; diff --git a/CrossModel/OpenMSX.Serializer.cs b/CrossModel/OpenMSX.Serializer.cs index b352c53b..0670feda 100644 --- a/CrossModel/OpenMSX.Serializer.cs +++ b/CrossModel/OpenMSX.Serializer.cs @@ -7,11 +7,7 @@ namespace SabreTools.Serialization.CrossModel public partial class OpenMSX : IModelSerializer { /// -#if NET48 - public Models.Metadata.MetadataFile Serialize(SoftwareDb item) -#else public Models.Metadata.MetadataFile? Serialize(SoftwareDb? item) -#endif { if (item == null) return null; diff --git a/CrossModel/RomCenter.Deserializer.cs b/CrossModel/RomCenter.Deserializer.cs index 451ee85a..6a6e208c 100644 --- a/CrossModel/RomCenter.Deserializer.cs +++ b/CrossModel/RomCenter.Deserializer.cs @@ -8,11 +8,7 @@ namespace SabreTools.Serialization.CrossModel public partial class RomCenter : IModelSerializer { /// -#if NET48 - public MetadataFile Deserialize(Models.Metadata.MetadataFile obj) -#else public MetadataFile? Deserialize(Models.Metadata.MetadataFile? obj) -#endif { if (obj == null) return null; diff --git a/CrossModel/RomCenter.Serializer.cs b/CrossModel/RomCenter.Serializer.cs index 02b0807e..4c07321d 100644 --- a/CrossModel/RomCenter.Serializer.cs +++ b/CrossModel/RomCenter.Serializer.cs @@ -7,11 +7,7 @@ namespace SabreTools.Serialization.CrossModel public partial class RomCenter : IModelSerializer { /// -#if NET48 - public Models.Metadata.MetadataFile Serialize(MetadataFile obj) -#else public Models.Metadata.MetadataFile? Serialize(MetadataFile? obj) -#endif { if (obj == null) return null; diff --git a/CrossModel/SeparatedValue.Deserializer.cs b/CrossModel/SeparatedValue.Deserializer.cs index 923a5904..129839c1 100644 --- a/CrossModel/SeparatedValue.Deserializer.cs +++ b/CrossModel/SeparatedValue.Deserializer.cs @@ -8,11 +8,7 @@ namespace SabreTools.Serialization.CrossModel public partial class SeparatedValue : IModelSerializer { /// -#if NET48 - public MetadataFile Deserialize(Models.Metadata.MetadataFile obj) -#else public MetadataFile? Deserialize(Models.Metadata.MetadataFile? obj) -#endif { if (obj == null) return null; diff --git a/CrossModel/SeparatedValue.Serializer.cs b/CrossModel/SeparatedValue.Serializer.cs index ebd98381..919365d9 100644 --- a/CrossModel/SeparatedValue.Serializer.cs +++ b/CrossModel/SeparatedValue.Serializer.cs @@ -7,11 +7,7 @@ namespace SabreTools.Serialization.CrossModel public partial class SeparatedValue : IModelSerializer { /// -#if NET48 - public Models.Metadata.MetadataFile Serialize(MetadataFile obj) -#else public Models.Metadata.MetadataFile? Serialize(MetadataFile? obj) -#endif { if (obj == null) return null; @@ -78,53 +74,6 @@ namespace SabreTools.Serialization.CrossModel return machine; } -#if NET48 - /// - /// Convert from to - /// - private static Models.Metadata.DatItem ConvertToInternalModel(Row item) - { - switch (item.Type) - { - case "disk": - return new Models.Metadata.Disk - { - [Models.Metadata.Disk.NameKey] = item.DiskName, - [Models.Metadata.Disk.MD5Key] = item.MD5, - [Models.Metadata.Disk.SHA1Key] = item.SHA1, - [Models.Metadata.Disk.StatusKey] = item.Status, - }; - - case "media": - return new Models.Metadata.Media - { - [Models.Metadata.Media.NameKey] = item.DiskName, - [Models.Metadata.Media.MD5Key] = item.MD5, - [Models.Metadata.Media.SHA1Key] = item.SHA1, - [Models.Metadata.Media.SHA256Key] = item.SHA256, - [Models.Metadata.Media.SpamSumKey] = item.SpamSum, - }; - - case "rom": - return new Models.Metadata.Rom - { - [Models.Metadata.Rom.NameKey] = item.RomName, - [Models.Metadata.Rom.SizeKey] = item.Size, - [Models.Metadata.Rom.CRCKey] = item.CRC, - [Models.Metadata.Rom.MD5Key] = item.MD5, - [Models.Metadata.Rom.SHA1Key] = item.SHA1, - [Models.Metadata.Rom.SHA256Key] = item.SHA256, - [Models.Metadata.Rom.SHA384Key] = item.SHA384, - [Models.Metadata.Rom.SHA512Key] = item.SHA512, - [Models.Metadata.Rom.SpamSumKey] = item.SpamSum, - [Models.Metadata.Rom.StatusKey] = item.Status, - }; - - default: - return null; - } - } -#else /// /// Convert from to /// @@ -163,6 +112,5 @@ namespace SabreTools.Serialization.CrossModel _ => null, }; } -#endif } } \ No newline at end of file diff --git a/CrossModel/SoftwareList.Deserializer.cs b/CrossModel/SoftwareList.Deserializer.cs index 2ff39118..0c9da289 100644 --- a/CrossModel/SoftwareList.Deserializer.cs +++ b/CrossModel/SoftwareList.Deserializer.cs @@ -7,11 +7,7 @@ namespace SabreTools.Serialization.CrossModel public partial class SoftwareList : IModelSerializer { /// -#if NET48 - public Models.SoftwareList.SoftwareList Deserialize(Models.Metadata.MetadataFile obj) -#else public Models.SoftwareList.SoftwareList? Deserialize(Models.Metadata.MetadataFile? obj) -#endif { if (obj == null) return null; diff --git a/CrossModel/SoftwareList.Serializer.cs b/CrossModel/SoftwareList.Serializer.cs index ec20821b..2d64b027 100644 --- a/CrossModel/SoftwareList.Serializer.cs +++ b/CrossModel/SoftwareList.Serializer.cs @@ -7,11 +7,7 @@ namespace SabreTools.Serialization.CrossModel public partial class SoftwareList : IModelSerializer { /// -#if NET48 - public Models.Metadata.MetadataFile Serialize(Models.SoftwareList.SoftwareList item) -#else public Models.Metadata.MetadataFile? Serialize(Models.SoftwareList.SoftwareList? item) -#endif { if (item == null) return null; diff --git a/Extensions.PortableExecutable.cs b/Extensions.PortableExecutable.cs index 7231a8fd..db8bbc8e 100644 --- a/Extensions.PortableExecutable.cs +++ b/Extensions.PortableExecutable.cs @@ -17,11 +17,7 @@ namespace SabreTools.Serialization /// Relative virtual address to convert /// Array of sections to check against /// Physical address, 0 on error -#if NET48 - public static uint ConvertVirtualAddress(this uint rva, SectionHeader[] sections) -#else public static uint ConvertVirtualAddress(this uint rva, SectionHeader?[]? sections) -#endif { // If we have an invalid section table, we can't do anything if (sections == null || sections.Length == 0) @@ -44,19 +40,11 @@ namespace SabreTools.Serialization continue; // If the section "starts" at 0, just skip it -#if NET48 - if (sections[i].PointerToRawData == 0) -#else if (sections[i]!.PointerToRawData == 0) -#endif continue; // Attempt to derive the physical address from the current section -#if NET48 - var section = sections[i]; -#else var section = sections[i]!; -#endif if (rva >= section.VirtualAddress && section.VirtualSize != 0 && rva <= section.VirtualAddress + section.VirtualSize) return rva - section.VirtualAddress + section.PointerToRawData; else if (rva >= section.VirtualAddress && section.SizeOfRawData != 0 && rva <= section.VirtualAddress + section.SizeOfRawData) @@ -72,11 +60,7 @@ namespace SabreTools.Serialization /// Relative virtual address to convert /// Array of sections to check against /// Section index, null on error -#if NET48 - public static int ContainingSectionIndex(this uint rva, SectionHeader[] sections) -#else public static int ContainingSectionIndex(this uint rva, SectionHeader?[]? sections) -#endif { // If we have an invalid section table, we can't do anything if (sections == null || sections.Length == 0) @@ -114,11 +98,7 @@ namespace SabreTools.Serialization /// Data to parse into overlay data /// Offset into the byte array /// A filled SecuROM AddD overlay data on success, null on error -#if NET48 - public static SecuROMAddD AsSecuROMAddD(this byte[] data, ref int offset) -#else public static SecuROMAddD? AsSecuROMAddD(this byte[]? data, ref int offset) -#endif { // If we have data that's invalid, we can't do anything if (data == null) @@ -181,11 +161,7 @@ namespace SabreTools.Serialization /// Data to parse into a database /// Offset into the byte array /// A filled NB10 Program Database on success, null on error -#if NET48 - public static NB10ProgramDatabase AsNB10ProgramDatabase(this byte[] data, ref int offset) -#else public static NB10ProgramDatabase? AsNB10ProgramDatabase(this byte[] data, ref int offset) -#endif { // If we have data that's invalid, we can't do anything if (data == null) @@ -211,11 +187,7 @@ namespace SabreTools.Serialization /// Data to parse into a database /// Offset into the byte array /// A filled RSDS Program Database on success, null on error -#if NET48 - public static RSDSProgramDatabase AsRSDSProgramDatabase(this byte[] data, ref int offset) -#else public static RSDSProgramDatabase? AsRSDSProgramDatabase(this byte[]? data, ref int offset) -#endif { // If we have data that's invalid, we can't do anything if (data == null) @@ -247,11 +219,7 @@ namespace SabreTools.Serialization /// Data to parse into a resource header /// Offset into the byte array /// A filled resource header on success, null on error -#if NET48 - public static ResourceHeader AsResourceHeader(this byte[] data, ref int offset) -#else public static ResourceHeader? AsResourceHeader(this byte[]? data, ref int offset) -#endif { // If we have data that's invalid, we can't do anything if (data == null) @@ -277,11 +245,7 @@ namespace SabreTools.Serialization /// /// Resource data entry to parse into an accelerator table resource /// A filled accelerator table resource on success, null on error -#if NET48 - public static AcceleratorTableEntry[] AsAcceleratorTableResource(this ResourceDataEntry entry) -#else public static AcceleratorTableEntry[]? AsAcceleratorTableResource(this ResourceDataEntry? entry) -#endif { // If we have data that's invalid for this resource type, we can't do anything if (entry?.Data == null || entry.Data.Length % 8 != 0) @@ -317,11 +281,7 @@ namespace SabreTools.Serialization /// /// Resource data entry to parse into a side-by-side assembly manifest /// A filled side-by-side assembly manifest on success, null on error -#if NET48 - public static AssemblyManifest AsAssemblyManifest(this ResourceDataEntry entry) -#else public static AssemblyManifest? AsAssemblyManifest(this ResourceDataEntry? entry) -#endif { // If we have an invalid entry, just skip if (entry?.Data == null) @@ -343,11 +303,7 @@ namespace SabreTools.Serialization /// /// Resource data entry to parse into a dialog box /// A filled dialog box on success, null on error -#if NET48 - public static DialogBoxResource AsDialogBox(this ResourceDataEntry entry) -#else public static DialogBoxResource? AsDialogBox(this ResourceDataEntry? entry) -#endif { // If we have an invalid entry, just skip if (entry?.Data == null) @@ -856,11 +812,7 @@ namespace SabreTools.Serialization /// /// Resource data entry to parse into a font group /// A filled font group on success, null on error -#if NET48 - public static FontGroupHeader AsFontGroup(this ResourceDataEntry entry) -#else public static FontGroupHeader? AsFontGroup(this ResourceDataEntry? entry) -#endif { // If we have an invalid entry, just skip if (entry?.Data == null) @@ -929,11 +881,7 @@ namespace SabreTools.Serialization /// /// Resource data entry to parse into a menu /// A filled menu on success, null on error -#if NET48 - public static MenuResource AsMenu(this ResourceDataEntry entry) -#else public static MenuResource? AsMenu(this ResourceDataEntry? entry) -#endif { // If we have an invalid entry, just skip if (entry?.Data == null) @@ -1056,11 +1004,7 @@ namespace SabreTools.Serialization /// /// Resource data entry to parse into a message table resource /// A filled message table resource on success, null on error -#if NET48 - public static MessageResourceData AsMessageResourceData(this ResourceDataEntry entry) -#else public static MessageResourceData? AsMessageResourceData(this ResourceDataEntry? entry) -#endif { // If we have an invalid entry, just skip if (entry?.Data == null) @@ -1095,11 +1039,7 @@ namespace SabreTools.Serialization // Message resource entries if (messageResourceData.Blocks != null && messageResourceData.Blocks.Length != 0) { -#if NET48 - var messageResourceEntries = new Dictionary(); -#else var messageResourceEntries = new Dictionary(); -#endif for (int i = 0; i < messageResourceData.Blocks.Length; i++) { @@ -1117,11 +1057,7 @@ namespace SabreTools.Serialization messageResourceEntry.Flags = entry.Data.ReadUInt16(ref offset); Encoding textEncoding = messageResourceEntry.Flags == 0x0001 ? Encoding.Unicode : Encoding.ASCII; -#if NET48 - byte[] textArray = entry.Data.ReadBytes(ref offset, messageResourceEntry.Length - 4); -#else byte[]? textArray = entry.Data.ReadBytes(ref offset, messageResourceEntry.Length - 4); -#endif if (textArray != null) messageResourceEntry.Text = textEncoding.GetString(textArray); @@ -1140,11 +1076,7 @@ namespace SabreTools.Serialization /// /// Resource data entry to parse into a string table resource /// A filled string table resource on success, null on error -#if NET48 - public static Dictionary AsStringTable(this ResourceDataEntry entry) -#else public static Dictionary? AsStringTable(this ResourceDataEntry? entry) -#endif { // If we have an invalid entry, just skip if (entry?.Data == null) @@ -1154,11 +1086,7 @@ namespace SabreTools.Serialization int offset = 0, stringIndex = 0; // Create the output table -#if NET48 - var stringTable = new Dictionary(); -#else var stringTable = new Dictionary(); -#endif // Loop through and add while (offset < entry.Data.Length) @@ -1191,11 +1119,7 @@ namespace SabreTools.Serialization /// /// Resource data entry to parse into a version info resource /// A filled version info resource on success, null on error -#if NET48 - public static VersionInfo AsVersionInfo(this ResourceDataEntry entry) -#else public static VersionInfo? AsVersionInfo(this ResourceDataEntry? entry) -#endif { // If we have an invalid entry, just skip if (entry?.Data == null) @@ -1252,11 +1176,7 @@ namespace SabreTools.Serialization int currentOffset = offset; offset += 6; -#if NET48 - string nextKey = entry.Data.ReadString(ref offset, Encoding.Unicode); -#else string? nextKey = entry.Data.ReadString(ref offset, Encoding.Unicode); -#endif offset = currentOffset; if (nextKey == "StringFileInfo") @@ -1278,11 +1198,7 @@ namespace SabreTools.Serialization int currentOffset = offset; offset += 6; -#if NET48 - string nextKey = entry.Data.ReadString(ref offset, Encoding.Unicode); -#else string? nextKey = entry.Data.ReadString(ref offset, Encoding.Unicode); -#endif offset = currentOffset; if (nextKey == "StringFileInfo") @@ -1306,11 +1222,7 @@ namespace SabreTools.Serialization /// Data to parse into a string file info /// Offset into the byte array /// A filled string file info resource on success, null on error -#if NET48 - private static StringFileInfo AsStringFileInfo(byte[] data, ref int offset) -#else private static StringFileInfo? AsStringFileInfo(byte[] data, ref int offset) -#endif { var stringFileInfo = new StringFileInfo(); @@ -1370,11 +1282,7 @@ namespace SabreTools.Serialization if (stringData.ValueLength > 0) { -#if NET48 - byte[] valueBytes = data.ReadBytes(ref offset, stringData.ValueLength * sizeof(ushort)); -#else byte[]? valueBytes = data.ReadBytes(ref offset, stringData.ValueLength * sizeof(ushort)); -#endif if (valueBytes != null) stringData.Value = Encoding.Unicode.GetString(valueBytes); } @@ -1405,11 +1313,7 @@ namespace SabreTools.Serialization /// Data to parse into a var file info /// Offset into the byte array /// A filled var file info resource on success, null on error -#if NET48 - private static VarFileInfo AsVarFileInfo(byte[] data, ref int offset) -#else private static VarFileInfo? AsVarFileInfo(byte[] data, ref int offset) -#endif { var varFileInfo = new VarFileInfo(); diff --git a/Files/AttractMode.Deserializer.cs b/Files/AttractMode.Deserializer.cs index 37bc85cf..5cfde3fd 100644 --- a/Files/AttractMode.Deserializer.cs +++ b/Files/AttractMode.Deserializer.cs @@ -6,11 +6,7 @@ namespace SabreTools.Serialization.Files public partial class AttractMode : IFileSerializer { /// -#if NET48 - public MetadataFile Deserialize(string path) -#else public MetadataFile? Deserialize(string? path) -#endif { using (var stream = PathProcessor.OpenStream(path)) { diff --git a/Files/AttractMode.Serializer.cs b/Files/AttractMode.Serializer.cs index ed0c0a20..0a44b26c 100644 --- a/Files/AttractMode.Serializer.cs +++ b/Files/AttractMode.Serializer.cs @@ -7,11 +7,7 @@ namespace SabreTools.Serialization.Files public partial class AttractMode : IFileSerializer { /// -#if NET48 - public bool Serialize(MetadataFile obj, string path) -#else public bool Serialize(MetadataFile? obj, string? path) -#endif { if (string.IsNullOrWhiteSpace(path)) return false; diff --git a/Files/ClrMamePro.Deserializer.cs b/Files/ClrMamePro.Deserializer.cs index 620c0242..7769f3be 100644 --- a/Files/ClrMamePro.Deserializer.cs +++ b/Files/ClrMamePro.Deserializer.cs @@ -6,18 +6,10 @@ namespace SabreTools.Serialization.Files public partial class ClrMamePro : IFileSerializer { /// -#if NET48 - public MetadataFile Deserialize(string path) => Deserialize(path, true); -#else public MetadataFile? Deserialize(string? path) => Deserialize(path, true); -#endif /// -#if NET48 - public MetadataFile Deserialize(string path, bool quotes) -#else public MetadataFile? Deserialize(string? path, bool quotes) -#endif { using (var stream = PathProcessor.OpenStream(path)) { diff --git a/Files/ClrMamePro.Serializer.cs b/Files/ClrMamePro.Serializer.cs index 63364dfc..0d4553cb 100644 --- a/Files/ClrMamePro.Serializer.cs +++ b/Files/ClrMamePro.Serializer.cs @@ -7,18 +7,10 @@ namespace SabreTools.Serialization.Files public partial class ClrMamePro : IFileSerializer { /// -#if NET48 - public bool Serialize(MetadataFile obj, string path) => Serialize(obj, path, true); -#else public bool Serialize(MetadataFile? obj, string? path) => Serialize(obj, path, true); -#endif /// -#if NET48 - public bool Serialize(MetadataFile obj, string path, bool quotes) -#else public bool Serialize(MetadataFile? obj, string? path, bool quotes) -#endif { if (string.IsNullOrWhiteSpace(path)) return false; diff --git a/Files/CueSheet.Deserializer.cs b/Files/CueSheet.Deserializer.cs index eb4d56dc..68d53e22 100644 --- a/Files/CueSheet.Deserializer.cs +++ b/Files/CueSheet.Deserializer.cs @@ -11,11 +11,7 @@ namespace SabreTools.Serialization.Files public partial class CueSheet : IFileSerializer { /// -#if NET48 - public Models.CueSheets.CueSheet Deserialize(string path) -#else public Models.CueSheets.CueSheet? Deserialize(string? path) -#endif { // Check that the file exists if (string.IsNullOrWhiteSpace(path) || !File.Exists(path)) @@ -122,11 +118,7 @@ namespace SabreTools.Serialization.Files /// File type to set /// Lines array to pull from /// Reference to index in array -#if NET48 - private static CueFile CreateCueFile(string fileName, string fileType, string[] cueLines, ref int i) -#else private static CueFile? CreateCueFile(string fileName, string fileType, string[]? cueLines, ref int i) -#endif { // Check the required parameters if (cueLines == null) @@ -191,11 +183,7 @@ namespace SabreTools.Serialization.Files /// Data type to set /// Lines array to pull from /// Reference to index in array -#if NET48 - private static CueTrack CreateCueTrack(string number, string dataType, string[] cueLines, ref int i) -#else private static CueTrack? CreateCueTrack(string number, string dataType, string[]? cueLines, ref int i) -#endif { // Check the required parameters if (cueLines == null) @@ -326,18 +314,14 @@ namespace SabreTools.Serialization.Files /// Create a PREGAP from a mm:ss:ff length /// /// String to get length information from -#if NET48 - private static PreGap CreatePreGap(string length) -#else private static PreGap CreatePreGap(string? length) -#endif { // Ignore empty lines if (string.IsNullOrWhiteSpace(length)) throw new ArgumentException("Length was null or whitespace"); // Ignore lines that don't contain the correct information - if (length.Length != 8 || length.Count(c => c == ':') != 2) + if (length!.Length != 8 || length.Count(c => c == ':') != 2) throw new FormatException($"Length was not in a recognized format: {length}"); // Split the line @@ -381,11 +365,7 @@ namespace SabreTools.Serialization.Files /// /// Index to set /// Start time to set -#if NET48 - private static CueIndex CreateCueIndex(string index, string startTime) -#else private static CueIndex CreateCueIndex(string? index, string? startTime) -#endif { // Set the current fields if (!int.TryParse(index, out int parsedIndex)) @@ -398,7 +378,7 @@ namespace SabreTools.Serialization.Files throw new ArgumentException("Start time was null or whitespace"); // Ignore lines that don't contain the correct information - if (startTime.Length != 8 || startTime.Count(c => c == ':') != 2) + if (startTime!.Length != 8 || startTime.Count(c => c == ':') != 2) throw new FormatException($"Start time was not in a recognized format: {startTime}"); // Split the line @@ -442,18 +422,14 @@ namespace SabreTools.Serialization.Files /// Create a POSTGAP from a mm:ss:ff length /// /// String to get length information from -#if NET48 - private static PostGap CreatePostGap(string length) -#else private static PostGap CreatePostGap(string? length) -#endif { // Ignore empty lines if (string.IsNullOrWhiteSpace(length)) throw new ArgumentException("Length was null or whitespace"); // Ignore lines that don't contain the correct information - if (length.Length != 8 || length.Count(c => c == ':') != 2) + if (length!.Length != 8 || length.Count(c => c == ':') != 2) throw new FormatException($"Length was not in a recognized format: {length}"); // Split the line @@ -499,11 +475,7 @@ namespace SabreTools.Serialization.Files /// /// String to get value from /// CueFileType, if possible -#if NET48 - private static CueFileType GetFileType(string fileType) -#else private static CueFileType GetFileType(string? fileType) -#endif { switch (fileType?.ToLowerInvariant()) { @@ -532,11 +504,7 @@ namespace SabreTools.Serialization.Files /// /// String to get value from /// CueTrackDataType, if possible (default AUDIO) -#if NET48 - private static CueTrackDataType GetDataType(string dataType) -#else private static CueTrackDataType GetDataType(string? dataType) -#endif { switch (dataType?.ToLowerInvariant()) { @@ -574,21 +542,13 @@ namespace SabreTools.Serialization.Files /// /// Possible flags as strings /// CueTrackFlag value representing the strings, if possible -#if NET48 - private static CueTrackFlag GetFlags(string[] flagStrings) -#else private static CueTrackFlag GetFlags(string?[]? flagStrings) -#endif { CueTrackFlag flag = 0; if (flagStrings == null) return flag; -#if NET48 - foreach (string flagString in flagStrings) -#else foreach (string? flagString in flagStrings) -#endif { switch (flagString?.ToLowerInvariant()) { diff --git a/Files/CueSheet.Serializer.cs b/Files/CueSheet.Serializer.cs index b99a564d..d7e78d61 100644 --- a/Files/CueSheet.Serializer.cs +++ b/Files/CueSheet.Serializer.cs @@ -6,11 +6,7 @@ namespace SabreTools.Serialization.Files public partial class CueSheet : IFileSerializer { /// -#if NET48 - public bool Serialize(Models.CueSheets.CueSheet obj, string path) -#else public bool Serialize(Models.CueSheets.CueSheet? obj, string? path) -#endif { if (string.IsNullOrWhiteSpace(path)) return false; diff --git a/Files/DosCenter.Deserializer.cs b/Files/DosCenter.Deserializer.cs index e26bd23c..e6678b02 100644 --- a/Files/DosCenter.Deserializer.cs +++ b/Files/DosCenter.Deserializer.cs @@ -6,11 +6,7 @@ namespace SabreTools.Serialization.Files public partial class DosCenter : IFileSerializer { /// -#if NET48 - public MetadataFile Deserialize(string path) -#else public MetadataFile? Deserialize(string? path) -#endif { using (var stream = PathProcessor.OpenStream(path)) { diff --git a/Files/DosCenter.Serializer.cs b/Files/DosCenter.Serializer.cs index 327120a0..6c056203 100644 --- a/Files/DosCenter.Serializer.cs +++ b/Files/DosCenter.Serializer.cs @@ -6,11 +6,7 @@ namespace SabreTools.Serialization.Files public partial class DosCenter : IFileSerializer { /// -#if NET48 - public bool Serialize(MetadataFile obj, string path) -#else public bool Serialize(MetadataFile? obj, string? path) -#endif { if (string.IsNullOrWhiteSpace(path)) return false; diff --git a/Files/EverdriveSMDB.Deserializer.cs b/Files/EverdriveSMDB.Deserializer.cs index bd0404e3..a4a0ec95 100644 --- a/Files/EverdriveSMDB.Deserializer.cs +++ b/Files/EverdriveSMDB.Deserializer.cs @@ -6,11 +6,7 @@ namespace SabreTools.Serialization.Files public partial class EverdriveSMDB : IFileSerializer { /// -#if NET48 - public MetadataFile Deserialize(string path) -#else public MetadataFile? Deserialize(string? path) -#endif { using (var stream = PathProcessor.OpenStream(path)) { diff --git a/Files/EverdriveSMDB.Serializer.cs b/Files/EverdriveSMDB.Serializer.cs index 35be31b6..e34741dd 100644 --- a/Files/EverdriveSMDB.Serializer.cs +++ b/Files/EverdriveSMDB.Serializer.cs @@ -6,11 +6,7 @@ namespace SabreTools.Serialization.Files public partial class EverdriveSMDB : IFileSerializer { /// -#if NET48 - public bool Serialize(MetadataFile obj, string path) -#else public bool Serialize(MetadataFile? obj, string? path) -#endif { if (string.IsNullOrWhiteSpace(path)) return false; diff --git a/Files/Hashfile.Deserializer.cs b/Files/Hashfile.Deserializer.cs index a8bcdc12..e4810d87 100644 --- a/Files/Hashfile.Deserializer.cs +++ b/Files/Hashfile.Deserializer.cs @@ -5,18 +5,10 @@ namespace SabreTools.Serialization.Files public partial class Hashfile : IFileSerializer { /// -#if NET48 - public Models.Hashfile.Hashfile Deserialize(string path) => Deserialize(path, Hash.CRC); -#else public Models.Hashfile.Hashfile? Deserialize(string? path) => Deserialize(path, Hash.CRC); -#endif /// -#if NET48 - public Models.Hashfile.Hashfile Deserialize(string path, Hash hash) -#else public Models.Hashfile.Hashfile? Deserialize(string? path, Hash hash) -#endif { using (var stream = PathProcessor.OpenStream(path)) { diff --git a/Files/Hashfile.Serializer.cs b/Files/Hashfile.Serializer.cs index 48356044..f41a07ba 100644 --- a/Files/Hashfile.Serializer.cs +++ b/Files/Hashfile.Serializer.cs @@ -5,18 +5,10 @@ namespace SabreTools.Serialization.Files public partial class Hashfile : IFileSerializer { /// -#if NET48 - public bool Serialize(Models.Hashfile.Hashfile obj, string path) => Serialize(obj, path, Hash.CRC); -#else public bool Serialize(Models.Hashfile.Hashfile? obj, string? path) => Serialize(obj, path, Hash.CRC); -#endif /// -#if NET48 - public bool Serialize(Models.Hashfile.Hashfile obj, string path, Hash hash) -#else public bool Serialize(Models.Hashfile.Hashfile? obj, string? path, Hash hash) -#endif { if (string.IsNullOrWhiteSpace(path)) return false; diff --git a/Files/IRD.Deserializer.cs b/Files/IRD.Deserializer.cs index 0120458a..7728a4ed 100644 --- a/Files/IRD.Deserializer.cs +++ b/Files/IRD.Deserializer.cs @@ -5,11 +5,7 @@ namespace SabreTools.Serialization.Files public partial class IRD : IFileSerializer { /// -#if NET48 - public Models.IRD.IRD Deserialize(string path) -#else public Models.IRD.IRD? Deserialize(string? path) -#endif { using (var stream = PathProcessor.OpenStream(path)) { diff --git a/Files/IRD.Serializer.cs b/Files/IRD.Serializer.cs index cde7a595..f9952629 100644 --- a/Files/IRD.Serializer.cs +++ b/Files/IRD.Serializer.cs @@ -5,11 +5,7 @@ namespace SabreTools.Serialization.Files public partial class IRD : IFileSerializer { /// -#if NET48 - public bool Serialize(Models.IRD.IRD obj, string path) -#else public bool Serialize(Models.IRD.IRD? obj, string? path) -#endif { if (string.IsNullOrWhiteSpace(path)) return false; diff --git a/Files/Listrom.Deserializer.cs b/Files/Listrom.Deserializer.cs index cd2e6440..59d3edd3 100644 --- a/Files/Listrom.Deserializer.cs +++ b/Files/Listrom.Deserializer.cs @@ -6,11 +6,7 @@ namespace SabreTools.Serialization.Files public partial class Listrom : IFileSerializer { /// -#if NET48 - public MetadataFile Deserialize(string path) -#else public MetadataFile? Deserialize(string? path) -#endif { using (var stream = PathProcessor.OpenStream(path)) { diff --git a/Files/Listrom.Serializer.cs b/Files/Listrom.Serializer.cs index 57318e65..117b2395 100644 --- a/Files/Listrom.Serializer.cs +++ b/Files/Listrom.Serializer.cs @@ -6,11 +6,7 @@ namespace SabreTools.Serialization.Files public partial class Listrom : IFileSerializer { /// -#if NET48 - public bool Serialize(MetadataFile obj, string path) -#else public bool Serialize(MetadataFile? obj, string? path) -#endif { if (string.IsNullOrWhiteSpace(path)) return false; diff --git a/Files/PIC.Deserializer.cs b/Files/PIC.Deserializer.cs index 11d25a60..0afd67e1 100644 --- a/Files/PIC.Deserializer.cs +++ b/Files/PIC.Deserializer.cs @@ -6,11 +6,7 @@ namespace SabreTools.Serialization.Files public partial class PIC : IFileSerializer { /// -#if NET48 - public DiscInformation Deserialize(string path) -#else public DiscInformation? Deserialize(string? path) -#endif { using (var stream = PathProcessor.OpenStream(path)) { diff --git a/Files/PIC.Serializer.cs b/Files/PIC.Serializer.cs index cec12b77..9b3620d3 100644 --- a/Files/PIC.Serializer.cs +++ b/Files/PIC.Serializer.cs @@ -6,11 +6,7 @@ namespace SabreTools.Serialization.Files public partial class PIC : IFileSerializer { /// -#if NET48 - public bool Serialize(DiscInformation obj, string path) -#else public bool Serialize(DiscInformation? obj, string? path) -#endif { if (string.IsNullOrWhiteSpace(path)) return false; diff --git a/Files/RomCenter.Deserializer.cs b/Files/RomCenter.Deserializer.cs index 931a6326..39c95e53 100644 --- a/Files/RomCenter.Deserializer.cs +++ b/Files/RomCenter.Deserializer.cs @@ -6,11 +6,7 @@ namespace SabreTools.Serialization.Files public partial class RomCenter : IFileSerializer { /// -#if NET48 - public MetadataFile Deserialize(string path) -#else public MetadataFile? Deserialize(string? path) -#endif { using (var stream = PathProcessor.OpenStream(path)) { diff --git a/Files/RomCenter.Serializer.cs b/Files/RomCenter.Serializer.cs index 8026bcd9..8b9d9eb3 100644 --- a/Files/RomCenter.Serializer.cs +++ b/Files/RomCenter.Serializer.cs @@ -6,11 +6,7 @@ namespace SabreTools.Serialization.Files public partial class RomCenter : IFileSerializer { /// -#if NET48 - public bool Serialize(MetadataFile obj, string path) -#else public bool Serialize(MetadataFile? obj, string? path) -#endif { if (string.IsNullOrWhiteSpace(path)) return false; diff --git a/Files/SeparatedValue.Deserializer.cs b/Files/SeparatedValue.Deserializer.cs index 0877a92e..414fa883 100644 --- a/Files/SeparatedValue.Deserializer.cs +++ b/Files/SeparatedValue.Deserializer.cs @@ -6,18 +6,10 @@ namespace SabreTools.Serialization.Files public partial class SeparatedValue : IFileSerializer { /// -#if NET48 - public MetadataFile Deserialize(string path) => Deserialize(path, ','); -#else public MetadataFile? Deserialize(string? path) => Deserialize(path, ','); -#endif /// -#if NET48 - public MetadataFile Deserialize(string path, char delim) -#else public MetadataFile? Deserialize(string? path, char delim) -#endif { using (var stream = PathProcessor.OpenStream(path)) { diff --git a/Files/SeparatedValue.Serializer.cs b/Files/SeparatedValue.Serializer.cs index a2e7a06a..84faa87f 100644 --- a/Files/SeparatedValue.Serializer.cs +++ b/Files/SeparatedValue.Serializer.cs @@ -6,18 +6,10 @@ namespace SabreTools.Serialization.Files public partial class SeparatedValue : IFileSerializer { /// -#if NET48 - public bool Serialize(MetadataFile obj, string path) => Serialize(obj, path, ','); -#else public bool Serialize(MetadataFile? obj, string? path) => Serialize(obj, path, ','); -#endif /// -#if NET48 - public bool Serialize(MetadataFile obj, string path, char delim) -#else public bool Serialize(MetadataFile? obj, string? path, char delim) -#endif { if (string.IsNullOrWhiteSpace(path)) return false; diff --git a/Files/XmlFile.Deserializer.cs b/Files/XmlFile.Deserializer.cs index b8c18801..2b809787 100644 --- a/Files/XmlFile.Deserializer.cs +++ b/Files/XmlFile.Deserializer.cs @@ -9,11 +9,7 @@ namespace SabreTools.Serialization.Files public partial class XmlFile : IFileSerializer { /// -#if NET48 - public T Deserialize(string path) -#else public T? Deserialize(string? path) -#endif { using (var data = PathProcessor.OpenStream(path)) { diff --git a/Files/XmlFile.Serializer.cs b/Files/XmlFile.Serializer.cs index 814e0b19..22688782 100644 --- a/Files/XmlFile.Serializer.cs +++ b/Files/XmlFile.Serializer.cs @@ -10,11 +10,7 @@ namespace SabreTools.Serialization.Files public partial class XmlFile : IFileSerializer { /// -#if NET48 - public bool Serialize(T obj, string path) -#else public bool Serialize(T? obj, string? path) -#endif => Serialize(obj, path, null, null, null, null); /// @@ -28,11 +24,7 @@ namespace SabreTools.Serialization.Files /// Optional DOCTYPE sysid /// Optional DOCTYPE name /// True on successful serialization, false otherwise -#if NET48 - public bool Serialize(T obj, string path, string name = null, string pubid = null, string sysid = null, string subset = null) -#else public bool Serialize(T? obj, string? path, string? name = null, string? pubid = null, string? sysid = null, string? subset = null) -#endif { if (string.IsNullOrWhiteSpace(path)) return false; diff --git a/Interfaces/IByteSerializer.cs b/Interfaces/IByteSerializer.cs index deac29f5..01f84a48 100644 --- a/Interfaces/IByteSerializer.cs +++ b/Interfaces/IByteSerializer.cs @@ -12,11 +12,7 @@ namespace SabreTools.Serialization.Interfaces /// Byte array to parse /// Offset into the byte array /// Filled object on success, null on error -#if NET48 - T Deserialize(byte[] data, int offset); -#else T? Deserialize(byte[]? data, int offset); -#endif // TODO: Add serialization method } diff --git a/Interfaces/IFileSerializer.cs b/Interfaces/IFileSerializer.cs index 165d6ec1..28e281ec 100644 --- a/Interfaces/IFileSerializer.cs +++ b/Interfaces/IFileSerializer.cs @@ -11,11 +11,7 @@ namespace SabreTools.Serialization.Interfaces /// Type of object to deserialize to /// Path to deserialize from /// Filled object on success, null on error -#if NET48 - T Deserialize(string path); -#else T? Deserialize(string? path); -#endif /// /// Serialize a into a file @@ -24,10 +20,6 @@ namespace SabreTools.Serialization.Interfaces /// Data to serialize /// Path to the file to serialize to /// True on successful serialization, false otherwise -#if NET48 - bool Serialize(T obj, string path); -#else bool Serialize(T? obj, string? path); -#endif } } \ No newline at end of file diff --git a/Interfaces/IModelSerializer.cs b/Interfaces/IModelSerializer.cs index df625932..8126f161 100644 --- a/Interfaces/IModelSerializer.cs +++ b/Interfaces/IModelSerializer.cs @@ -12,11 +12,7 @@ namespace SabreTools.Serialization.Interfaces /// Type of object to deserialize from /// Object to deserialize from /// Filled object on success, null on error -#if NET48 - T Deserialize(U obj); -#else T? Deserialize(U? obj); -#endif /// /// Serialize a into @@ -25,10 +21,6 @@ namespace SabreTools.Serialization.Interfaces /// Type of object to serialize to /// Object to serialize from /// Filled object on success, null on error -#if NET48 - U Serialize(T obj); -#else U? Serialize(T? obj); -#endif } } \ No newline at end of file diff --git a/Interfaces/IStreamSerializer.cs b/Interfaces/IStreamSerializer.cs index bc7c620c..71dba156 100644 --- a/Interfaces/IStreamSerializer.cs +++ b/Interfaces/IStreamSerializer.cs @@ -13,11 +13,7 @@ namespace SabreTools.Serialization.Interfaces /// Type of object to deserialize to /// Stream to parse /// Filled object on success, null on error -#if NET48 - T Deserialize(Stream data); -#else T? Deserialize(Stream? data); -#endif /// /// Serialize a into a Stream @@ -25,10 +21,6 @@ namespace SabreTools.Serialization.Interfaces /// Type of object to serialize from /// Data to serialize /// Filled object on success, null on error -#if NET48 - Stream Serialize(T obj); -#else Stream? Serialize(T? obj); -#endif } } \ No newline at end of file diff --git a/Interfaces/IStringSerializer.cs b/Interfaces/IStringSerializer.cs index 157a6e9e..2b7db4be 100644 --- a/Interfaces/IStringSerializer.cs +++ b/Interfaces/IStringSerializer.cs @@ -11,11 +11,7 @@ namespace SabreTools.Serialization.Interfaces /// Type of object to deserialize to /// String to deserialize from /// Filled object on success, null on error -#if NET48 - T Deserialize(string str); -#else T? Deserialize(string? str); -#endif /// /// Serialize a into a string @@ -23,10 +19,6 @@ namespace SabreTools.Serialization.Interfaces /// Type of object to serialize from /// Data to serialize /// Filled string on successful serialization, null otherwise -#if NET48 - string Serialize(T obj); -#else string? Serialize(T? obj); -#endif } } \ No newline at end of file diff --git a/Interfaces/IWrapper.cs b/Interfaces/IWrapper.cs index 23104eaf..5985746e 100644 --- a/Interfaces/IWrapper.cs +++ b/Interfaces/IWrapper.cs @@ -7,7 +7,7 @@ namespace SabreTools.Serialization.Interfaces /// string Description(); -#if NET6_0_OR_GREATER +#if !NETFRAMEWORK /// /// Export the item information as JSON /// diff --git a/Internal.cs b/Internal.cs index 18487800..a5acf58f 100644 --- a/Internal.cs +++ b/Internal.cs @@ -10,11 +10,7 @@ namespace SabreTools.Serialization /// /// Extract nested items from a Dump /// -#if NET48 - public static DatItem[] ExtractItems(Dump item) -#else public static DatItem[]? ExtractItems(Dump? item) -#endif { if (item == null) return null; @@ -39,11 +35,7 @@ namespace SabreTools.Serialization /// /// Extract nested items from a Part /// -#if NET48 - public static DatItem[] ExtractItems(Part item) -#else public static DatItem[]? ExtractItems(Part? item) -#endif { if (item == null) return null; diff --git a/Logiqx.cs b/Logiqx.cs index 6c84bf89..cb28fcb6 100644 --- a/Logiqx.cs +++ b/Logiqx.cs @@ -23,10 +23,6 @@ namespace SabreTools.Serialization /// /// subset field for DOCTYPE /// -#if NET48 - public const string DocTypeSubset = null; -#else public const string? DocTypeSubset = null; -#endif } } \ No newline at end of file diff --git a/OpenMSX.cs b/OpenMSX.cs index 94b819d4..0e4bb9e2 100644 --- a/OpenMSX.cs +++ b/OpenMSX.cs @@ -13,11 +13,7 @@ namespace SabreTools.Serialization /// /// pubid field for DOCTYPE /// -#if NET48 - public const string DocTypePubId = null; -#else public const string? DocTypePubId = null; -#endif /// /// sysid field for DOCTYPE @@ -27,10 +23,6 @@ namespace SabreTools.Serialization /// /// subset field for DOCTYPE /// -#if NET48 - public const string DocTypeSubset = null; -#else public const string? DocTypeSubset = null; -#endif } } \ No newline at end of file diff --git a/PathProcessor.cs b/PathProcessor.cs index 7e1ed323..709c8082 100644 --- a/PathProcessor.cs +++ b/PathProcessor.cs @@ -11,11 +11,7 @@ namespace SabreTools.Serialization /// /// Path to open as a stream /// Stream representing the file, null on error -#if NET48 - public static Stream OpenStream(string path) -#else public static Stream? OpenStream(string? path) -#endif { try { diff --git a/SabreTools.Serialization.csproj b/SabreTools.Serialization.csproj index 5061fe73..061bc5f9 100644 --- a/SabreTools.Serialization.csproj +++ b/SabreTools.Serialization.csproj @@ -4,8 +4,11 @@ net48;net6.0;net7.0;net8.0 win-x86;win-x64;linux-x64;osx-x64 - 1.1.7 true + latest + enable + true + 1.1.7 Matt Nadareski @@ -19,10 +22,6 @@ MIT - - enable - - diff --git a/SoftwareList.cs b/SoftwareList.cs index 27924d76..f2dba5cc 100644 --- a/SoftwareList.cs +++ b/SoftwareList.cs @@ -13,11 +13,7 @@ namespace SabreTools.Serialization /// /// pubid field for DOCTYPE /// -#if NET48 - public const string DocTypePubId = null; -#else public const string? DocTypePubId = null; -#endif /// /// sysid field for DOCTYPE @@ -27,10 +23,6 @@ namespace SabreTools.Serialization /// /// subset field for DOCTYPE /// -#if NET48 - public const string DocTypeSubset = null; -#else public const string? DocTypeSubset = null; -#endif } } \ No newline at end of file diff --git a/Streams/AACS.Deserializer.cs b/Streams/AACS.Deserializer.cs index 8c5642f2..7fdee0ac 100644 --- a/Streams/AACS.Deserializer.cs +++ b/Streams/AACS.Deserializer.cs @@ -11,11 +11,7 @@ namespace SabreTools.Serialization.Streams public partial class AACS : IStreamSerializer { /// -#if NET48 - public MediaKeyBlock Deserialize(Stream data) -#else public MediaKeyBlock? Deserialize(Stream? data) -#endif { // If the data is invalid if (data == null || data.Length == 0 || !data.CanSeek || !data.CanRead) @@ -76,20 +72,12 @@ namespace SabreTools.Serialization.Streams /// /// Stream to parse /// Filled record on success, null on error -#if NET48 - private static Record ParseRecord(Stream data) -#else private static Record? ParseRecord(Stream data) -#endif { // TODO: Use marshalling here instead of building // The first 4 bytes make up the type and length -#if NET48 - byte[] typeAndLength = data.ReadBytes(4); -#else byte[]? typeAndLength = data.ReadBytes(4); -#endif if (typeAndLength == null) return null; @@ -125,11 +113,7 @@ namespace SabreTools.Serialization.Streams /// /// Stream to parse /// Filled end of media key block record on success, null on error -#if NET48 - private static EndOfMediaKeyBlockRecord ParseEndOfMediaKeyBlockRecord(Stream data, RecordType type, uint length) -#else private static EndOfMediaKeyBlockRecord? ParseEndOfMediaKeyBlockRecord(Stream data, RecordType type, uint length) -#endif { // Verify we're calling the right parser if (type != RecordType.EndOfMediaKeyBlock) @@ -151,11 +135,7 @@ namespace SabreTools.Serialization.Streams /// /// Stream to parse /// Filled explicit subset-difference record on success, null on error -#if NET48 - private static ExplicitSubsetDifferenceRecord ParseExplicitSubsetDifferenceRecord(Stream data, RecordType type, uint length) -#else private static ExplicitSubsetDifferenceRecord? ParseExplicitSubsetDifferenceRecord(Stream data, RecordType type, uint length) -#endif { // Verify we're calling the right parser if (type != RecordType.ExplicitSubsetDifference) @@ -199,11 +179,7 @@ namespace SabreTools.Serialization.Streams /// /// Stream to parse /// Filled media key data record on success, null on error -#if NET48 - private static MediaKeyDataRecord ParseMediaKeyDataRecord(Stream data, RecordType type, uint length) -#else private static MediaKeyDataRecord? ParseMediaKeyDataRecord(Stream data, RecordType type, uint length) -#endif { // Verify we're calling the right parser if (type != RecordType.MediaKeyData) @@ -224,11 +200,7 @@ namespace SabreTools.Serialization.Streams // Try to parse the media keys while (data.Position < initialOffset + length) { -#if NET48 - byte[] mediaKey = data.ReadBytes(0x10); -#else byte[]? mediaKey = data.ReadBytes(0x10); -#endif if (mediaKey != null) mediaKeys.Add(mediaKey); } @@ -244,11 +216,7 @@ namespace SabreTools.Serialization.Streams /// /// Stream to parse /// Filled subset-difference index record on success, null on error -#if NET48 - private static SubsetDifferenceIndexRecord ParseSubsetDifferenceIndexRecord(Stream data, RecordType type, uint length) -#else private static SubsetDifferenceIndexRecord? ParseSubsetDifferenceIndexRecord(Stream data, RecordType type, uint length) -#endif { // Verify we're calling the right parser if (type != RecordType.SubsetDifferenceIndex) @@ -286,11 +254,7 @@ namespace SabreTools.Serialization.Streams /// /// Stream to parse /// Filled type and version record on success, null on error -#if NET48 - private static TypeAndVersionRecord ParseTypeAndVersionRecord(Stream data, RecordType type, uint length) -#else private static TypeAndVersionRecord? ParseTypeAndVersionRecord(Stream data, RecordType type, uint length) -#endif { // Verify we're calling the right parser if (type != RecordType.TypeAndVersion) @@ -312,11 +276,7 @@ namespace SabreTools.Serialization.Streams /// /// Stream to parse /// Filled drive revocation list record on success, null on error -#if NET48 - private static DriveRevocationListRecord ParseDriveRevocationListRecord(Stream data, RecordType type, uint length) -#else private static DriveRevocationListRecord? ParseDriveRevocationListRecord(Stream data, RecordType type, uint length) -#endif { // Verify we're calling the right parser if (type != RecordType.DriveRevocationList) @@ -377,11 +337,7 @@ namespace SabreTools.Serialization.Streams /// /// Stream to parse /// Filled host revocation list record on success, null on error -#if NET48 - private static HostRevocationListRecord ParseHostRevocationListRecord(Stream data, RecordType type, uint length) -#else private static HostRevocationListRecord? ParseHostRevocationListRecord(Stream data, RecordType type, uint length) -#endif { // Verify we're calling the right parser if (type != RecordType.HostRevocationList) @@ -442,11 +398,7 @@ namespace SabreTools.Serialization.Streams /// /// Stream to parse /// Filled verify media key record on success, null on error -#if NET48 - private static VerifyMediaKeyRecord ParseVerifyMediaKeyRecord(Stream data, RecordType type, uint length) -#else private static VerifyMediaKeyRecord? ParseVerifyMediaKeyRecord(Stream data, RecordType type, uint length) -#endif { // Verify we're calling the right parser if (type != RecordType.VerifyMediaKey) @@ -467,11 +419,7 @@ namespace SabreTools.Serialization.Streams /// /// Stream to parse /// Filled copyright record on success, null on error -#if NET48 - private static CopyrightRecord ParseCopyrightRecord(Stream data, RecordType type, uint length) -#else private static CopyrightRecord? ParseCopyrightRecord(Stream data, RecordType type, uint length) -#endif { // Verify we're calling the right parser if (type != RecordType.Copyright) @@ -484,11 +432,7 @@ namespace SabreTools.Serialization.Streams record.RecordLength = length; if (length > 4) { -#if NET48 - byte[] copyright = data.ReadBytes((int)(length - 4)); -#else byte[]? copyright = data.ReadBytes((int)(length - 4)); -#endif if (copyright != null) record.Copyright = Encoding.ASCII.GetString(copyright).TrimEnd('\0'); } diff --git a/Streams/AACS.Serializer.cs b/Streams/AACS.Serializer.cs index 2a7f8dd9..91a267b9 100644 --- a/Streams/AACS.Serializer.cs +++ b/Streams/AACS.Serializer.cs @@ -8,10 +8,6 @@ namespace SabreTools.Serialization.Streams public partial class AACS : IStreamSerializer { /// -#if NET48 - public Stream Serialize(MediaKeyBlock obj) => throw new NotImplementedException(); -#else public Stream? Serialize(MediaKeyBlock? obj) => throw new NotImplementedException(); -#endif } } \ No newline at end of file diff --git a/Streams/AttractMode.Deserializer.cs b/Streams/AttractMode.Deserializer.cs index 0cd6b78a..25e022f7 100644 --- a/Streams/AttractMode.Deserializer.cs +++ b/Streams/AttractMode.Deserializer.cs @@ -11,11 +11,7 @@ namespace SabreTools.Serialization.Streams public partial class AttractMode : IStreamSerializer { /// -#if NET48 - public MetadataFile Deserialize(Stream data) -#else public MetadataFile? Deserialize(Stream? data) -#endif { // If the stream is null if (data == null) diff --git a/Streams/AttractMode.Serializer.cs b/Streams/AttractMode.Serializer.cs index f412b5f0..1056e422 100644 --- a/Streams/AttractMode.Serializer.cs +++ b/Streams/AttractMode.Serializer.cs @@ -10,11 +10,7 @@ namespace SabreTools.Serialization.Streams public partial class AttractMode : IStreamSerializer { /// -#if NET48 - public Stream Serialize(MetadataFile obj) -#else public Stream? Serialize(MetadataFile? obj) -#endif { // If the metadata file is null if (obj == null) @@ -46,11 +42,7 @@ namespace SabreTools.Serialization.Streams /// /// Array of Row objects representing the rows information /// SeparatedValueWriter representing the output -#if NET48 - private static void WriteRows(Row[] rows, SeparatedValueWriter writer) -#else private static void WriteRows(Row?[]? rows, SeparatedValueWriter writer) -#endif { // If the games information is missing, we can't do anything if (rows == null || !rows.Any()) @@ -62,11 +54,7 @@ namespace SabreTools.Serialization.Streams if (row == null) continue; -#if NET48 - var rowArray = new string[] -#else var rowArray = new string?[] -#endif { row.Name, row.Title, diff --git a/Streams/BDPlus.Deserializer.cs b/Streams/BDPlus.Deserializer.cs index 48f1bbff..0b06345c 100644 --- a/Streams/BDPlus.Deserializer.cs +++ b/Streams/BDPlus.Deserializer.cs @@ -10,11 +10,7 @@ namespace SabreTools.Serialization.Streams public partial class BDPlus : IStreamSerializer { /// -#if NET48 - public SVM Deserialize(Stream data) -#else public SVM? Deserialize(Stream? data) -#endif { // If the data is invalid if (data == null || data.Length == 0 || !data.CanSeek || !data.CanRead) @@ -36,20 +32,12 @@ namespace SabreTools.Serialization.Streams /// /// Stream to parse /// Filled SVM on success, null on error -#if NET48 - private static SVM ParseSVMData(Stream data) -#else private static SVM? ParseSVMData(Stream data) -#endif { // TODO: Use marshalling here instead of building var svm = new SVM(); -#if NET48 - byte[] signature = data.ReadBytes(8); -#else byte[]? signature = data.ReadBytes(8); -#endif if (signature == null) return null; diff --git a/Streams/BDPlus.Serializer.cs b/Streams/BDPlus.Serializer.cs index 64a6aa0d..2a961a3e 100644 --- a/Streams/BDPlus.Serializer.cs +++ b/Streams/BDPlus.Serializer.cs @@ -8,10 +8,6 @@ namespace SabreTools.Serialization.Streams public partial class BDPlus : IStreamSerializer { /// -#if NET48 - public Stream Serialize(SVM obj) => throw new NotImplementedException(); -#else public Stream? Serialize(SVM? obj) => throw new NotImplementedException(); -#endif } } \ No newline at end of file diff --git a/Streams/BFPK.Deserializer.cs b/Streams/BFPK.Deserializer.cs index e2b7ea80..d1f2389b 100644 --- a/Streams/BFPK.Deserializer.cs +++ b/Streams/BFPK.Deserializer.cs @@ -10,11 +10,7 @@ namespace SabreTools.Serialization.Streams public partial class BFPK : IStreamSerializer { /// -#if NET48 - public Archive Deserialize(Stream data) -#else public Archive? Deserialize(Stream? data) -#endif { // If the data is invalid if (data == null || data.Length == 0 || !data.CanSeek || !data.CanRead) @@ -73,20 +69,12 @@ namespace SabreTools.Serialization.Streams /// /// Stream to parse /// Filled header on success, null on error -#if NET48 - private static Header ParseHeader(Stream data) -#else private static Header? ParseHeader(Stream data) -#endif { // TODO: Use marshalling here instead of building Header header = new Header(); -#if NET48 - byte[] magic = data.ReadBytes(4); -#else byte[]? magic = data.ReadBytes(4); -#endif if (magic == null) return null; @@ -113,11 +101,7 @@ namespace SabreTools.Serialization.Streams fileEntry.NameSize = data.ReadInt32(); if (fileEntry.NameSize > 0) { -#if NET48 - byte[] name = data.ReadBytes(fileEntry.NameSize); -#else byte[]? name = data.ReadBytes(fileEntry.NameSize); -#endif if (name != null) fileEntry.Name = Encoding.ASCII.GetString(name); } diff --git a/Streams/BFPK.Serializer.cs b/Streams/BFPK.Serializer.cs index 39eab0df..22fd6812 100644 --- a/Streams/BFPK.Serializer.cs +++ b/Streams/BFPK.Serializer.cs @@ -8,10 +8,6 @@ namespace SabreTools.Serialization.Streams public partial class BFPK : IStreamSerializer { /// -#if NET48 - public Stream Serialize(Archive obj) => throw new NotImplementedException(); -#else public Stream? Serialize(Archive? obj) => throw new NotImplementedException(); -#endif } } \ No newline at end of file diff --git a/Streams/BSP.Deserializer.cs b/Streams/BSP.Deserializer.cs index c27f1478..0028d965 100644 --- a/Streams/BSP.Deserializer.cs +++ b/Streams/BSP.Deserializer.cs @@ -11,11 +11,7 @@ namespace SabreTools.Serialization.Streams public partial class BSP : IStreamSerializer { /// -#if NET48 - public Models.BSP.File Deserialize(Stream data) -#else public Models.BSP.File? Deserialize(Stream? data) -#endif { // If the data is invalid if (data == null || data.Length == 0 || !data.CanSeek || !data.CanRead) @@ -86,11 +82,7 @@ namespace SabreTools.Serialization.Streams for (int i = 0; i < textureHeader.TextureCount; i++) { // Get the texture offset -#if NET48 - int offset = (int)(textureHeader.Offsets[i] + file.Lumps[HL_BSP_LUMP_TEXTUREDATA].Offset); -#else int offset = (int)(textureHeader.Offsets![i] + file.Lumps[HL_BSP_LUMP_TEXTUREDATA]!.Offset); -#endif if (offset < 0 || offset >= data.Length) continue; @@ -111,11 +103,7 @@ namespace SabreTools.Serialization.Streams /// /// Stream to parse /// Filled Half-Life Level header on success, null on error -#if NET48 - private static Header ParseHeader(Stream data) -#else private static Header? ParseHeader(Stream data) -#endif { // TODO: Use marshalling here instead of building Header header = new Header(); @@ -179,11 +167,7 @@ namespace SabreTools.Serialization.Streams // TODO: Use marshalling here instead of building Texture texture = new Texture(); -#if NET48 - byte[] name = data.ReadBytes(16)?.TakeWhile(c => c != '\0')?.ToArray(); -#else byte[]? name = data.ReadBytes(16)?.TakeWhile(c => c != '\0')?.ToArray(); -#endif if (name != null) texture.Name = Encoding.ASCII.GetString(name); texture.Width = data.ReadUInt32(); diff --git a/Streams/BSP.Serializer.cs b/Streams/BSP.Serializer.cs index 158ca774..a963734f 100644 --- a/Streams/BSP.Serializer.cs +++ b/Streams/BSP.Serializer.cs @@ -7,10 +7,6 @@ namespace SabreTools.Serialization.Streams public partial class BSP : IStreamSerializer { /// -#if NET48 - public Stream Serialize(Models.BSP.File obj) => throw new NotImplementedException(); -#else public Stream? Serialize(Models.BSP.File? obj) => throw new NotImplementedException(); -#endif } } \ No newline at end of file diff --git a/Streams/CFB.Deserializer.cs b/Streams/CFB.Deserializer.cs index 9f549569..687b8668 100644 --- a/Streams/CFB.Deserializer.cs +++ b/Streams/CFB.Deserializer.cs @@ -12,11 +12,7 @@ namespace SabreTools.Serialization.Streams public partial class CFB : IStreamSerializer { /// -#if NET48 - public Binary Deserialize(Stream data) -#else public Binary? Deserialize(Stream? data) -#endif { // If the data is invalid if (data == null || data.Length == 0 || !data.CanSeek || !data.CanRead) @@ -47,11 +43,7 @@ namespace SabreTools.Serialization.Streams #region DIFAT Sector Numbers // Create a DIFAT sector table -#if NET48 - var difatSectors = new List(); -#else var difatSectors = new List(); -#endif // Add the sectors from the header if (fileHeader.DIFAT != null) @@ -93,11 +85,7 @@ namespace SabreTools.Serialization.Streams #region FAT Sector Numbers // Create a FAT sector table -#if NET48 - var fatSectors = new List(); -#else var fatSectors = new List(); -#endif // Loop through and add the FAT sectors currentSector = binary.DIFATSectorNumbers[0]; @@ -135,11 +123,7 @@ namespace SabreTools.Serialization.Streams #region Mini FAT Sector Numbers // Create a mini FAT sector table -#if NET48 - var miniFatSectors = new List(); -#else var miniFatSectors = new List(); -#endif // Loop through and add the mini FAT sectors currentSector = (SectorNumber)fileHeader.FirstMiniFATSectorLocation; @@ -244,11 +228,7 @@ namespace SabreTools.Serialization.Streams /// /// Stream to parse /// Filled file header on success, null on error -#if NET48 - private static FileHeader ParseFileHeader(Stream data) -#else private static FileHeader? ParseFileHeader(Stream data) -#endif { // TODO: Use marshalling here instead of building FileHeader header = new FileHeader(); @@ -287,11 +267,7 @@ namespace SabreTools.Serialization.Streams header.NumberOfMiniFATSectors = data.ReadUInt32(); header.FirstDIFATSectorLocation = data.ReadUInt32(); header.NumberOfDIFATSectors = data.ReadUInt32(); -#if NET48 - header.DIFAT = new SectorNumber[109]; -#else header.DIFAT = new SectorNumber?[109]; -#endif for (int i = 0; i < header.DIFAT.Length; i++) { header.DIFAT[i] = (SectorNumber)data.ReadUInt32(); @@ -310,19 +286,11 @@ namespace SabreTools.Serialization.Streams /// Stream to parse /// Sector shift from the header /// Filled sector full of sector numbers on success, null on error -#if NET48 - private static SectorNumber[] ParseSectorNumbers(Stream data, ushort sectorShift) -#else private static SectorNumber?[] ParseSectorNumbers(Stream data, ushort sectorShift) -#endif { // TODO: Use marshalling here instead of building int sectorCount = (int)(Math.Pow(2, sectorShift) / sizeof(uint)); -#if NET48 - var sectorNumbers = new SectorNumber[sectorCount]; -#else var sectorNumbers = new SectorNumber?[sectorCount]; -#endif for (int i = 0; i < sectorNumbers.Length; i++) { @@ -339,11 +307,7 @@ namespace SabreTools.Serialization.Streams /// Sector shift from the header /// Major version from the header /// Filled sector full of directory entries on success, null on error -#if NET48 - private static DirectoryEntry[] ParseDirectoryEntries(Stream data, ushort sectorShift, ushort majorVersion) -#else private static DirectoryEntry[]? ParseDirectoryEntries(Stream data, ushort sectorShift, ushort majorVersion) -#endif { // TODO: Use marshalling here instead of building const int directoryEntrySize = 64 + 2 + 1 + 1 + 4 + 4 + 4 + 16 + 4 + 8 + 8 + 4 + 8; @@ -373,11 +337,7 @@ namespace SabreTools.Serialization.Streams // TODO: Use marshalling here instead of building DirectoryEntry directoryEntry = new DirectoryEntry(); -#if NET48 - byte[] name = data.ReadBytes(64); -#else byte[]? name = data.ReadBytes(64); -#endif if (name != null) directoryEntry.Name = Encoding.Unicode.GetString(name).TrimEnd('\0'); directoryEntry.NameLength = data.ReadUInt16(); diff --git a/Streams/CFB.Serializer.cs b/Streams/CFB.Serializer.cs index b3bd8f38..f1e34376 100644 --- a/Streams/CFB.Serializer.cs +++ b/Streams/CFB.Serializer.cs @@ -8,10 +8,6 @@ namespace SabreTools.Serialization.Streams public partial class CFB : IStreamSerializer { /// -#if NET48 - public Stream Serialize(Binary obj) => throw new NotImplementedException(); -#else public Stream? Serialize(Binary? obj) => throw new NotImplementedException(); -#endif } } \ No newline at end of file diff --git a/Streams/CIA.Deserializer.cs b/Streams/CIA.Deserializer.cs index 69cf0db2..f1402433 100644 --- a/Streams/CIA.Deserializer.cs +++ b/Streams/CIA.Deserializer.cs @@ -10,11 +10,7 @@ namespace SabreTools.Serialization.Streams public partial class CIA : IStreamSerializer { /// -#if NET48 - public Models.N3DS.CIA Deserialize(Stream data) -#else public Models.N3DS.CIA? Deserialize(Stream? data) -#endif { // If the data is invalid if (data == null || data.Length == 0 || !data.CanSeek || !data.CanRead) @@ -173,11 +169,7 @@ namespace SabreTools.Serialization.Streams /// /// Stream to parse /// Filled certificate on success, null on error -#if NET48 - private static Certificate ParseCertificate(Stream data) -#else private static Certificate? ParseCertificate(Stream data) -#endif { // TODO: Use marshalling here instead of building Certificate certificate = new Certificate(); @@ -215,19 +207,11 @@ namespace SabreTools.Serialization.Streams certificate.Signature = data.ReadBytes(certificate.SignatureSize); certificate.Padding = data.ReadBytes(certificate.PaddingSize); -#if NET48 - byte[] issuer = data.ReadBytes(0x40); -#else byte[]? issuer = data.ReadBytes(0x40); -#endif if (issuer != null) certificate.Issuer = Encoding.ASCII.GetString(issuer).TrimEnd('\0'); certificate.KeyType = (PublicKeyType)data.ReadUInt32(); -#if NET48 - byte[] name = data.ReadBytes(0x40); -#else byte[]? name = data.ReadBytes(0x40); -#endif if (name != null) certificate.Name = Encoding.ASCII.GetString(name).TrimEnd('\0'); certificate.ExpirationTime = data.ReadUInt32(); @@ -261,11 +245,7 @@ namespace SabreTools.Serialization.Streams /// Stream to parse /// Indicates if the ticket is from CDN /// Filled ticket on success, null on error -#if NET48 - private static Ticket ParseTicket(Stream data, bool fromCdn = false) -#else private static Ticket? ParseTicket(Stream data, bool fromCdn = false) -#endif { // TODO: Use marshalling here instead of building Ticket ticket = new Ticket(); @@ -303,11 +283,7 @@ namespace SabreTools.Serialization.Streams ticket.Signature = data.ReadBytes(ticket.SignatureSize); ticket.Padding = data.ReadBytes(ticket.PaddingSize); -#if NET48 - byte[] issuer = data.ReadBytes(0x40); -#else byte[]? issuer = data.ReadBytes(0x40); -#endif if (issuer != null) ticket.Issuer = Encoding.ASCII.GetString(issuer).TrimEnd('\0'); ticket.ECCPublicKey = data.ReadBytes(0x3C); @@ -339,11 +315,7 @@ namespace SabreTools.Serialization.Streams data.Seek(4, SeekOrigin.Current); // Read the size (big-endian) -#if NET48 - byte[] contentIndexSize = data.ReadBytes(4); -#else byte[]? contentIndexSize = data.ReadBytes(4); -#endif if (contentIndexSize != null) { Array.Reverse(contentIndexSize); @@ -378,11 +350,7 @@ namespace SabreTools.Serialization.Streams /// Stream to parse /// Indicates if the ticket is from CDN /// Filled title metadata on success, null on error -#if NET48 - private static TitleMetadata ParseTitleMetadata(Stream data, bool fromCdn = false) -#else private static TitleMetadata? ParseTitleMetadata(Stream data, bool fromCdn = false) -#endif { // TODO: Use marshalling here instead of building TitleMetadata titleMetadata = new TitleMetadata(); @@ -420,11 +388,7 @@ namespace SabreTools.Serialization.Streams titleMetadata.Signature = data.ReadBytes(titleMetadata.SignatureSize); titleMetadata.Padding1 = data.ReadBytes(titleMetadata.PaddingSize); -#if NET48 - byte[] issuer = data.ReadBytes(0x40); -#else byte[]? issuer = data.ReadBytes(0x40); -#endif if (issuer != null) titleMetadata.Issuer = Encoding.ASCII.GetString(issuer).TrimEnd('\0'); titleMetadata.Version = data.ReadByteValue(); @@ -444,11 +408,7 @@ namespace SabreTools.Serialization.Streams titleMetadata.TitleVersion = data.ReadUInt16(); // Read the content count (big-endian) -#if NET48 - byte[] contentCount = data.ReadBytes(2); -#else byte[]? contentCount = data.ReadBytes(2); -#endif if (contentCount != null) { Array.Reverse(contentCount); diff --git a/Streams/CIA.Serializer.cs b/Streams/CIA.Serializer.cs index a8b53311..aa0d008f 100644 --- a/Streams/CIA.Serializer.cs +++ b/Streams/CIA.Serializer.cs @@ -7,10 +7,6 @@ namespace SabreTools.Serialization.Streams public partial class CIA : IStreamSerializer { /// -#if NET48 - public Stream Serialize(Models.N3DS.CIA obj) => throw new NotImplementedException(); -#else public Stream? Serialize(Models.N3DS.CIA? obj) => throw new NotImplementedException(); -#endif } } \ No newline at end of file diff --git a/Streams/ClrMamePro.Deserializer.cs b/Streams/ClrMamePro.Deserializer.cs index 4c58a5b8..b365e4fa 100644 --- a/Streams/ClrMamePro.Deserializer.cs +++ b/Streams/ClrMamePro.Deserializer.cs @@ -11,18 +11,10 @@ namespace SabreTools.Serialization.Streams public partial class ClrMamePro : IStreamSerializer { /// -#if NET48 - public MetadataFile Deserialize(Stream data) => Deserialize(data, true); -#else public MetadataFile? Deserialize(Stream? data) => Deserialize(data, true); -#endif /// -#if NET48 - public MetadataFile Deserialize(Stream data, bool quotes) -#else public MetadataFile? Deserialize(Stream? data, bool quotes) -#endif { // If the stream is null if (data == null) @@ -33,17 +25,9 @@ namespace SabreTools.Serialization.Streams var dat = new MetadataFile(); // Loop through and parse out the values -#if NET48 - string lastTopLevel = reader.TopLevel; -#else string? lastTopLevel = reader.TopLevel; -#endif -#if NET48 - GameBase game = null; -#else GameBase? game = null; -#endif var games = new List(); var releases = new List(); var biosSets = new List(); @@ -154,11 +138,7 @@ namespace SabreTools.Serialization.Streams && reader.RowType == CmpRowType.Standalone) { // Create the block if we haven't already -#if NET48 - dat.ClrMamePro = dat.ClrMamePro != null ? dat.ClrMamePro : new Models.ClrMamePro.ClrMamePro(); -#else dat.ClrMamePro ??= new Models.ClrMamePro.ClrMamePro(); -#endif switch (reader.Standalone?.Key?.ToLowerInvariant()) { @@ -222,28 +202,6 @@ namespace SabreTools.Serialization.Streams && reader.RowType == CmpRowType.Standalone) { // Create the block if we haven't already -#if NET48 - if (game == null) - { - switch (reader.TopLevel) - { - case "game": - game = new Game(); - break; - case "machine": - game = new Machine(); - break; - case "resource": - game = new Resource(); - break; - case "set": - game = new Set(); - break; - default: - throw new FormatException($"Unknown top-level block: {reader.TopLevel}"); - } - } -#else game ??= reader.TopLevel switch { "game" => new Game(), @@ -252,7 +210,6 @@ namespace SabreTools.Serialization.Streams "set" => new Set(), _ => throw new FormatException($"Unknown top-level block: {reader.TopLevel}"), }; -#endif switch (reader.Standalone?.Key?.ToLowerInvariant()) { @@ -396,11 +353,7 @@ namespace SabreTools.Serialization.Streams /// /// ClrMameProReader representing the metadata file /// Release object created from the reader context -#if NET48 - private static Release CreateRelease(ClrMameProReader reader) -#else private static Release? CreateRelease(ClrMameProReader reader) -#endif { if (reader.Internal == null) return null; @@ -441,11 +394,7 @@ namespace SabreTools.Serialization.Streams /// /// ClrMameProReader representing the metadata file /// BiosSet object created from the reader context -#if NET48 - private static BiosSet CreateBiosSet(ClrMameProReader reader) -#else private static BiosSet? CreateBiosSet(ClrMameProReader reader) -#endif { if (reader.Internal == null) return null; @@ -480,11 +429,7 @@ namespace SabreTools.Serialization.Streams /// /// ClrMameProReader representing the metadata file /// Rom object created from the reader context -#if NET48 - private static Rom CreateRom(ClrMameProReader reader) -#else private static Rom? CreateRom(ClrMameProReader reader) -#endif { if (reader.Internal == null) return null; @@ -573,11 +518,7 @@ namespace SabreTools.Serialization.Streams /// /// ClrMameProReader representing the metadata file /// Disk object created from the reader context -#if NET48 - private static Disk CreateDisk(ClrMameProReader reader) -#else private static Disk? CreateDisk(ClrMameProReader reader) -#endif { if (reader.Internal == null) return null; @@ -621,11 +562,7 @@ namespace SabreTools.Serialization.Streams /// /// ClrMameProReader representing the metadata file /// Media object created from the reader context -#if NET48 - private static Media CreateMedia(ClrMameProReader reader) -#else private static Media? CreateMedia(ClrMameProReader reader) -#endif { if (reader.Internal == null) return null; @@ -666,11 +603,7 @@ namespace SabreTools.Serialization.Streams /// /// ClrMameProReader representing the metadata file /// Sample object created from the reader context -#if NET48 - private static Sample CreateSample(ClrMameProReader reader) -#else private static Sample? CreateSample(ClrMameProReader reader) -#endif { if (reader.Internal == null) return null; @@ -699,11 +632,7 @@ namespace SabreTools.Serialization.Streams /// /// ClrMameProReader representing the metadata file /// Archive object created from the reader context -#if NET48 - private static Archive CreateArchive(ClrMameProReader reader) -#else private static Archive? CreateArchive(ClrMameProReader reader) -#endif { if (reader.Internal == null) return null; @@ -732,11 +661,7 @@ namespace SabreTools.Serialization.Streams /// /// ClrMameProReader representing the metadata file /// Chip object created from the reader context -#if NET48 - private static Chip CreateChip(ClrMameProReader reader) -#else private static Chip? CreateChip(ClrMameProReader reader) -#endif { if (reader.Internal == null) return null; @@ -774,11 +699,7 @@ namespace SabreTools.Serialization.Streams /// /// ClrMameProReader representing the metadata file /// Video object created from the reader context -#if NET48 - private static Video CreateVideo(ClrMameProReader reader) -#else private static Video? CreateVideo(ClrMameProReader reader) -#endif { if (reader.Internal == null) return null; @@ -825,11 +746,7 @@ namespace SabreTools.Serialization.Streams /// /// ClrMameProReader representing the metadata file /// Sound object created from the reader context -#if NET48 - private static Sound CreateSound(ClrMameProReader reader) -#else private static Sound? CreateSound(ClrMameProReader reader) -#endif { if (reader.Internal == null) return null; @@ -858,11 +775,7 @@ namespace SabreTools.Serialization.Streams /// /// ClrMameProReader representing the metadata file /// Input object created from the reader context -#if NET48 - private static Input CreateInput(ClrMameProReader reader) -#else private static Input? CreateInput(ClrMameProReader reader) -#endif { if (reader.Internal == null) return null; @@ -906,11 +819,7 @@ namespace SabreTools.Serialization.Streams /// /// ClrMameProReader representing the metadata file /// DipSwitch object created from the reader context -#if NET48 - private static DipSwitch CreateDipSwitch(ClrMameProReader reader) -#else private static DipSwitch? CreateDipSwitch(ClrMameProReader reader) -#endif { if (reader.Internal == null) return null; @@ -947,11 +856,7 @@ namespace SabreTools.Serialization.Streams /// /// ClrMameProReader representing the metadata file /// Driver object created from the reader context -#if NET48 - private static Driver CreateDriver(ClrMameProReader reader) -#else private static Driver? CreateDriver(ClrMameProReader reader) -#endif { if (reader.Internal == null) return null; diff --git a/Streams/ClrMamePro.Serializer.cs b/Streams/ClrMamePro.Serializer.cs index 8b1890a6..d503b0cf 100644 --- a/Streams/ClrMamePro.Serializer.cs +++ b/Streams/ClrMamePro.Serializer.cs @@ -11,18 +11,10 @@ namespace SabreTools.Serialization.Streams public partial class ClrMamePro : IStreamSerializer { /// -#if NET48 - public Stream Serialize(MetadataFile obj) => Serialize(obj, true); -#else public Stream? Serialize(MetadataFile? obj) => Serialize(obj, true); -#endif /// -#if NET48 - public Stream Serialize(MetadataFile obj, bool quotes) -#else public Stream? Serialize(MetadataFile? obj, bool quotes) -#endif { // If the metadata file is null if (obj == null) @@ -48,11 +40,7 @@ namespace SabreTools.Serialization.Streams /// /// ClrMamePro representing the header information /// ClrMameProWriter representing the output -#if NET48 - private static void WriteHeader(Models.ClrMamePro.ClrMamePro header, ClrMameProWriter writer) -#else private static void WriteHeader(Models.ClrMamePro.ClrMamePro? header, ClrMameProWriter writer) -#endif { // If the header information is missing, we can't do anything if (header == null) @@ -85,11 +73,7 @@ namespace SabreTools.Serialization.Streams /// /// Array of GameBase objects representing the games information /// ClrMameProWriter representing the output -#if NET48 - private static void WriteGames(GameBase[] games, ClrMameProWriter writer) -#else private static void WriteGames(GameBase?[]? games, ClrMameProWriter writer) -#endif { // If the games information is missing, we can't do anything if (games == null || !games.Any()) @@ -117,16 +101,6 @@ namespace SabreTools.Serialization.Streams if (game == null) return; -#if NET48 - if (game is Game) - writer.WriteStartElement("game"); - else if (game is Machine) - writer.WriteStartElement("machine"); - else if (game is Resource) - writer.WriteStartElement("resource"); - else if (game is Set) - writer.WriteStartElement(name: "set"); -#else switch (game) { case Game: @@ -142,7 +116,6 @@ namespace SabreTools.Serialization.Streams writer.WriteStartElement(name: "set"); break; } -#endif // Write the standalone values writer.WriteRequiredStandalone("name", game.Name, throwOnError: true); @@ -177,11 +150,7 @@ namespace SabreTools.Serialization.Streams /// /// Array of Release objects to write /// ClrMameProWriter representing the output -#if NET48 - private static void WriteReleases(Release[] releases, ClrMameProWriter writer) -#else private static void WriteReleases(Release[]? releases, ClrMameProWriter writer) -#endif { // If the array is missing, we can't do anything if (releases == null) @@ -204,11 +173,7 @@ namespace SabreTools.Serialization.Streams /// /// Array of BiosSet objects to write /// ClrMameProWriter representing the output -#if NET48 - private static void WriteBiosSets(BiosSet[] biossets, ClrMameProWriter writer) -#else private static void WriteBiosSets(BiosSet[]? biossets, ClrMameProWriter writer) -#endif { // If the array is missing, we can't do anything if (biossets == null) @@ -229,11 +194,7 @@ namespace SabreTools.Serialization.Streams /// /// Array of Rom objects to write /// ClrMameProWriter representing the output -#if NET48 - private static void WriteRoms(Rom[] roms, ClrMameProWriter writer) -#else private static void WriteRoms(Rom[]? roms, ClrMameProWriter writer) -#endif { // If the array is missing, we can't do anything if (roms == null) @@ -272,11 +233,7 @@ namespace SabreTools.Serialization.Streams /// /// Array of Disk objects to write /// ClrMameProWriter representing the output -#if NET48 - private static void WriteDisks(Disk[] disks, ClrMameProWriter writer) -#else private static void WriteDisks(Disk[]? disks, ClrMameProWriter writer) -#endif { // If the array is missing, we can't do anything if (disks == null) @@ -300,11 +257,7 @@ namespace SabreTools.Serialization.Streams /// /// Array of Media objects to write /// ClrMameProWriter representing the output -#if NET48 - private static void WriteMedia(Media[] medias, ClrMameProWriter writer) -#else private static void WriteMedia(Media[]? medias, ClrMameProWriter writer) -#endif { // If the array is missing, we can't do anything if (medias == null) @@ -327,11 +280,7 @@ namespace SabreTools.Serialization.Streams /// /// Array of Sample objects to write /// ClrMameProWriter representing the output -#if NET48 - private static void WriteSamples(Sample[] samples, ClrMameProWriter writer) -#else private static void WriteSamples(Sample[]? samples, ClrMameProWriter writer) -#endif { // If the array is missing, we can't do anything if (samples == null) @@ -350,11 +299,7 @@ namespace SabreTools.Serialization.Streams /// /// Array of Archive objects to write /// ClrMameProWriter representing the output -#if NET48 - private static void WriteArchives(Archive[] archives, ClrMameProWriter writer) -#else private static void WriteArchives(Archive[]? archives, ClrMameProWriter writer) -#endif { // If the array is missing, we can't do anything if (archives == null) @@ -373,11 +318,7 @@ namespace SabreTools.Serialization.Streams /// /// Array of Chip objects to write /// ClrMameProWriter representing the output -#if NET48 - private static void WriteChips(Chip[] chips, ClrMameProWriter writer) -#else private static void WriteChips(Chip[]? chips, ClrMameProWriter writer) -#endif { // If the array is missing, we can't do anything if (chips == null) @@ -399,11 +340,7 @@ namespace SabreTools.Serialization.Streams /// /// Array of Video objects to write /// ClrMameProWriter representing the output -#if NET48 - private static void WriteVideos(Video[] videos, ClrMameProWriter writer) -#else private static void WriteVideos(Video[]? videos, ClrMameProWriter writer) -#endif { // If the item is missing, we can't do anything if (videos == null) @@ -428,11 +365,7 @@ namespace SabreTools.Serialization.Streams /// /// Sound object to write /// ClrMameProWriter representing the output -#if NET48 - private static void WriteSound(Sound sound, ClrMameProWriter writer) -#else private static void WriteSound(Sound? sound, ClrMameProWriter writer) -#endif { // If the item is missing, we can't do anything if (sound == null) @@ -448,11 +381,7 @@ namespace SabreTools.Serialization.Streams /// /// Input object to write /// ClrMameProWriter representing the output -#if NET48 - private static void WriteInput(Input input, ClrMameProWriter writer) -#else private static void WriteInput(Input? input, ClrMameProWriter writer) -#endif { // If the item is missing, we can't do anything if (input == null) @@ -473,11 +402,7 @@ namespace SabreTools.Serialization.Streams /// /// Array of DipSwitch objects to write /// ClrMameProWriter representing the output -#if NET48 - private static void WriteDipSwitches(DipSwitch[] dipswitches, ClrMameProWriter writer) -#else private static void WriteDipSwitches(DipSwitch[]? dipswitches, ClrMameProWriter writer) -#endif { // If the array is missing, we can't do anything if (dipswitches == null) @@ -501,11 +426,7 @@ namespace SabreTools.Serialization.Streams /// /// Driver object to write /// ClrMameProWriter representing the output -#if NET48 - private static void WriteDriver(Driver driver, ClrMameProWriter writer) -#else private static void WriteDriver(Driver? driver, ClrMameProWriter writer) -#endif { // If the item is missing, we can't do anything if (driver == null) diff --git a/Streams/CueSheet.Deserializer.cs b/Streams/CueSheet.Deserializer.cs index 18746e45..8b3384b5 100644 --- a/Streams/CueSheet.Deserializer.cs +++ b/Streams/CueSheet.Deserializer.cs @@ -7,10 +7,6 @@ namespace SabreTools.Serialization.Streams public partial class CueSheet : IStreamSerializer { /// -#if NET48 - public Models.CueSheets.CueSheet Deserialize(Stream data) => throw new NotImplementedException(); -#else public Models.CueSheets.CueSheet? Deserialize(Stream? data) => throw new NotImplementedException(); -#endif } } \ No newline at end of file diff --git a/Streams/CueSheet.Serializer.cs b/Streams/CueSheet.Serializer.cs index 17ef6ac6..725b4d65 100644 --- a/Streams/CueSheet.Serializer.cs +++ b/Streams/CueSheet.Serializer.cs @@ -9,11 +9,7 @@ namespace SabreTools.Serialization.Streams public partial class CueSheet : IStreamSerializer { /// -#if NET48 - public Stream Serialize(Models.CueSheets.CueSheet obj) -#else public Stream? Serialize(Models.CueSheets.CueSheet? obj) -#endif { // If the cuesheet is null if (obj == null) @@ -78,11 +74,7 @@ namespace SabreTools.Serialization.Streams /// /// CueFile to write /// StreamWriter to write to -#if NET48 - private static void WriteCueFile(CueFile cueFile, StreamWriter sw) -#else private static void WriteCueFile(CueFile? cueFile, StreamWriter sw) -#endif { // If we don't have any tracks, it's invalid if (cueFile?.Tracks == null) @@ -103,11 +95,7 @@ namespace SabreTools.Serialization.Streams /// /// CueFile to write /// StreamWriter to write to -#if NET48 - private static void WriteCueTrack(CueTrack cueTrack, StreamWriter sw) -#else private static void WriteCueTrack(CueTrack? cueTrack, StreamWriter sw) -#endif { // If we don't have any indices, it's invalid if (cueTrack?.Indices == null) @@ -159,11 +147,7 @@ namespace SabreTools.Serialization.Streams /// /// CueIndex to write /// StreamWriter to write to -#if NET48 - private static void WriteCueIndex(CueIndex cueIndex, StreamWriter sw) -#else private static void WriteCueIndex(CueIndex? cueIndex, StreamWriter sw) -#endif { if (cueIndex == null) throw new ArgumentNullException(nameof(cueIndex)); diff --git a/Streams/DosCenter.Deserializer.cs b/Streams/DosCenter.Deserializer.cs index 78cc56eb..b91678e9 100644 --- a/Streams/DosCenter.Deserializer.cs +++ b/Streams/DosCenter.Deserializer.cs @@ -10,11 +10,7 @@ namespace SabreTools.Serialization.Streams public partial class DosCenter : IStreamSerializer { /// -#if NET48 - public MetadataFile Deserialize(Stream data) -#else public MetadataFile? Deserialize(Stream? data) -#endif { // If the stream is null if (data == null) @@ -25,17 +21,9 @@ namespace SabreTools.Serialization.Streams var dat = new MetadataFile(); // Loop through and parse out the values -#if NET48 - string lastTopLevel = reader.TopLevel; -#else string? lastTopLevel = reader.TopLevel; -#endif -#if NET48 - Game game = null; -#else Game? game = null; -#endif var games = new List(); var files = new List(); @@ -105,11 +93,7 @@ namespace SabreTools.Serialization.Streams else if (reader.TopLevel == "doscenter" && reader.RowType == CmpRowType.Standalone) { // Create the block if we haven't already -#if NET48 - dat.DosCenter = dat.DosCenter != null ? dat.DosCenter : new Models.DosCenter.DosCenter(); -#else dat.DosCenter ??= new Models.DosCenter.DosCenter(); -#endif switch (reader.Standalone?.Key?.ToLowerInvariant()) { @@ -145,11 +129,7 @@ namespace SabreTools.Serialization.Streams else if (reader.TopLevel == "game" && reader.RowType == CmpRowType.Standalone) { // Create the block if we haven't already -#if NET48 - game = game != null ? game : new Game(); -#else game ??= new Game(); -#endif switch (reader.Standalone?.Key?.ToLowerInvariant()) { @@ -198,11 +178,7 @@ namespace SabreTools.Serialization.Streams /// /// ClrMameProReader representing the metadata file /// File object created from the reader context -#if NET48 - private static Models.DosCenter.File CreateFile(ClrMameProReader reader) -#else private static Models.DosCenter.File? CreateFile(ClrMameProReader reader) -#endif { if (reader.Internal == null) return null; diff --git a/Streams/DosCenter.Serializer.cs b/Streams/DosCenter.Serializer.cs index 7b8b8b80..644c5825 100644 --- a/Streams/DosCenter.Serializer.cs +++ b/Streams/DosCenter.Serializer.cs @@ -10,11 +10,7 @@ namespace SabreTools.Serialization.Streams public partial class DosCenter : IStreamSerializer { /// -#if NET48 - public Stream Serialize(MetadataFile obj) -#else public Stream? Serialize(MetadataFile? obj) -#endif { // If the metadata file is null if (obj == null) @@ -43,11 +39,7 @@ namespace SabreTools.Serialization.Streams /// /// DosCenter representing the header information /// ClrMameProWriter representing the output -#if NET48 - private static void WriteHeader(Models.DosCenter.DosCenter header, ClrMameProWriter writer) -#else private static void WriteHeader(Models.DosCenter.DosCenter? header, ClrMameProWriter writer) -#endif { // If the header information is missing, we can't do anything if (header == null) @@ -72,11 +64,7 @@ namespace SabreTools.Serialization.Streams /// /// Array of Game objects representing the games information /// ClrMameProWriter representing the output -#if NET48 - private static void WriteGames(Game[] games, ClrMameProWriter writer) -#else private static void WriteGames(Game[]? games, ClrMameProWriter writer) -#endif { // If the games information is missing, we can't do anything if (games == null || !games.Any()) @@ -117,11 +105,7 @@ namespace SabreTools.Serialization.Streams /// /// Array of File objects to write /// ClrMameProWriter representing the output -#if NET48 - private static void WriteFiles(Models.DosCenter.File[] files, ClrMameProWriter writer) -#else private static void WriteFiles(Models.DosCenter.File[]? files, ClrMameProWriter writer) -#endif { // If the array is missing, we can't do anything if (files == null) diff --git a/Streams/EverdriveSMDB.Deserializer.cs b/Streams/EverdriveSMDB.Deserializer.cs index 6fcc90d3..7b587196 100644 --- a/Streams/EverdriveSMDB.Deserializer.cs +++ b/Streams/EverdriveSMDB.Deserializer.cs @@ -11,11 +11,7 @@ namespace SabreTools.Serialization.Streams public partial class EverdriveSMDB : IStreamSerializer { /// -#if NET48 - public MetadataFile Deserialize(Stream data) -#else public MetadataFile? Deserialize(Stream? data) -#endif { // If the stream is null if (data == null) diff --git a/Streams/EverdriveSMDB.Serializer.cs b/Streams/EverdriveSMDB.Serializer.cs index 64c0b414..51712e99 100644 --- a/Streams/EverdriveSMDB.Serializer.cs +++ b/Streams/EverdriveSMDB.Serializer.cs @@ -11,11 +11,7 @@ namespace SabreTools.Serialization.Streams public partial class EverdriveSMDB : IStreamSerializer { /// -#if NET48 - public Stream Serialize(MetadataFile obj) -#else public Stream? Serialize(MetadataFile? obj) -#endif { // If the metadata file is null if (obj == null) @@ -38,11 +34,7 @@ namespace SabreTools.Serialization.Streams /// /// Array of Row objects representing the rows information /// SeparatedValueWriter representing the output -#if NET48 - private static void WriteRows(Row[] rows, SeparatedValueWriter writer) -#else private static void WriteRows(Row[]? rows, SeparatedValueWriter writer) -#endif { // If the games information is missing, we can't do anything if (rows == null || !rows.Any()) @@ -54,11 +46,7 @@ namespace SabreTools.Serialization.Streams if (row == null) continue; -#if NET48 - var rowArray = new List -#else var rowArray = new List -#endif { row.SHA256, row.Name, diff --git a/Streams/GCF.Deserializer.cs b/Streams/GCF.Deserializer.cs index 035ee375..ba37922b 100644 --- a/Streams/GCF.Deserializer.cs +++ b/Streams/GCF.Deserializer.cs @@ -10,11 +10,7 @@ namespace SabreTools.Serialization.Streams public partial class GCF : IStreamSerializer { /// -#if NET48 - public Models.GCF.File Deserialize(Stream data) -#else public Models.GCF.File? Deserialize(Stream? data) -#endif { // If the data is invalid if (data == null || data.Length == 0 || !data.CanSeek || !data.CanRead) @@ -114,11 +110,7 @@ namespace SabreTools.Serialization.Streams if (header.MinorVersion < 6) { // Create the block entry map array -#if NET48 - file.BlockEntryMaps = new BlockEntryMap[file.BlockEntryMapHeader.BlockCount]; -#else file.BlockEntryMaps = new BlockEntryMap[file.BlockEntryMapHeader!.BlockCount]; -#endif // Try to parse the block entry maps for (int i = 0; i < file.BlockEntryMapHeader.BlockCount; i++) @@ -170,29 +162,17 @@ namespace SabreTools.Serialization.Streams long directoryNamesEnd = data.Position + directoryHeader.NameSize; // Create the string dictionary -#if NET48 - file.DirectoryNames = new Dictionary(); -#else file.DirectoryNames = new Dictionary(); -#endif // Loop and read the null-terminated strings while (data.Position < directoryNamesEnd) { long nameOffset = data.Position - directoryNamesStart; -#if NET48 - string directoryName = data.ReadString(Encoding.ASCII); -#else string? directoryName = data.ReadString(Encoding.ASCII); -#endif if (data.Position > directoryNamesEnd) { data.Seek(-directoryName?.Length ?? 0, SeekOrigin.Current); -#if NET48 - byte[] endingData = data.ReadBytes((int)(directoryNamesEnd - data.Position)); -#else byte[]? endingData = data.ReadBytes((int)(directoryNamesEnd - data.Position)); -#endif if (endingData != null) directoryName = Encoding.ASCII.GetString(endingData); else @@ -378,11 +358,7 @@ namespace SabreTools.Serialization.Streams /// /// Stream to parse /// Filled Half-Life Game Cache on success, null on error -#if NET48 - private static Header ParseHeader(Stream data) -#else private static Header? ParseHeader(Stream data) -#endif { // TODO: Use marshalling here instead of building Header header = new Header(); @@ -636,11 +612,7 @@ namespace SabreTools.Serialization.Streams /// /// Stream to parse /// Filled Half-Life Game Cache directory map header on success, null on error -#if NET48 - private static DirectoryMapHeader ParseDirectoryMapHeader(Stream data) -#else private static DirectoryMapHeader? ParseDirectoryMapHeader(Stream data) -#endif { // TODO: Use marshalling here instead of building DirectoryMapHeader directoryMapHeader = new DirectoryMapHeader(); @@ -676,11 +648,7 @@ namespace SabreTools.Serialization.Streams /// /// Stream to parse /// Filled Half-Life Game Cache checksum header on success, null on error -#if NET48 - private static ChecksumHeader ParseChecksumHeader(Stream data) -#else private static ChecksumHeader? ParseChecksumHeader(Stream data) -#endif { // TODO: Use marshalling here instead of building ChecksumHeader checksumHeader = new ChecksumHeader(); @@ -699,11 +667,7 @@ namespace SabreTools.Serialization.Streams /// /// Stream to parse /// Filled Half-Life Game Cache checksum map header on success, null on error -#if NET48 - private static ChecksumMapHeader ParseChecksumMapHeader(Stream data) -#else private static ChecksumMapHeader? ParseChecksumMapHeader(Stream data) -#endif { // TODO: Use marshalling here instead of building ChecksumMapHeader checksumMapHeader = new ChecksumMapHeader(); diff --git a/Streams/GCF.Serializer.cs b/Streams/GCF.Serializer.cs index c9e4e660..e4f1ec5c 100644 --- a/Streams/GCF.Serializer.cs +++ b/Streams/GCF.Serializer.cs @@ -7,10 +7,6 @@ namespace SabreTools.Serialization.Streams public partial class GCF : IStreamSerializer { /// -#if NET48 - public Stream Serialize(Models.GCF.File obj) => throw new NotImplementedException(); -#else public Stream? Serialize(Models.GCF.File? obj) => throw new NotImplementedException(); -#endif } } \ No newline at end of file diff --git a/Streams/HashFile.Deserializer.cs b/Streams/HashFile.Deserializer.cs index 98453420..a7ab7115 100644 --- a/Streams/HashFile.Deserializer.cs +++ b/Streams/HashFile.Deserializer.cs @@ -10,18 +10,10 @@ namespace SabreTools.Serialization.Streams public partial class Hashfile : IStreamSerializer { /// -#if NET48 - public Models.Hashfile.Hashfile Deserialize(Stream data) => Deserialize(data, Hash.CRC); -#else public Models.Hashfile.Hashfile? Deserialize(Stream? data) => Deserialize(data, Hash.CRC); -#endif /// -#if NET48 - public Models.Hashfile.Hashfile Deserialize(Stream data, Hash hash) -#else public Models.Hashfile.Hashfile? Deserialize(Stream? data, Hash hash) -#endif { // If the stream is null if (data == null) @@ -37,11 +29,10 @@ namespace SabreTools.Serialization.Streams while (!reader.EndOfStream) { // Read and split the line -#if NET48 - string line = reader.ReadLine(); - string[] lineParts = line?.Split(new char[] { ' ' } , StringSplitOptions.RemoveEmptyEntries); -#else string? line = reader.ReadLine(); +#if NETFRAMEWORK + string[]? lineParts = line?.Split(new char[] { ' ' } , StringSplitOptions.RemoveEmptyEntries); +#else string[]? lineParts = line?.Split(' ', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries); #endif if (lineParts == null) @@ -53,7 +44,7 @@ namespace SabreTools.Serialization.Streams case Hash.CRC: var sfv = new SFV { -#if NET48 +#if NETFRAMEWORK File = string.Join(" ", lineParts.Take(lineParts.Length - 1)), Hash = lineParts[lineParts.Length - 1], #else @@ -67,7 +58,7 @@ namespace SabreTools.Serialization.Streams var md5 = new MD5 { Hash = lineParts[0], -#if NET48 +#if NETFRAMEWORK File = string.Join(" ", lineParts.Skip(1)), #else File = string.Join(" ", lineParts[1..]), @@ -79,7 +70,7 @@ namespace SabreTools.Serialization.Streams var sha1 = new SHA1 { Hash = lineParts[0], -#if NET48 +#if NETFRAMEWORK File = string.Join(" ", lineParts.Skip(1)), #else File = string.Join(" ", lineParts[1..]), @@ -91,7 +82,7 @@ namespace SabreTools.Serialization.Streams var sha256 = new SHA256 { Hash = lineParts[0], -#if NET48 +#if NETFRAMEWORK File = string.Join(" ", lineParts.Skip(1)), #else File = string.Join(" ", lineParts[1..]), @@ -103,7 +94,7 @@ namespace SabreTools.Serialization.Streams var sha384 = new SHA384 { Hash = lineParts[0], -#if NET48 +#if NETFRAMEWORK File = string.Join(" ", lineParts.Skip(1)), #else File = string.Join(" ", lineParts[1..]), @@ -115,7 +106,7 @@ namespace SabreTools.Serialization.Streams var sha512 = new SHA512 { Hash = lineParts[0], -#if NET48 +#if NETFRAMEWORK File = string.Join(" ", lineParts.Skip(1)), #else File = string.Join(" ", lineParts[1..]), @@ -127,7 +118,7 @@ namespace SabreTools.Serialization.Streams var spamSum = new SpamSum { Hash = lineParts[0], -#if NET48 +#if NETFRAMEWORK File = string.Join(" ", lineParts.Skip(1)), #else File = string.Join(" ", lineParts[1..]), diff --git a/Streams/Hashfile.Serializer.cs b/Streams/Hashfile.Serializer.cs index 467eca70..4b94ad97 100644 --- a/Streams/Hashfile.Serializer.cs +++ b/Streams/Hashfile.Serializer.cs @@ -11,18 +11,10 @@ namespace SabreTools.Serialization.Streams public partial class Hashfile : IStreamSerializer { /// -#if NET48 - public Stream Serialize(Models.Hashfile.Hashfile obj) => Serialize(obj, Hash.CRC); -#else public Stream? Serialize(Models.Hashfile.Hashfile? obj) => Serialize(obj, Hash.CRC); -#endif /// -#if NET48 - public Stream Serialize(Models.Hashfile.Hashfile obj, Hash hash) -#else public Stream? Serialize(Models.Hashfile.Hashfile? obj, Hash hash) -#endif { // If the metadata file is null if (obj == null) @@ -75,11 +67,7 @@ namespace SabreTools.Serialization.Streams /// /// Array of SFV objects representing the files /// SeparatedValueWriter representing the output -#if NET48 - private static void WriteSFV(SFV[] sfvs, SeparatedValueWriter writer) -#else private static void WriteSFV(SFV[]? sfvs, SeparatedValueWriter writer) -#endif { // If the item information is missing, we can't do anything if (sfvs == null || !sfvs.Any()) @@ -103,11 +91,7 @@ namespace SabreTools.Serialization.Streams /// /// Array of MD5 objects representing the files /// SeparatedValueWriter representing the output -#if NET48 - private static void WriteMD5(MD5[] md5s, SeparatedValueWriter writer) -#else private static void WriteMD5(MD5[]? md5s, SeparatedValueWriter writer) -#endif { // If the item information is missing, we can't do anything if (md5s == null || !md5s.Any()) @@ -131,11 +115,7 @@ namespace SabreTools.Serialization.Streams /// /// Array of SHA1 objects representing the files /// SeparatedValueWriter representing the output -#if NET48 - private static void WriteSHA1(SHA1[] sha1s, SeparatedValueWriter writer) -#else private static void WriteSHA1(SHA1[]? sha1s, SeparatedValueWriter writer) -#endif { // If the item information is missing, we can't do anything if (sha1s == null || !sha1s.Any()) @@ -159,11 +139,7 @@ namespace SabreTools.Serialization.Streams /// /// Array of SHA256 objects representing the files /// SeparatedValueWriter representing the output -#if NET48 - private static void WriteSHA256(SHA256[] sha256s, SeparatedValueWriter writer) -#else private static void WriteSHA256(SHA256[]? sha256s, SeparatedValueWriter writer) -#endif { // If the item information is missing, we can't do anything if (sha256s == null || !sha256s.Any()) @@ -187,11 +163,7 @@ namespace SabreTools.Serialization.Streams /// /// Array of SHA384 objects representing the files /// SeparatedValueWriter representing the output -#if NET48 - private static void WriteSHA384(SHA384[] sha384s, SeparatedValueWriter writer) -#else private static void WriteSHA384(SHA384[]? sha384s, SeparatedValueWriter writer) -#endif { // If the item information is missing, we can't do anything if (sha384s == null || !sha384s.Any()) @@ -215,11 +187,7 @@ namespace SabreTools.Serialization.Streams /// /// Array of SHA512 objects representing the files /// SeparatedValueWriter representing the output -#if NET48 - private static void WriteSHA512(SHA512[] sha512s, SeparatedValueWriter writer) -#else private static void WriteSHA512(SHA512[]? sha512s, SeparatedValueWriter writer) -#endif { // If the item information is missing, we can't do anything if (sha512s == null || !sha512s.Any()) @@ -243,11 +211,7 @@ namespace SabreTools.Serialization.Streams /// /// Array of SpamSum objects representing the files /// SeparatedValueWriter representing the output -#if NET48 - private static void WriteSpamSum(SpamSum[] spamsums, SeparatedValueWriter writer) -#else private static void WriteSpamSum(SpamSum[]? spamsums, SeparatedValueWriter writer) -#endif { // If the item information is missing, we can't do anything if (spamsums == null || !spamsums.Any()) diff --git a/Streams/IRD.Deserializer.cs b/Streams/IRD.Deserializer.cs index 69e7846a..d805bd09 100644 --- a/Streams/IRD.Deserializer.cs +++ b/Streams/IRD.Deserializer.cs @@ -9,11 +9,7 @@ namespace SabreTools.Serialization.Streams public partial class IRD : IStreamSerializer { /// -#if NET48 - public Models.IRD.IRD Deserialize(Stream data) -#else public Models.IRD.IRD? Deserialize(Stream? data) -#endif { // If the data is invalid if (data == null || data.Length == 0 || !data.CanSeek || !data.CanRead) diff --git a/Streams/IRD.Serializer.cs b/Streams/IRD.Serializer.cs index 061c4885..ede35c46 100644 --- a/Streams/IRD.Serializer.cs +++ b/Streams/IRD.Serializer.cs @@ -9,11 +9,7 @@ namespace SabreTools.Serialization.Streams public partial class IRD : IStreamSerializer { /// -#if NET48 - public Stream Serialize(Models.IRD.IRD obj) -#else public Stream? Serialize(Models.IRD.IRD? obj) -#endif { // If the data is invalid if (obj?.Magic == null) diff --git a/Streams/InstallShieldCabinet.Deserializer.cs b/Streams/InstallShieldCabinet.Deserializer.cs index e3dae781..32d5249c 100644 --- a/Streams/InstallShieldCabinet.Deserializer.cs +++ b/Streams/InstallShieldCabinet.Deserializer.cs @@ -12,11 +12,7 @@ namespace SabreTools.Serialization.Streams public partial class InstallShieldCabinet : IStreamSerializer { /// -#if NET48 - public Cabinet Deserialize(Stream data) -#else public Cabinet? Deserialize(Stream? data) -#endif { // If the data is invalid if (data == null || data.Length == 0 || !data.CanSeek || !data.CanRead) @@ -121,11 +117,7 @@ namespace SabreTools.Serialization.Streams data.Seek(offset, SeekOrigin.Begin); // Create and add the file descriptor -#if NET48 - string directoryName = ParseDirectoryName(data, GetMajorVersion(commonHeader)); -#else string? directoryName = ParseDirectoryName(data, GetMajorVersion(commonHeader)); -#endif if (directoryName != null) cabinet.DirectoryNames[i] = directoryName; } @@ -171,19 +163,11 @@ namespace SabreTools.Serialization.Streams #region File Group Offsets // Create and fill the file group offsets -#if NET48 - cabinet.FileGroupOffsets = new Dictionary(); -#else cabinet.FileGroupOffsets = new Dictionary(); -#endif for (int i = 0; i < (descriptor.FileGroupOffsets?.Length ?? 0); i++) { // Get the file group offset -#if NET48 - uint offset = descriptor.FileGroupOffsets[i]; -#else uint offset = descriptor.FileGroupOffsets![i]; -#endif if (offset == 0) continue; @@ -230,11 +214,7 @@ namespace SabreTools.Serialization.Streams foreach (var kvp in cabinet.FileGroupOffsets) { // Get the offset -#if NET48 - OffsetList list = kvp.Value; -#else OffsetList? list = kvp.Value; -#endif if (list == null) { fileGroupId++; @@ -265,19 +245,11 @@ namespace SabreTools.Serialization.Streams #region Component Offsets // Create and fill the component offsets -#if NET48 - cabinet.ComponentOffsets = new Dictionary(); -#else cabinet.ComponentOffsets = new Dictionary(); -#endif for (int i = 0; i < (descriptor.ComponentOffsets?.Length ?? 0); i++) { // Get the component offset -#if NET48 - uint offset = descriptor.ComponentOffsets[i]; -#else uint offset = descriptor.ComponentOffsets![i]; -#endif if (offset == 0) continue; @@ -321,18 +293,10 @@ namespace SabreTools.Serialization.Streams // Create and fill the components int componentId = 0; -#if NET48 - foreach (KeyValuePair kvp in cabinet.ComponentOffsets) -#else foreach (KeyValuePair kvp in cabinet.ComponentOffsets) -#endif { // Get the offset -#if NET48 - OffsetList list = kvp.Value; -#else OffsetList? list = kvp.Value; -#endif if (list == null) { componentId++; @@ -370,19 +334,11 @@ namespace SabreTools.Serialization.Streams /// /// Stream to parse /// Filled common header on success, null on error -#if NET48 - private static CommonHeader ParseCommonHeader(Stream data) -#else private static CommonHeader? ParseCommonHeader(Stream data) -#endif { CommonHeader commonHeader = new CommonHeader(); -#if NET48 - byte[] signature = data.ReadBytes(4); -#else byte[]? signature = data.ReadBytes(4); -#endif if (signature == null) return null; @@ -722,11 +678,7 @@ namespace SabreTools.Serialization.Streams /// Stream to parse /// Major version of the cabinet /// Filled directory name on success, null on error -#if NET48 - private static string ParseDirectoryName(Stream data, int majorVersion) -#else private static string? ParseDirectoryName(Stream data, int majorVersion) -#endif { // Read the string if (majorVersion >= 17) diff --git a/Streams/InstallShieldCabinet.Serializer.cs b/Streams/InstallShieldCabinet.Serializer.cs index 87453881..23b4089d 100644 --- a/Streams/InstallShieldCabinet.Serializer.cs +++ b/Streams/InstallShieldCabinet.Serializer.cs @@ -8,10 +8,6 @@ namespace SabreTools.Serialization.Streams public partial class InstallShieldCabinet : IStreamSerializer { /// -#if NET48 - public Stream Serialize(Cabinet obj) => throw new NotImplementedException(); -#else public Stream? Serialize(Cabinet? obj) => throw new NotImplementedException(); -#endif } } \ No newline at end of file diff --git a/Streams/LinearExecutable.Deserializer.cs b/Streams/LinearExecutable.Deserializer.cs index b5afe1b9..b0764b16 100644 --- a/Streams/LinearExecutable.Deserializer.cs +++ b/Streams/LinearExecutable.Deserializer.cs @@ -11,11 +11,7 @@ namespace SabreTools.Serialization.Streams public partial class LinearExecutable : IStreamSerializer { /// -#if NET48 - public Executable Deserialize(Stream data) -#else public Executable? Deserialize(Stream? data) -#endif { // If the data is invalid if (data == null || data.Length == 0 || !data.CanSeek || !data.CanRead) @@ -428,20 +424,12 @@ namespace SabreTools.Serialization.Streams /// /// Stream to parse /// Filled information block on success, null on error -#if NET48 - private static InformationBlock ParseInformationBlock(Stream data) -#else private static InformationBlock? ParseInformationBlock(Stream data) -#endif { // TODO: Use marshalling here instead of building var informationBlock = new InformationBlock(); -#if NET48 - byte[] magic = data.ReadBytes(2); -#else byte[]? magic = data.ReadBytes(2); -#endif if (magic == null) return null; @@ -567,11 +555,7 @@ namespace SabreTools.Serialization.Streams entry.Length = data.ReadByteValue(); if (entry.Length > 0) { -#if NET48 - byte[] name = data.ReadBytes(entry.Length); -#else byte[]? name = data.ReadBytes(entry.Length); -#endif if (name != null) entry.Name = Encoding.ASCII.GetString(name).TrimEnd('\0'); } @@ -585,11 +569,7 @@ namespace SabreTools.Serialization.Streams /// /// Stream to parse /// Filled entry table bundle on success, null on error -#if NET48 - private static EntryTableBundle ParseEntryTableBundle(Stream data) -#else private static EntryTableBundle? ParseEntryTableBundle(Stream data) -#endif { // TODO: Use marshalling here instead of building var bundle = new EntryTableBundle(); @@ -705,11 +685,7 @@ namespace SabreTools.Serialization.Streams /// /// Stream to parse /// Filled fix-up record table entry on success, null on error -#if NET48 - private static FixupRecordTableEntry ParseFixupRecordTableEntry(Stream data) -#else private static FixupRecordTableEntry? ParseFixupRecordTableEntry(Stream data) -#endif { // TODO: Use marshalling here instead of building var entry = new FixupRecordTableEntry(); @@ -852,11 +828,7 @@ namespace SabreTools.Serialization.Streams entry.Length = data.ReadByteValue(); if (entry.Length > 0) { -#if NET48 - byte[] name = data.ReadBytes(entry.Length); -#else byte[]? name = data.ReadBytes(entry.Length); -#endif if (name != null) entry.Name = Encoding.ASCII.GetString(name).TrimEnd('\0'); } @@ -877,11 +849,7 @@ namespace SabreTools.Serialization.Streams entry.Length = data.ReadByteValue(); if (entry.Length > 0) { -#if NET48 - byte[] name = data.ReadBytes(entry.Length); -#else byte[]? name = data.ReadBytes(entry.Length); -#endif if (name != null) entry.Name = Encoding.ASCII.GetString(name).TrimEnd('\0'); } @@ -917,11 +885,7 @@ namespace SabreTools.Serialization.Streams entry.Length = data.ReadByteValue(); if (entry.Length > 0) { -#if NET48 - byte[] name = data.ReadBytes(entry.Length); -#else byte[]? name = data.ReadBytes(entry.Length); -#endif if (name != null) entry.Name = Encoding.ASCII.GetString(name).TrimEnd('\0'); } @@ -936,20 +900,12 @@ namespace SabreTools.Serialization.Streams /// Stream to parse /// Total size of the debug information /// Filled debug information on success, null on error -#if NET48 - private static DebugInformation ParseDebugInformation(Stream data, long size) -#else private static DebugInformation? ParseDebugInformation(Stream data, long size) -#endif { // TODO: Use marshalling here instead of building var debugInformation = new DebugInformation(); -#if NET48 - byte[] signature = data.ReadBytes(3); -#else byte[]? signature = data.ReadBytes(3); -#endif if (signature == null) return null; diff --git a/Streams/LinearExecutable.Serializer.cs b/Streams/LinearExecutable.Serializer.cs index caacae8d..178145d9 100644 --- a/Streams/LinearExecutable.Serializer.cs +++ b/Streams/LinearExecutable.Serializer.cs @@ -8,10 +8,6 @@ namespace SabreTools.Serialization.Streams public partial class LinearExecutable : IStreamSerializer { /// -#if NET48 - public Stream Serialize(Executable obj) => throw new NotImplementedException(); -#else public Stream? Serialize(Executable? obj) => throw new NotImplementedException(); -#endif } } \ No newline at end of file diff --git a/Streams/Listrom.Deserializer.cs b/Streams/Listrom.Deserializer.cs index 3e5df16b..6aaab992 100644 --- a/Streams/Listrom.Deserializer.cs +++ b/Streams/Listrom.Deserializer.cs @@ -10,11 +10,7 @@ namespace SabreTools.Serialization.Streams public partial class Listrom : IStreamSerializer { /// -#if NET48 - public MetadataFile Deserialize(Stream data) -#else public MetadataFile? Deserialize(Stream? data) -#endif { // If the stream is null if (data == null) @@ -24,11 +20,7 @@ namespace SabreTools.Serialization.Streams var reader = new StreamReader(data, Encoding.UTF8); var dat = new MetadataFile(); -#if NET48 - Set set = null; -#else Set? set = null; -#endif var sets = new List(); var rows = new List(); @@ -36,11 +28,7 @@ namespace SabreTools.Serialization.Streams while (!reader.EndOfStream) { // Read the line and don't split yet -#if NET48 - string line = reader.ReadLine(); -#else string? line = reader.ReadLine(); -#endif if (string.IsNullOrWhiteSpace(line)) { // If we have a set to process @@ -58,7 +46,7 @@ namespace SabreTools.Serialization.Streams // Set lines are unique if (line.StartsWith("ROMs required for driver")) { -#if NET48 +#if NETFRAMEWORK string driver = line.Substring("ROMs required for driver".Length).Trim('"', ' ', '.'); #else string driver = line["ROMs required for driver".Length..].Trim('"', ' ', '.'); @@ -68,7 +56,7 @@ namespace SabreTools.Serialization.Streams } else if (line.StartsWith("No ROMs required for driver")) { -#if NET48 +#if NETFRAMEWORK string driver = line.Substring("No ROMs required for driver".Length).Trim('"', ' ', '.'); #else string driver = line["No ROMs required for driver".Length..].Trim('"', ' ', '.'); @@ -78,7 +66,7 @@ namespace SabreTools.Serialization.Streams } else if (line.StartsWith("ROMs required for device")) { -#if NET48 +#if NETFRAMEWORK string device = line.Substring("ROMs required for device".Length).Trim('"', ' ', '.'); #else string device = line["ROMs required for device".Length..].Trim('"', ' ', '.'); @@ -88,7 +76,7 @@ namespace SabreTools.Serialization.Streams } else if (line.StartsWith("No ROMs required for device")) { -#if NET48 +#if NETFRAMEWORK string device = line.Substring("No ROMs required for device".Length).Trim('"', ' ', '.'); #else string device = line["No ROMs required for device".Length..].Trim('"', ' ', '.'); @@ -103,7 +91,7 @@ namespace SabreTools.Serialization.Streams } // Split the line for the name iteratively -#if NET48 +#if NETFRAMEWORK string[] lineParts = line.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries); if (lineParts.Length == 1) lineParts = line.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries); @@ -123,7 +111,7 @@ namespace SabreTools.Serialization.Streams // Read the name and set the rest of the line for processing string name = lineParts[0]; -#if NET48 +#if NETFRAMEWORK string trimmedLine = line.Substring(name.Length); #else string trimmedLine = line[name.Length..]; @@ -131,7 +119,7 @@ namespace SabreTools.Serialization.Streams if (trimmedLine == null) continue; -#if NET48 +#if NETFRAMEWORK lineParts = trimmedLine.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); #else lineParts = trimmedLine.Split(' ', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries); @@ -144,7 +132,7 @@ namespace SabreTools.Serialization.Streams // Normal CHD (Name, MD5/SHA1) case 1: row.Name = name; -#if NET48 +#if NETFRAMEWORK if (line.Contains("MD5(")) row.MD5 = lineParts[0].Substring("MD5".Length).Trim('(', ')'); else @@ -161,7 +149,7 @@ namespace SabreTools.Serialization.Streams case 3 when line.Contains("CRC"): row.Name = name; row.Size = lineParts[0]; -#if NET48 +#if NETFRAMEWORK row.CRC = lineParts[1].Substring("CRC".Length).Trim('(', ')'); if (line.Contains("MD5(")) row.MD5 = lineParts[2].Substring("MD5".Length).Trim('(', ')'); @@ -180,7 +168,7 @@ namespace SabreTools.Serialization.Streams case 3 when line.Contains("BAD_DUMP"): row.Name = name; row.Bad = true; -#if NET48 +#if NETFRAMEWORK if (line.Contains("MD5(")) row.MD5 = lineParts[1].Substring("MD5".Length).Trim('(', ')'); else @@ -204,7 +192,7 @@ namespace SabreTools.Serialization.Streams row.Name = name; row.Size = lineParts[0]; row.Bad = true; -#if NET48 +#if NETFRAMEWORK row.CRC = lineParts[2].Substring("CRC".Length).Trim('(', ')'); if (line.Contains("MD5(")) row.MD5 = lineParts[3].Substring("MD5".Length).Trim('(', ')'); diff --git a/Streams/Listrom.Serializer.cs b/Streams/Listrom.Serializer.cs index f38cb0ed..ddb820c8 100644 --- a/Streams/Listrom.Serializer.cs +++ b/Streams/Listrom.Serializer.cs @@ -9,11 +9,7 @@ namespace SabreTools.Serialization.Streams public partial class Listrom : IStreamSerializer { /// -#if NET48 - public Stream Serialize(MetadataFile obj) -#else public Stream? Serialize(MetadataFile? obj) -#endif { // If the metadata file is null if (obj == null) @@ -36,11 +32,7 @@ namespace SabreTools.Serialization.Streams /// /// Array of Set objects representing the sets information /// StreamWriter representing the output -#if NET48 - private static void WriteSets(Set[] sets, StreamWriter writer) -#else private static void WriteSets(Set[]? sets, StreamWriter writer) -#endif { // If the games information is missing, we can't do anything if (sets == null || !sets.Any()) @@ -112,11 +104,7 @@ namespace SabreTools.Serialization.Streams /// /// Array of Row objects to write /// StreamWriter representing the output -#if NET48 - private static void WriteRows(Row[] rows, StreamWriter writer) -#else private static void WriteRows(Row[]? rows, StreamWriter writer) -#endif { // If the array is missing, we can't do anything if (rows == null) diff --git a/Streams/Logiqx.Serializer.cs b/Streams/Logiqx.Serializer.cs index 61452d63..7ce446b3 100644 --- a/Streams/Logiqx.Serializer.cs +++ b/Streams/Logiqx.Serializer.cs @@ -6,11 +6,7 @@ namespace SabreTools.Serialization.Streams public partial class Logiqx : XmlFile { /// -#if NET48 - public Stream SerializeToStreamWithDocType(Datafile obj, string path) -#else public Stream? SerializeToStreamWithDocType(Datafile obj, string path) -#endif => Serialize(obj, Serialization.Logiqx.DocTypeName, Serialization.Logiqx.DocTypePubId, Serialization.Logiqx.DocTypeSysId, Serialization.Logiqx.DocTypeSysId); } } \ No newline at end of file diff --git a/Streams/MSDOS.Deserializer.cs b/Streams/MSDOS.Deserializer.cs index a5465b2f..bd98302a 100644 --- a/Streams/MSDOS.Deserializer.cs +++ b/Streams/MSDOS.Deserializer.cs @@ -10,11 +10,7 @@ namespace SabreTools.Serialization.Streams public partial class MSDOS : IStreamSerializer { /// -#if NET48 - public Executable Deserialize(Stream data) -#else public Executable? Deserialize(Stream? data) -#endif { // If the data is invalid if (data == null || data.Length == 0 || !data.CanSeek || !data.CanRead) @@ -69,22 +65,14 @@ namespace SabreTools.Serialization.Streams /// /// Stream to parse /// Filled executable header on success, null on error -#if NET48 - private static ExecutableHeader ParseExecutableHeader(Stream data) -#else private static ExecutableHeader? ParseExecutableHeader(Stream data) -#endif { // TODO: Use marshalling here instead of building var header = new ExecutableHeader(); #region Standard Fields -#if NET48 - byte[] magic = data.ReadBytes(2); -#else byte[]? magic = data.ReadBytes(2); -#endif if (magic == null) return null; diff --git a/Streams/MSDOS.Serializer.cs b/Streams/MSDOS.Serializer.cs index 8e90dd11..66651783 100644 --- a/Streams/MSDOS.Serializer.cs +++ b/Streams/MSDOS.Serializer.cs @@ -8,10 +8,6 @@ namespace SabreTools.Serialization.Streams public partial class MSDOS : IStreamSerializer { /// -#if NET48 - public Stream Serialize(Executable obj) => throw new NotImplementedException(); -#else public Stream? Serialize(Executable? obj) => throw new NotImplementedException(); -#endif } } \ No newline at end of file diff --git a/Streams/MicrosoftCabinet.Deserializer.cs b/Streams/MicrosoftCabinet.Deserializer.cs index 74c76c82..c93966c5 100644 --- a/Streams/MicrosoftCabinet.Deserializer.cs +++ b/Streams/MicrosoftCabinet.Deserializer.cs @@ -11,11 +11,7 @@ namespace SabreTools.Serialization.Streams public partial class MicrosoftCabinet : IStreamSerializer { /// -#if NET48 - public Cabinet Deserialize(Stream data) -#else public Cabinet? Deserialize(Stream? data) -#endif { // If the data is invalid if (data == null || data.Length == 0 || !data.CanSeek || !data.CanRead) @@ -95,19 +91,11 @@ namespace SabreTools.Serialization.Streams /// /// Stream to parse /// Filled cabinet header on success, null on error -#if NET48 - private static CFHEADER ParseCabinetHeader(Stream data) -#else private static CFHEADER? ParseCabinetHeader(Stream data) -#endif { CFHEADER header = new CFHEADER(); -#if NET48 - byte[] signature = data.ReadBytes(4); -#else byte[]? signature = data.ReadBytes(4); -#endif if (signature == null) return null; diff --git a/Streams/MicrosoftCabinet.Serializer.cs b/Streams/MicrosoftCabinet.Serializer.cs index c0502757..cba089b7 100644 --- a/Streams/MicrosoftCabinet.Serializer.cs +++ b/Streams/MicrosoftCabinet.Serializer.cs @@ -8,10 +8,6 @@ namespace SabreTools.Serialization.Streams public partial class MicrosoftCabinet : IStreamSerializer { /// -#if NET48 - public Stream Serialize(Cabinet obj) => throw new NotImplementedException(); -#else public Stream? Serialize(Cabinet? obj) => throw new NotImplementedException(); -#endif } } \ No newline at end of file diff --git a/Streams/MoPaQ.Deserializer.cs b/Streams/MoPaQ.Deserializer.cs index ae2ae970..4ef591c8 100644 --- a/Streams/MoPaQ.Deserializer.cs +++ b/Streams/MoPaQ.Deserializer.cs @@ -12,11 +12,7 @@ namespace SabreTools.Serialization.Streams public partial class MoPaQ : IStreamSerializer { /// -#if NET48 - public Archive Deserialize(Stream data) -#else public Archive? Deserialize(Stream? data) -#endif { // If the data is invalid if (data == null || data.Length == 0 || !data.CanSeek || !data.CanRead) @@ -343,20 +339,12 @@ namespace SabreTools.Serialization.Streams /// /// Stream to parse /// Filled archive header on success, null on error -#if NET48 - private static ArchiveHeader ParseArchiveHeader(Stream data) -#else private static ArchiveHeader? ParseArchiveHeader(Stream data) -#endif { ArchiveHeader archiveHeader = new ArchiveHeader(); // V1 - Common -#if NET48 - byte[] signature = data.ReadBytes(4); -#else byte[]? signature = data.ReadBytes(4); -#endif if (signature == null) return null; @@ -415,19 +403,11 @@ namespace SabreTools.Serialization.Streams /// /// Stream to parse /// Filled user data on success, null on error -#if NET48 - private static UserData ParseUserData(Stream data) -#else private static UserData? ParseUserData(Stream data) -#endif { UserData userData = new UserData(); -#if NET48 - byte[] signature = data.ReadBytes(4); -#else byte[]? signature = data.ReadBytes(4); -#endif if (signature == null) return null; @@ -447,20 +427,12 @@ namespace SabreTools.Serialization.Streams /// /// Stream to parse /// Filled HET table on success, null on error -#if NET48 - private static HetTable ParseHetTable(Stream data) -#else private static HetTable? ParseHetTable(Stream data) -#endif { HetTable hetTable = new HetTable(); // Common Headers -#if NET48 - byte[] signature = data.ReadBytes(4); -#else byte[]? signature = data.ReadBytes(4); -#endif if (signature == null) return null; @@ -492,20 +464,12 @@ namespace SabreTools.Serialization.Streams /// /// Stream to parse /// Filled BET table on success, null on error -#if NET48 - private static BetTable ParseBetTable(Stream data) -#else private static BetTable? ParseBetTable(Stream data) -#endif { BetTable betTable = new BetTable(); // Common Headers -#if NET48 - byte[] signature = data.ReadBytes(4); -#else byte[]? signature = data.ReadBytes(4); -#endif if (signature == null) return null; @@ -541,11 +505,7 @@ namespace SabreTools.Serialization.Streams betTable.FlagCount = data.ReadUInt32(); betTable.FlagsArray = new uint[betTable.FlagCount]; -#if NET48 - byte[] flagsArray = data.ReadBytes((int)betTable.FlagCount * 4); -#else byte[]? flagsArray = data.ReadBytes((int)betTable.FlagCount * 4); -#endif if (flagsArray != null) Buffer.BlockCopy(flagsArray, 0, betTable.FlagsArray, 0, (int)betTable.FlagCount * 4); diff --git a/Streams/MoPaQ.Serializer.cs b/Streams/MoPaQ.Serializer.cs index e9988eb4..4e7b4f53 100644 --- a/Streams/MoPaQ.Serializer.cs +++ b/Streams/MoPaQ.Serializer.cs @@ -8,10 +8,6 @@ namespace SabreTools.Serialization.Streams public partial class MoPaQ : IStreamSerializer { /// -#if NET48 - public Stream Serialize(Archive obj) => throw new NotImplementedException(); -#else public Stream? Serialize(Archive? obj) => throw new NotImplementedException(); -#endif } } \ No newline at end of file diff --git a/Streams/N3DS.Deserializer.cs b/Streams/N3DS.Deserializer.cs index e8e5f6f2..921bd466 100644 --- a/Streams/N3DS.Deserializer.cs +++ b/Streams/N3DS.Deserializer.cs @@ -11,11 +11,7 @@ namespace SabreTools.Serialization.Streams public partial class N3DS : IStreamSerializer { /// -#if NET48 - public Cart Deserialize(Stream data) -#else public Cart? Deserialize(Stream? data) -#endif { // If the data is invalid if (data == null || data.Length == 0 || !data.CanSeek || !data.CanRead) @@ -94,27 +90,15 @@ namespace SabreTools.Serialization.Streams for (int i = 0; i < 8; i++) { // If we have an encrypted or invalid partition -#if NET48 - if (cart.Partitions[i].MagicID != NCCHMagicNumber) -#else if (cart.Partitions[i]!.MagicID != NCCHMagicNumber) -#endif continue; // If we have no partitions table -#if NET48 - if (cart.Header.PartitionsTable == null) -#else if (cart.Header!.PartitionsTable == null) -#endif continue; // Get the extended header offset -#if NET48 - long offset = (cart.Header.PartitionsTable[i].Offset * mediaUnitSize) + 0x200; -#else long offset = (cart.Header.PartitionsTable[i]!.Offset * mediaUnitSize) + 0x200; -#endif if (offset < 0 || offset >= data.Length) continue; @@ -138,27 +122,15 @@ namespace SabreTools.Serialization.Streams for (int i = 0; i < 8; i++) { // If we have an encrypted or invalid partition -#if NET48 - if (cart.Partitions[i].MagicID != NCCHMagicNumber) -#else if (cart.Partitions[i]!.MagicID != NCCHMagicNumber) -#endif continue; // If we have no partitions table -#if NET48 - if (cart.Header.PartitionsTable == null) -#else if (cart.Header!.PartitionsTable == null) -#endif continue; // Get the ExeFS header offset -#if NET48 - long offset = (cart.Header.PartitionsTable[i].Offset + cart.Partitions[i].ExeFSOffsetInMediaUnits) * mediaUnitSize; -#else long offset = (cart.Header.PartitionsTable[i]!.Offset + cart.Partitions[i]!.ExeFSOffsetInMediaUnits) * mediaUnitSize; -#endif if (offset < 0 || offset >= data.Length) continue; @@ -180,27 +152,15 @@ namespace SabreTools.Serialization.Streams for (int i = 0; i < 8; i++) { // If we have an encrypted or invalid partition -#if NET48 - if (cart.Partitions[i].MagicID != NCCHMagicNumber) -#else if (cart.Partitions[i]!.MagicID != NCCHMagicNumber) -#endif continue; // If we have no partitions table -#if NET48 - if (cart.Header.PartitionsTable == null) -#else if (cart.Header!.PartitionsTable == null) -#endif continue; // Get the RomFS header offset -#if NET48 - long offset = (cart.Header.PartitionsTable[i].Offset + cart.Partitions[i].RomFSOffsetInMediaUnits) * mediaUnitSize; -#else long offset = (cart.Header.PartitionsTable[i]!.Offset + cart.Partitions[i]!.RomFSOffsetInMediaUnits) * mediaUnitSize; -#endif if (offset < 0 || offset >= data.Length) continue; @@ -223,21 +183,13 @@ namespace SabreTools.Serialization.Streams /// /// Stream to parse /// Filled NCSD header on success, null on error -#if NET48 - private static NCSDHeader ParseNCSDHeader(Stream data) -#else private static NCSDHeader? ParseNCSDHeader(Stream data) -#endif { // TODO: Use marshalling here instead of building NCSDHeader header = new NCSDHeader(); header.RSA2048Signature = data.ReadBytes(0x100); -#if NET48 - byte[] magicNumber = data.ReadBytes(4); -#else byte[]? magicNumber = data.ReadBytes(4); -#endif if (magicNumber == null) return null; @@ -329,11 +281,7 @@ namespace SabreTools.Serialization.Streams /// /// Stream to parse /// Filled development card info header on success, null on error -#if NET48 - private static DevelopmentCardInfoHeader ParseDevelopmentCardInfoHeader(Stream data) -#else private static DevelopmentCardInfoHeader? ParseDevelopmentCardInfoHeader(Stream data) -#endif { // TODO: Use marshalling here instead of building DevelopmentCardInfoHeader developmentCardInfoHeader = new DevelopmentCardInfoHeader(); @@ -358,11 +306,7 @@ namespace SabreTools.Serialization.Streams /// /// Stream to parse /// Filled initial data on success, null on error -#if NET48 - private static InitialData ParseInitialData(Stream data) -#else private static InitialData? ParseInitialData(Stream data) -#endif { // TODO: Use marshalling here instead of building InitialData initialData = new InitialData(); @@ -393,11 +337,7 @@ namespace SabreTools.Serialization.Streams if (!skipSignature) header.RSA2048Signature = data.ReadBytes(0x100); -#if NET48 - byte[] magicId = data.ReadBytes(4); -#else byte[]? magicId = data.ReadBytes(4); -#endif if (magicId != null) header.MagicID = Encoding.ASCII.GetString(magicId).TrimEnd('\0'); header.ContentSizeInMediaUnits = data.ReadUInt32(); @@ -408,11 +348,7 @@ namespace SabreTools.Serialization.Streams header.ProgramId = data.ReadBytes(8); header.Reserved1 = data.ReadBytes(0x10); header.LogoRegionHash = data.ReadBytes(0x20); -#if NET48 - byte[] productCode = data.ReadBytes(0x10); -#else byte[]? productCode = data.ReadBytes(0x10); -#endif if (productCode != null) header.ProductCode = Encoding.ASCII.GetString(productCode).TrimEnd('\0'); header.ExtendedHeaderHash = data.ReadBytes(0x20); @@ -489,11 +425,7 @@ namespace SabreTools.Serialization.Streams /// /// Stream to parse /// Filled NCCH extended header on success, null on error -#if NET48 - private static NCCHExtendedHeader ParseNCCHExtendedHeader(Stream data) -#else private static NCCHExtendedHeader? ParseNCCHExtendedHeader(Stream data) -#endif { // TODO: Use marshalling here instead of building NCCHExtendedHeader extendedHeader = new NCCHExtendedHeader(); @@ -526,11 +458,7 @@ namespace SabreTools.Serialization.Streams // TODO: Use marshalling here instead of building SystemControlInfo systemControlInfo = new SystemControlInfo(); -#if NET48 - byte[] applicationTitle = data.ReadBytes(8); -#else byte[]? applicationTitle = data.ReadBytes(8); -#endif if (applicationTitle != null) systemControlInfo.ApplicationTitle = Encoding.ASCII.GetString(applicationTitle).TrimEnd('\0'); systemControlInfo.Reserved1 = data.ReadBytes(5); @@ -731,11 +659,7 @@ namespace SabreTools.Serialization.Streams // TODO: Use marshalling here instead of building ExeFSFileHeader exeFSFileHeader = new ExeFSFileHeader(); -#if NET48 - byte[] fileName = data.ReadBytes(8); -#else byte[]? fileName = data.ReadBytes(8); -#endif if (fileName != null) exeFSFileHeader.FileName = Encoding.ASCII.GetString(fileName).TrimEnd('\0'); exeFSFileHeader.FileOffset = data.ReadUInt32(); @@ -749,20 +673,12 @@ namespace SabreTools.Serialization.Streams /// /// Stream to parse /// Filled RomFS header on success, null on error -#if NET48 - private static RomFSHeader ParseRomFSHeader(Stream data) -#else private static RomFSHeader? ParseRomFSHeader(Stream data) -#endif { // TODO: Use marshalling here instead of building RomFSHeader romFSHeader = new RomFSHeader(); -#if NET48 - byte[] magicString = data.ReadBytes(4); -#else byte[]? magicString = data.ReadBytes(4); -#endif if (magicString == null) return null; diff --git a/Streams/N3DS.Serializer.cs b/Streams/N3DS.Serializer.cs index 6d6656e8..186babdd 100644 --- a/Streams/N3DS.Serializer.cs +++ b/Streams/N3DS.Serializer.cs @@ -8,10 +8,6 @@ namespace SabreTools.Serialization.Streams public partial class N3DS : IStreamSerializer { /// -#if NET48 - public Stream Serialize(Cart obj) => throw new NotImplementedException(); -#else public Stream? Serialize(Cart? obj) => throw new NotImplementedException(); -#endif } } \ No newline at end of file diff --git a/Streams/NCF.Deserialization.cs b/Streams/NCF.Deserialization.cs index 6f2fbe16..f2d722c0 100644 --- a/Streams/NCF.Deserialization.cs +++ b/Streams/NCF.Deserialization.cs @@ -10,11 +10,7 @@ namespace SabreTools.Serialization.Streams public partial class NCF : IStreamSerializer { /// -#if NET48 - public Models.NCF.File Deserialize(Stream data) -#else public Models.NCF.File? Deserialize(Stream? data) -#endif { // If the data is invalid if (data == null || data.Length == 0 || !data.CanSeek || !data.CanRead) @@ -82,29 +78,17 @@ namespace SabreTools.Serialization.Streams long directoryNamesEnd = data.Position + directoryHeader.NameSize; // Create the string dictionary -#if NET48 - file.DirectoryNames = new Dictionary(); -#else file.DirectoryNames = new Dictionary(); -#endif // Loop and read the null-terminated strings while (data.Position < directoryNamesEnd) { long nameOffset = data.Position - directoryNamesStart; -#if NET48 - string directoryName = data.ReadString(Encoding.ASCII); -#else string? directoryName = data.ReadString(Encoding.ASCII); -#endif if (data.Position > directoryNamesEnd) { data.Seek(-directoryName?.Length ?? 0, SeekOrigin.Current); -#if NET48 - byte[] endingData = data.ReadBytes((int)(directoryNamesEnd - data.Position)); -#else byte[]? endingData = data.ReadBytes((int)(directoryNamesEnd - data.Position)); -#endif if (endingData != null) directoryName = Encoding.ASCII.GetString(endingData); else @@ -275,11 +259,7 @@ namespace SabreTools.Serialization.Streams /// /// Stream to parse /// Filled Half-Life No Cache header on success, null on error -#if NET48 - private static Header ParseHeader(Stream data) -#else private static Header? ParseHeader(Stream data) -#endif { // TODO: Use marshalling here instead of building Header header = new Header(); @@ -313,11 +293,7 @@ namespace SabreTools.Serialization.Streams /// /// Stream to parse /// Filled Half-Life No Cache directory header on success, null on error -#if NET48 - private static DirectoryHeader ParseDirectoryHeader(Stream data) -#else private static DirectoryHeader? ParseDirectoryHeader(Stream data) -#endif { // TODO: Use marshalling here instead of building DirectoryHeader directoryHeader = new DirectoryHeader(); @@ -429,11 +405,7 @@ namespace SabreTools.Serialization.Streams /// /// Stream to parse /// Filled Half-Life No Cache unknown header on success, null on error -#if NET48 - private static UnknownHeader ParseUnknownHeader(Stream data) -#else private static UnknownHeader? ParseUnknownHeader(Stream data) -#endif { // TODO: Use marshalling here instead of building UnknownHeader unknownHeader = new UnknownHeader(); @@ -469,11 +441,7 @@ namespace SabreTools.Serialization.Streams /// /// Stream to parse /// Filled Half-Life No Cache checksum header on success, null on error -#if NET48 - private static ChecksumHeader ParseChecksumHeader(Stream data) -#else private static ChecksumHeader? ParseChecksumHeader(Stream data) -#endif { // TODO: Use marshalling here instead of building ChecksumHeader checksumHeader = new ChecksumHeader(); @@ -492,11 +460,7 @@ namespace SabreTools.Serialization.Streams /// /// Stream to parse /// Filled Half-Life No Cache checksum map header on success, null on error -#if NET48 - private static ChecksumMapHeader ParseChecksumMapHeader(Stream data) -#else private static ChecksumMapHeader? ParseChecksumMapHeader(Stream data) -#endif { // TODO: Use marshalling here instead of building ChecksumMapHeader checksumMapHeader = new ChecksumMapHeader(); diff --git a/Streams/NCF.Serialization.cs b/Streams/NCF.Serialization.cs index e5babd5b..478ff036 100644 --- a/Streams/NCF.Serialization.cs +++ b/Streams/NCF.Serialization.cs @@ -7,10 +7,6 @@ namespace SabreTools.Serialization.Streams public partial class NCF : IStreamSerializer { /// -#if NET48 - public Stream Serialize(Models.NCF.File obj) => throw new NotImplementedException(); -#else public Stream? Serialize(Models.NCF.File? obj) => throw new NotImplementedException(); -#endif } } \ No newline at end of file diff --git a/Streams/NewExecutable.Deserializer.cs b/Streams/NewExecutable.Deserializer.cs index c63c71df..eb931237 100644 --- a/Streams/NewExecutable.Deserializer.cs +++ b/Streams/NewExecutable.Deserializer.cs @@ -12,11 +12,7 @@ namespace SabreTools.Serialization.Streams public partial class NewExecutable : IStreamSerializer { /// -#if NET48 - public Executable Deserialize(Stream data) -#else public Executable? Deserialize(Stream? data) -#endif { // If the data is invalid if (data == null || data.Length == 0 || !data.CanSeek || !data.CanRead) @@ -217,20 +213,12 @@ namespace SabreTools.Serialization.Streams /// /// Stream to parse /// Filled executable header on success, null on error -#if NET48 - private static ExecutableHeader ParseExecutableHeader(Stream data) -#else private static ExecutableHeader? ParseExecutableHeader(Stream data) -#endif { // TODO: Use marshalling here instead of building var header = new ExecutableHeader(); -#if NET48 - byte[] magic = data.ReadBytes(2); -#else byte[]? magic = data.ReadBytes(2); -#endif if (magic == null) return null; @@ -335,34 +323,19 @@ namespace SabreTools.Serialization.Streams // Get the full list of unique string offsets var stringOffsets = resourceTable.ResourceTypes .Where(rt => rt != null) -#if NET48 - .Where(rt => rt.IsIntegerType() == false) - .Select(rt => rt.TypeID) -#else .Where(rt => rt!.IsIntegerType() == false) .Select(rt => rt!.TypeID) -#endif .Union(resourceTable.ResourceTypes .Where(rt => rt != null) -#if NET48 - .SelectMany(rt => rt.Resources) - .Where(r => r.IsIntegerType() == false) - .Select(r => r.ResourceID)) -#else .SelectMany(rt => rt!.Resources ?? System.Array.Empty()) .Where(r => r!.IsIntegerType() == false) .Select(r => r!.ResourceID)) -#endif .Distinct() .OrderBy(o => o) .ToList(); // Populate the type and name string dictionary -#if NET48 - resourceTable.TypeAndNameStrings = new Dictionary(); -#else resourceTable.TypeAndNameStrings = new Dictionary(); -#endif for (int i = 0; i < stringOffsets.Count; i++) { int stringOffset = (int)(stringOffsets[i] + initialOffset); @@ -426,18 +399,10 @@ namespace SabreTools.Serialization.Streams /// Stream to parse /// First address not part of the imported-name table /// Filled imported-name table on success, null on error -#if NET48 - private static Dictionary ParseImportedNameTable(Stream data, int endOffset) -#else private static Dictionary ParseImportedNameTable(Stream data, int endOffset) -#endif { // TODO: Use marshalling here instead of building -#if NET48 - var importedNameTable = new Dictionary(); -#else var importedNameTable = new Dictionary(); -#endif while (data.Position < endOffset) { diff --git a/Streams/NewExecutable.Serializer.cs b/Streams/NewExecutable.Serializer.cs index f39d32da..4ff00c8b 100644 --- a/Streams/NewExecutable.Serializer.cs +++ b/Streams/NewExecutable.Serializer.cs @@ -8,10 +8,6 @@ namespace SabreTools.Serialization.Streams public partial class NewExecutable : IStreamSerializer { /// -#if NET48 - public Stream Serialize(Executable obj) => throw new NotImplementedException(); -#else public Stream? Serialize(Executable? obj) => throw new NotImplementedException(); -#endif } } \ No newline at end of file diff --git a/Streams/Nitro.Deserializer.cs b/Streams/Nitro.Deserializer.cs index 3d32dfa1..a306f08b 100644 --- a/Streams/Nitro.Deserializer.cs +++ b/Streams/Nitro.Deserializer.cs @@ -10,11 +10,7 @@ namespace SabreTools.Serialization.Streams public partial class Nitro : IStreamSerializer { /// -#if NET48 - public Cart Deserialize(Stream data) -#else public Cart? Deserialize(Stream? data) -#endif { // If the data is invalid if (data == null || data.Length == 0 || !data.CanSeek || !data.CanRead) @@ -132,19 +128,11 @@ namespace SabreTools.Serialization.Streams // TODO: Use marshalling here instead of building CommonHeader commonHeader = new CommonHeader(); -#if NET48 - byte[] gameTitle = data.ReadBytes(12); -#else byte[]? gameTitle = data.ReadBytes(12); -#endif if (gameTitle != null) commonHeader.GameTitle = Encoding.ASCII.GetString(gameTitle).TrimEnd('\0'); commonHeader.GameCode = data.ReadUInt32(); -#if NET48 - byte[] makerCode = data.ReadBytes(2); -#else byte[]? makerCode = data.ReadBytes(2); -#endif if (makerCode != null) commonHeader.MakerCode = Encoding.ASCII.GetString(bytes: makerCode).TrimEnd('\0'); commonHeader.UnitCode = (Unitcode)data.ReadByteValue(); @@ -332,11 +320,7 @@ namespace SabreTools.Serialization.Streams /// /// Stream to parse /// Filled name list entry on success, null on error -#if NET48 - private static NameListEntry ParseNameListEntry(Stream data) -#else private static NameListEntry? ParseNameListEntry(Stream data) -#endif { // TODO: Use marshalling here instead of building NameListEntry entry = new NameListEntry(); @@ -350,11 +334,7 @@ namespace SabreTools.Serialization.Streams byte size = (byte)(flagAndSize & ~0x80); if (size > 0) { -#if NET48 - byte[] name = data.ReadBytes(size); -#else byte[]? name = data.ReadBytes(size); -#endif if (name != null) entry.Name = Encoding.UTF8.GetString(name); } diff --git a/Streams/Nitro.Serializer.cs b/Streams/Nitro.Serializer.cs index 8c69e6bf..9ac34cf2 100644 --- a/Streams/Nitro.Serializer.cs +++ b/Streams/Nitro.Serializer.cs @@ -8,10 +8,6 @@ namespace SabreTools.Serialization.Streams public partial class Nitro : IStreamSerializer { /// -#if NET48 - public Stream Serialize(Cart obj) => throw new NotImplementedException(); -#else public Stream? Serialize(Cart? obj) => throw new NotImplementedException(); -#endif } } \ No newline at end of file diff --git a/Streams/OpenMSX.Serializer.cs b/Streams/OpenMSX.Serializer.cs index ee29a588..2f82ec75 100644 --- a/Streams/OpenMSX.Serializer.cs +++ b/Streams/OpenMSX.Serializer.cs @@ -6,11 +6,7 @@ namespace SabreTools.Serialization.Streams public partial class OpenMSX : XmlFile { /// -#if NET48 - public Stream SerializeToStreamWithDocType(SoftwareDb obj, string path) -#else public Stream? SerializeToStreamWithDocType(SoftwareDb? obj, string path) -#endif => Serialize(obj, Serialization.OpenMSX.DocTypeName, Serialization.OpenMSX.DocTypePubId, Serialization.OpenMSX.DocTypeSysId, Serialization.OpenMSX.DocTypeSysId); } } \ No newline at end of file diff --git a/Streams/PAK.Deserializer.cs b/Streams/PAK.Deserializer.cs index d54fe80b..df01e083 100644 --- a/Streams/PAK.Deserializer.cs +++ b/Streams/PAK.Deserializer.cs @@ -10,11 +10,7 @@ namespace SabreTools.Serialization.Streams public partial class PAK : IStreamSerializer { /// -#if NET48 - public Models.PAK.File Deserialize(Stream data) -#else public Models.PAK.File? Deserialize(Stream? data) -#endif { // If the data is invalid if (data == null || data.Length == 0 || !data.CanSeek || !data.CanRead) @@ -72,20 +68,12 @@ namespace SabreTools.Serialization.Streams /// /// Stream to parse /// Filled Half-Life Package header on success, null on error -#if NET48 - private static Header ParseHeader(Stream data) -#else private static Header? ParseHeader(Stream data) -#endif { // TODO: Use marshalling here instead of building Header header = new Header(); -#if NET48 - byte[] signature = data.ReadBytes(4); -#else byte[]? signature = data.ReadBytes(4); -#endif if (signature == null) return null; @@ -109,11 +97,7 @@ namespace SabreTools.Serialization.Streams // TODO: Use marshalling here instead of building DirectoryItem directoryItem = new DirectoryItem(); -#if NET48 - byte[] itemName = data.ReadBytes(56); -#else byte[]? itemName = data.ReadBytes(56); -#endif if (itemName != null) directoryItem.ItemName = Encoding.ASCII.GetString(itemName).TrimEnd('\0'); directoryItem.ItemOffset = data.ReadUInt32(); diff --git a/Streams/PAK.Serializer.cs b/Streams/PAK.Serializer.cs index bb662b63..4a838527 100644 --- a/Streams/PAK.Serializer.cs +++ b/Streams/PAK.Serializer.cs @@ -7,10 +7,6 @@ namespace SabreTools.Serialization.Streams public partial class PAK : IStreamSerializer { /// -#if NET48 - public Stream Serialize(Models.PAK.File obj) => throw new NotImplementedException(); -#else public Stream? Serialize(Models.PAK.File? obj) => throw new NotImplementedException(); -#endif } } \ No newline at end of file diff --git a/Streams/PFF.Deserializer.cs b/Streams/PFF.Deserializer.cs index da214ac7..1f0b494b 100644 --- a/Streams/PFF.Deserializer.cs +++ b/Streams/PFF.Deserializer.cs @@ -10,11 +10,7 @@ namespace SabreTools.Serialization.Streams public partial class PFF : IStreamSerializer { /// -#if NET48 - public Archive Deserialize(Stream data) -#else public Archive? Deserialize(Stream? data) -#endif { // If the data is invalid if (data == null || data.Length == 0 || !data.CanSeek || !data.CanRead) @@ -95,21 +91,13 @@ namespace SabreTools.Serialization.Streams /// /// Stream to parse /// Filled header on success, null on error -#if NET48 - private static Header ParseHeader(Stream data) -#else private static Header? ParseHeader(Stream data) -#endif { // TODO: Use marshalling here instead of building Header header = new Header(); header.HeaderSize = data.ReadUInt32(); -#if NET48 - byte[] signature = data.ReadBytes(4); -#else byte[]? signature = data.ReadBytes(4); -#endif if (signature == null) return null; @@ -160,11 +148,7 @@ namespace SabreTools.Serialization.Streams footer.SystemIP = data.ReadUInt32(); footer.Reserved = data.ReadUInt32(); -#if NET48 - byte[] kingTag = data.ReadBytes(4); -#else byte[]? kingTag = data.ReadBytes(4); -#endif if (kingTag != null) footer.KingTag = Encoding.ASCII.GetString(kingTag); @@ -186,11 +170,7 @@ namespace SabreTools.Serialization.Streams segment.FileLocation = data.ReadUInt32(); segment.FileSize = data.ReadUInt32(); segment.PackedDate = data.ReadUInt32(); -#if NET48 - byte[] fileName = data.ReadBytes(0x10); -#else byte[]? fileName = data.ReadBytes(0x10); -#endif if (fileName != null) segment.FileName = Encoding.ASCII.GetString(fileName).TrimEnd('\0'); if (segmentSize > Version2SegmentSize) diff --git a/Streams/PFF.Serializer.cs b/Streams/PFF.Serializer.cs index 5365f581..6da02a0e 100644 --- a/Streams/PFF.Serializer.cs +++ b/Streams/PFF.Serializer.cs @@ -8,10 +8,6 @@ namespace SabreTools.Serialization.Streams public partial class PFF : IStreamSerializer { /// -#if NET48 - public Stream Serialize(Archive obj) => throw new NotImplementedException(); -#else public Stream? Serialize(Archive? obj) => throw new NotImplementedException(); -#endif } } \ No newline at end of file diff --git a/Streams/PIC.Deserializer.cs b/Streams/PIC.Deserializer.cs index 7f5e599a..9d3c7075 100644 --- a/Streams/PIC.Deserializer.cs +++ b/Streams/PIC.Deserializer.cs @@ -11,11 +11,7 @@ namespace SabreTools.Serialization.Streams public partial class PIC : IStreamSerializer { /// -#if NET48 - public DiscInformation Deserialize(Stream data) -#else public DiscInformation? Deserialize(Stream? data) -#endif { // If the data is invalid if (data == null || data.Length == 0 || !data.CanSeek || !data.CanRead) @@ -55,11 +51,7 @@ namespace SabreTools.Serialization.Streams /// /// Stream to parse /// Filled disc information unit on success, null on error -#if NET48 - private static DiscInformationUnit ParseDiscInformationUnit(Stream data) -#else private static DiscInformationUnit? ParseDiscInformationUnit(Stream data) -#endif { // TODO: Use marshalling here instead of building var unit = new DiscInformationUnit(); @@ -111,21 +103,13 @@ namespace SabreTools.Serialization.Streams /// /// Stream to parse /// Filled disc information unit header on success, null on error -#if NET48 - private static DiscInformationUnitHeader ParseDiscInformationUnitHeader(Stream data) -#else private static DiscInformationUnitHeader? ParseDiscInformationUnitHeader(Stream data) -#endif { // TODO: Use marshalling here instead of building var header = new DiscInformationUnitHeader(); // We only accept Disc Information units, not Emergency Brake or other -#if NET48 - byte[] dic = data.ReadBytes(2); -#else byte[]? dic = data.ReadBytes(2); -#endif if (dic == null) return null; @@ -148,20 +132,12 @@ namespace SabreTools.Serialization.Streams /// /// Stream to parse /// Filled disc information unit body on success, null on error -#if NET48 - private static DiscInformationUnitBody ParseDiscInformationUnitBody(Stream data) -#else private static DiscInformationUnitBody? ParseDiscInformationUnitBody(Stream data) -#endif { // TODO: Use marshalling here instead of building var body = new DiscInformationUnitBody(); -#if NET48 - byte[] dti = data.ReadBytes(3); -#else byte[]? dti = data.ReadBytes(3); -#endif if (dti == null) return null; diff --git a/Streams/PIC.Serializer.cs b/Streams/PIC.Serializer.cs index 21ebc196..4ef48489 100644 --- a/Streams/PIC.Serializer.cs +++ b/Streams/PIC.Serializer.cs @@ -8,10 +8,6 @@ namespace SabreTools.Serialization.Streams public partial class PIC : IStreamSerializer { /// -#if NET48 - public Stream Serialize(DiscInformation obj) => throw new NotImplementedException(); -#else public Stream? Serialize(DiscInformation? obj) => throw new NotImplementedException(); -#endif } } \ No newline at end of file diff --git a/Streams/PlayJAudio.Deserializer.cs b/Streams/PlayJAudio.Deserializer.cs index 100f87b1..c95a1a12 100644 --- a/Streams/PlayJAudio.Deserializer.cs +++ b/Streams/PlayJAudio.Deserializer.cs @@ -10,19 +10,11 @@ namespace SabreTools.Serialization.Streams public partial class PlayJAudio : IStreamSerializer { /// -#if NET48 - public AudioFile Deserialize(Stream data) => Deserialize(data, 0); -#else public AudioFile? Deserialize(Stream? data) => Deserialize(data, 0); -#endif /// /// Offset to adjust all seeking by -#if NET48 - public AudioFile Deserialize(Stream data, long adjust) -#else public AudioFile? Deserialize(Stream? data, long adjust) -#endif { // If the data is invalid if (data == null || data.Length == 0 || !data.CanSeek || !data.CanRead) @@ -176,11 +168,7 @@ namespace SabreTools.Serialization.Streams /// /// Stream to parse /// Filled audio header on success, null on error -#if NET48 - private static AudioHeader ParseAudioHeader(Stream data) -#else private static AudioHeader? ParseAudioHeader(Stream data) -#endif { // Cache the current offset long initialOffset = data.Position; @@ -260,67 +248,39 @@ namespace SabreTools.Serialization.Streams } audioHeader.TrackLength = data.ReadUInt16(); -#if NET48 - byte[] track = data.ReadBytes(audioHeader.TrackLength); -#else byte[]? track = data.ReadBytes(audioHeader.TrackLength); -#endif if (track != null) audioHeader.Track = Encoding.ASCII.GetString(track); audioHeader.ArtistLength = data.ReadUInt16(); -#if NET48 - byte[] artist = data.ReadBytes(audioHeader.ArtistLength); -#else byte[]? artist = data.ReadBytes(audioHeader.ArtistLength); -#endif if (artist != null) audioHeader.Artist = Encoding.ASCII.GetString(artist); audioHeader.AlbumLength = data.ReadUInt16(); -#if NET48 - byte[] album = data.ReadBytes(audioHeader.AlbumLength); -#else byte[]? album = data.ReadBytes(audioHeader.AlbumLength); -#endif if (album != null) audioHeader.Album = Encoding.ASCII.GetString(album); audioHeader.WriterLength = data.ReadUInt16(); -#if NET48 - byte[] writer = data.ReadBytes(audioHeader.WriterLength); -#else byte[]? writer = data.ReadBytes(audioHeader.WriterLength); -#endif if (writer != null) audioHeader.Writer = Encoding.ASCII.GetString(writer); audioHeader.PublisherLength = data.ReadUInt16(); -#if NET48 - byte[] publisher = data.ReadBytes(audioHeader.PublisherLength); -#else byte[]? publisher = data.ReadBytes(audioHeader.PublisherLength); -#endif if (publisher != null) audioHeader.Publisher = Encoding.ASCII.GetString(publisher); audioHeader.LabelLength = data.ReadUInt16(); -#if NET48 - byte[] label = data.ReadBytes(audioHeader.LabelLength); -#else byte[]? label = data.ReadBytes(audioHeader.LabelLength); -#endif if (label != null) audioHeader.Label = Encoding.ASCII.GetString(label); if (data.Position - initialOffset < unknownOffset1) { audioHeader.CommentsLength = data.ReadUInt16(); -#if NET48 - byte[] comments = data.ReadBytes(audioHeader.CommentsLength); -#else byte[]? comments = data.ReadBytes(audioHeader.CommentsLength); -#endif if (comments != null) audioHeader.Comments = Encoding.ASCII.GetString(comments); } @@ -370,11 +330,7 @@ namespace SabreTools.Serialization.Streams DataFile dataFile = new DataFile(); dataFile.FileNameLength = data.ReadUInt16(); -#if NET48 - byte[] fileName = data.ReadBytes(dataFile.FileNameLength); -#else byte[]? fileName = data.ReadBytes(dataFile.FileNameLength); -#endif if (fileName != null) dataFile.FileName = Encoding.ASCII.GetString(fileName); diff --git a/Streams/PlayJAudio.Serializer.cs b/Streams/PlayJAudio.Serializer.cs index e4a7d322..0cb96a57 100644 --- a/Streams/PlayJAudio.Serializer.cs +++ b/Streams/PlayJAudio.Serializer.cs @@ -8,10 +8,6 @@ namespace SabreTools.Serialization.Streams public partial class PlayJAudio : IStreamSerializer { /// -#if NET48 - public Stream Serialize(AudioFile obj) => throw new NotImplementedException(); -#else public Stream? Serialize(AudioFile? obj) => throw new NotImplementedException(); -#endif } } \ No newline at end of file diff --git a/Streams/PlayJPlaylist.Deserializer.cs b/Streams/PlayJPlaylist.Deserializer.cs index 1a989bb0..70025cbe 100644 --- a/Streams/PlayJPlaylist.Deserializer.cs +++ b/Streams/PlayJPlaylist.Deserializer.cs @@ -8,11 +8,7 @@ namespace SabreTools.Serialization.Streams public partial class PlayJPlaylist : IStreamSerializer { /// -#if NET48 - public Playlist Deserialize(Stream data) -#else public Playlist? Deserialize(Stream? data) -#endif { // If the data is invalid if (data == null || data.Length == 0 || !data.CanSeek || !data.CanRead) diff --git a/Streams/PlayJPlaylist.Serializer.cs b/Streams/PlayJPlaylist.Serializer.cs index 4bc96de5..b478f0a3 100644 --- a/Streams/PlayJPlaylist.Serializer.cs +++ b/Streams/PlayJPlaylist.Serializer.cs @@ -8,10 +8,6 @@ namespace SabreTools.Serialization.Streams public partial class PlayJPlaylist : IStreamSerializer { /// -#if NET48 - public Stream Serialize(Playlist obj) => throw new NotImplementedException(); -#else public Stream? Serialize(Playlist? obj) => throw new NotImplementedException(); -#endif } } \ No newline at end of file diff --git a/Streams/PortableExecutable.Deserializer.cs b/Streams/PortableExecutable.Deserializer.cs index aa67581f..4f3d6c81 100644 --- a/Streams/PortableExecutable.Deserializer.cs +++ b/Streams/PortableExecutable.Deserializer.cs @@ -13,11 +13,7 @@ namespace SabreTools.Serialization.Streams public partial class PortableExecutable : IStreamSerializer { /// -#if NET48 - public Executable Deserialize(Stream data) -#else public Executable? Deserialize(Stream? data) -#endif { // If the data is invalid if (data == null || data.Length == 0 || !data.CanSeek || !data.CanRead) @@ -48,11 +44,7 @@ namespace SabreTools.Serialization.Streams #region Signature data.Seek(initialOffset + stub.Header.NewExeHeaderAddr, SeekOrigin.Begin); -#if NET48 - byte[] signature = data.ReadBytes(4); -#else byte[]? signature = data.ReadBytes(4); -#endif if (signature == null) return null; @@ -704,11 +696,7 @@ namespace SabreTools.Serialization.Streams while (totalSize > 0 && data.Position < data.Length) { long initialPosition = data.Position; -#if NET48 - string str = data.ReadString(); -#else string? str = data.ReadString(); -#endif strings.Add(str ?? string.Empty); totalSize -= (uint)(data.Position - initialPosition); } @@ -779,11 +767,7 @@ namespace SabreTools.Serialization.Streams /// First address not part of the base relocation table /// Section table to use for virtual address translation /// Filled base relocation table on success, null on error -#if NET48 - private static BaseRelocationBlock[] ParseBaseRelocationTable(Stream data, int endOffset, SectionHeader[] sections) -#else private static BaseRelocationBlock[] ParseBaseRelocationTable(Stream data, int endOffset, SectionHeader?[] sections) -#endif { // TODO: Use marshalling here instead of building var baseRelocationTable = new List(); @@ -824,11 +808,7 @@ namespace SabreTools.Serialization.Streams /// First address not part of the debug table /// Section table to use for virtual address translation /// Filled debug table on success, null on error -#if NET48 - private static DebugTable ParseDebugTable(Stream data, int endOffset, SectionHeader[] sections) -#else private static DebugTable ParseDebugTable(Stream data, int endOffset, SectionHeader?[] sections) -#endif { // TODO: Use marshalling here instead of building var debugTable = new DebugTable(); @@ -865,11 +845,7 @@ namespace SabreTools.Serialization.Streams /// Stream to parse /// Section table to use for virtual address translation /// Filled export table on success, null on error -#if NET48 - private static ExportTable ParseExportTable(Stream data, SectionHeader[] sections) -#else private static ExportTable ParseExportTable(Stream data, SectionHeader?[] sections) -#endif { // TODO: Use marshalling here instead of building var exportTable = new ExportTable(); @@ -896,11 +872,7 @@ namespace SabreTools.Serialization.Streams uint nameAddress = exportDirectoryTable.NameRVA.ConvertVirtualAddress(sections); data.Seek(nameAddress, SeekOrigin.Begin); -#if NET48 - string name = data.ReadString(Encoding.ASCII); -#else string? name = data.ReadString(Encoding.ASCII); -#endif exportDirectoryTable.Name = name; } @@ -973,11 +945,7 @@ namespace SabreTools.Serialization.Streams exportNameTable.Strings = new string[exportDirectoryTable.NumberOfNamePointers]; for (int i = 0; i < exportDirectoryTable.NumberOfNamePointers; i++) { -#if NET48 - string str = data.ReadString(Encoding.ASCII); -#else string? str = data.ReadString(Encoding.ASCII); -#endif exportNameTable.Strings[i] = str ?? string.Empty; } @@ -994,11 +962,7 @@ namespace SabreTools.Serialization.Streams /// Optional header magic number indicating PE32 or PE32+ /// Section table to use for virtual address translation /// Filled import table on success, null on error -#if NET48 - private static ImportTable ParseImportTable(Stream data, OptionalHeaderMagicNumber magic, SectionHeader[] sections) -#else private static ImportTable ParseImportTable(Stream data, OptionalHeaderMagicNumber magic, SectionHeader?[] sections) -#endif { // TODO: Use marshalling here instead of building var importTable = new ImportTable(); @@ -1043,20 +1007,12 @@ namespace SabreTools.Serialization.Streams uint nameAddress = importDirectoryTableEntry.NameRVA.ConvertVirtualAddress(sections); data.Seek(nameAddress, SeekOrigin.Begin); -#if NET48 - string name = data.ReadString(Encoding.ASCII); -#else string? name = data.ReadString(Encoding.ASCII); -#endif importDirectoryTableEntry.Name = name; } // Lookup tables -#if NET48 - var importLookupTables = new Dictionary(); -#else var importLookupTables = new Dictionary(); -#endif for (int i = 0; i < importTable.ImportDirectoryTable.Length; i++) { @@ -1110,11 +1066,7 @@ namespace SabreTools.Serialization.Streams importTable.ImportLookupTables = importLookupTables; // Address tables -#if NET48 - var importAddressTables = new Dictionary(); -#else var importAddressTables = new Dictionary(); -#endif for (int i = 0; i < importTable.ImportDirectoryTable.Length; i++) { @@ -1181,17 +1133,9 @@ namespace SabreTools.Serialization.Streams { var addresses = importTable.ImportLookupTables .Where(kvp => kvp.Value != null) -#if NET48 - .SelectMany(kvp => kvp.Value) -#else .SelectMany(kvp => kvp.Value!) -#endif .Where(ilte => ilte != null) -#if NET48 - .Select(ilte => (int)ilte.HintNameTableRVA.ConvertVirtualAddress(sections)); -#else .Select(ilte => (int)ilte!.HintNameTableRVA.ConvertVirtualAddress(sections)); -#endif hintNameTableEntryAddresses.AddRange(addresses); } @@ -1200,17 +1144,9 @@ namespace SabreTools.Serialization.Streams { var addresses = importTable.ImportAddressTables .Where(kvp => kvp.Value != null) -#if NET48 - .SelectMany(kvp => kvp.Value) -#else .SelectMany(kvp => kvp.Value!) -#endif .Where(iate => iate != null) -#if NET48 - .Select(iate => (int)iate.HintNameTableRVA.ConvertVirtualAddress(sections)); -#else .Select(iate => (int)iate!.HintNameTableRVA.ConvertVirtualAddress(sections)); -#endif hintNameTableEntryAddresses.AddRange(addresses); } @@ -1251,11 +1187,7 @@ namespace SabreTools.Serialization.Streams /// Section table to use for virtual address translation /// Indicates if this is the top level or not /// Filled resource directory table on success, null on error -#if NET48 - private static ResourceDirectoryTable ParseResourceDirectoryTable(Stream data, long initialOffset, SectionHeader[] sections, bool topLevel = false) -#else private static ResourceDirectoryTable? ParseResourceDirectoryTable(Stream data, long initialOffset, SectionHeader?[] sections, bool topLevel = false) -#endif { // TODO: Use marshalling here instead of building var resourceDirectoryTable = new ResourceDirectoryTable(); @@ -1358,11 +1290,7 @@ namespace SabreTools.Serialization.Streams return resourceDirectoryTable; // Get the section size -#if NET48 - int size = (int)sections.First(s => s != null && s.PointerToRawData == initialOffset).SizeOfRawData; -#else int size = (int)sections.First(s => s != null && s.PointerToRawData == initialOffset)!.SizeOfRawData; -#endif // Align to the 512-byte boundary, we find the start of an MS-DOS header, or the end of the file while (data.Position - initialOffset < size && data.Position % 0x200 != 0 && data.Position < data.Length - 1) diff --git a/Streams/PortableExecutable.Serializer.cs b/Streams/PortableExecutable.Serializer.cs index 24113b38..4950427c 100644 --- a/Streams/PortableExecutable.Serializer.cs +++ b/Streams/PortableExecutable.Serializer.cs @@ -8,10 +8,6 @@ namespace SabreTools.Serialization.Streams public partial class PortableExecutable : IStreamSerializer { /// -#if NET48 - public Stream Serialize(Executable obj) => throw new NotImplementedException(); -#else public Stream? Serialize(Executable? obj) => throw new NotImplementedException(); -#endif } } \ No newline at end of file diff --git a/Streams/Quantum.Deserializer.cs b/Streams/Quantum.Deserializer.cs index 195c476e..8d973d57 100644 --- a/Streams/Quantum.Deserializer.cs +++ b/Streams/Quantum.Deserializer.cs @@ -10,11 +10,7 @@ namespace SabreTools.Serialization.Streams public partial class Quantum : IStreamSerializer { /// -#if NET48 - public Archive Deserialize(Stream data) -#else public Archive? Deserialize(Stream? data) -#endif { // If the data is invalid if (data == null || data.Length == 0 || !data.CanSeek || !data.CanRead) @@ -76,20 +72,12 @@ namespace SabreTools.Serialization.Streams /// /// Stream to parse /// Filled header on success, null on error -#if NET48 - private static Header ParseHeader(Stream data) -#else private static Header? ParseHeader(Stream data) -#endif { // TODO: Use marshalling here instead of building Header header = new Header(); -#if NET48 - byte[] signature = data.ReadBytes(2); -#else byte[]? signature = data.ReadBytes(2); -#endif if (signature == null) return null; @@ -120,11 +108,7 @@ namespace SabreTools.Serialization.Streams fileDescriptor.FileNameSize = ReadVariableLength(data); if (fileDescriptor.FileNameSize > 0) { -#if NET48 - byte[] fileName = data.ReadBytes(fileDescriptor.FileNameSize); -#else byte[]? fileName = data.ReadBytes(fileDescriptor.FileNameSize); -#endif if (fileName != null) fileDescriptor.FileName = Encoding.ASCII.GetString(fileName); } @@ -132,11 +116,7 @@ namespace SabreTools.Serialization.Streams fileDescriptor.CommentFieldSize = ReadVariableLength(data); if (fileDescriptor.CommentFieldSize > 0) { -#if NET48 - byte[] commentField = data.ReadBytes(fileDescriptor.CommentFieldSize); -#else byte[]? commentField = data.ReadBytes(fileDescriptor.CommentFieldSize); -#endif if (commentField != null) fileDescriptor.CommentField = Encoding.ASCII.GetString(commentField); } diff --git a/Streams/Quantum.Serializer.cs b/Streams/Quantum.Serializer.cs index 4713784d..5b442aaa 100644 --- a/Streams/Quantum.Serializer.cs +++ b/Streams/Quantum.Serializer.cs @@ -8,10 +8,6 @@ namespace SabreTools.Serialization.Streams public partial class Quantum : IStreamSerializer { /// -#if NET48 - public Stream Serialize(Archive obj) => throw new NotImplementedException(); -#else public Stream? Serialize(Archive? obj) => throw new NotImplementedException(); -#endif } } \ No newline at end of file diff --git a/Streams/RomCenter.Deserializer.cs b/Streams/RomCenter.Deserializer.cs index bdd8df3e..1d6aea5e 100644 --- a/Streams/RomCenter.Deserializer.cs +++ b/Streams/RomCenter.Deserializer.cs @@ -11,11 +11,7 @@ namespace SabreTools.Serialization.Streams public partial class RomCenter : IStreamSerializer { /// -#if NET48 - public MetadataFile Deserialize(Stream data) -#else public MetadataFile? Deserialize(Stream? data) -#endif { // If the stream is null if (data == null) @@ -50,24 +46,6 @@ namespace SabreTools.Serialization.Streams case IniRowType.SectionHeader: switch (reader.Section?.ToLowerInvariant()) { -#if NET48 - case "credits": - if (dat.Credits == null) - dat.Credits = new Credits(); - break; - case "dat": - if (dat.Dat == null) - dat.Dat = new Dat(); - break; - case "emulator": - if (dat.Emulator == null) - dat.Emulator = new Emulator(); - break; - case "games": - if (dat.Games == null) - dat.Games = new Games(); - break; -#else case "credits": dat.Credits ??= new Credits(); break; @@ -80,7 +58,6 @@ namespace SabreTools.Serialization.Streams case "games": dat.Games ??= new Games(); break; -#endif default: if (reader.CurrentLine != null) additional.Add(reader.CurrentLine); @@ -93,11 +70,7 @@ namespace SabreTools.Serialization.Streams if (reader.Section?.ToLowerInvariant() == "credits") { // Create the section if we haven't already -#if NET48 - dat.Credits = dat.Credits != null ? dat.Credits : new Credits(); -#else dat.Credits ??= new Credits(); -#endif switch (reader.KeyValuePair?.Key?.ToLowerInvariant()) { @@ -133,11 +106,7 @@ namespace SabreTools.Serialization.Streams else if (reader.Section?.ToLowerInvariant() == "dat") { // Create the section if we haven't already -#if NET48 - dat.Dat = dat.Dat != null ? dat.Dat : new Dat(); -#else dat.Dat ??= new Dat(); -#endif switch (reader.KeyValuePair?.Key?.ToLowerInvariant()) { @@ -164,11 +133,7 @@ namespace SabreTools.Serialization.Streams else if (reader.Section?.ToLowerInvariant() == "emulator") { // Create the section if we haven't already -#if NET48 - dat.Emulator = dat.Emulator != null ? dat.Emulator : new Emulator(); -#else dat.Emulator ??= new Emulator(); -#endif switch (reader.KeyValuePair?.Key?.ToLowerInvariant()) { @@ -189,11 +154,7 @@ namespace SabreTools.Serialization.Streams else if (reader.Section?.ToLowerInvariant() == "games") { // Create the section if we haven't already -#if NET48 - dat.Games = dat.Games != null ? dat.Games : new Games(); -#else dat.Games ??= new Games(); -#endif // If the line doesn't contain the delimiter if (!(reader.CurrentLine?.Contains('¬') ?? false)) diff --git a/Streams/RomCenter.Serializer.cs b/Streams/RomCenter.Serializer.cs index 745c31c5..582ed3bc 100644 --- a/Streams/RomCenter.Serializer.cs +++ b/Streams/RomCenter.Serializer.cs @@ -10,11 +10,7 @@ namespace SabreTools.Serialization.Streams public partial class RomCenter : IStreamSerializer { /// -#if NET48 - public Stream Serialize(MetadataFile obj) -#else public Stream? Serialize(MetadataFile? obj) -#endif { // If the metadata file is null if (obj == null) @@ -46,11 +42,7 @@ namespace SabreTools.Serialization.Streams /// /// Credits object representing the credits information /// IniWriter representing the output -#if NET48 - private static void WriteCredits(Credits credits, IniWriter writer) -#else private static void WriteCredits(Credits? credits, IniWriter writer) -#endif { // If the credits information is missing, we can't do anything if (credits == null) @@ -75,11 +67,7 @@ namespace SabreTools.Serialization.Streams /// /// Dat object representing the dat information /// IniWriter representing the output -#if NET48 - private static void WriteDat(Dat dat, IniWriter writer) -#else private static void WriteDat(Dat? dat, IniWriter writer) -#endif { // If the dat information is missing, we can't do anything if (dat == null) @@ -101,11 +89,7 @@ namespace SabreTools.Serialization.Streams /// /// Emulator object representing the emulator information /// IniWriter representing the output -#if NET48 - private static void WriteEmulator(Emulator emulator, IniWriter writer) -#else private static void WriteEmulator(Emulator? emulator, IniWriter writer) -#endif { // If the emulator information is missing, we can't do anything if (emulator == null) @@ -125,11 +109,7 @@ namespace SabreTools.Serialization.Streams /// /// Games object representing the games information /// IniWriter representing the output -#if NET48 - private static void WriteGames(Games games, IniWriter writer) -#else private static void WriteGames(Games? games, IniWriter writer) -#endif { // If the games information is missing, we can't do anything if (games?.Rom == null || !games.Rom.Any()) diff --git a/Streams/SGA.Deserializer.cs b/Streams/SGA.Deserializer.cs index 317ca0db..7f031f13 100644 --- a/Streams/SGA.Deserializer.cs +++ b/Streams/SGA.Deserializer.cs @@ -11,11 +11,7 @@ namespace SabreTools.Serialization.Streams public partial class SGA : IStreamSerializer { /// -#if NET48 - public Models.SGA.File Deserialize(Stream data) -#else public Models.SGA.File? Deserialize(Stream? data) -#endif { // If the data is invalid if (data == null || data.Length == 0 || !data.CanSeek || !data.CanRead) @@ -62,18 +58,10 @@ namespace SabreTools.Serialization.Streams /// /// Stream to parse /// Filled SGA header on success, null on error -#if NET48 - private static Header ParseHeader(Stream data) -#else private static Header? ParseHeader(Stream data) -#endif { // TODO: Use marshalling here instead of building -#if NET48 - byte[] signatureBytes = data.ReadBytes(8); -#else byte[]? signatureBytes = data.ReadBytes(8); -#endif if (signatureBytes == null) return null; @@ -97,11 +85,7 @@ namespace SabreTools.Serialization.Streams header4.MajorVersion = majorVersion; header4.MinorVersion = minorVersion; header4.FileMD5 = data.ReadBytes(0x10); -#if NET48 - byte[] header4Name = data.ReadBytes(count: 128); -#else byte[]? header4Name = data.ReadBytes(count: 128); -#endif if (header4Name != null) header4.Name = Encoding.Unicode.GetString(header4Name).TrimEnd('\0'); header4.HeaderMD5 = data.ReadBytes(0x10); @@ -119,11 +103,7 @@ namespace SabreTools.Serialization.Streams header6.Signature = signature; header6.MajorVersion = majorVersion; header6.MinorVersion = minorVersion; -#if NET48 - byte[] header6Name = data.ReadBytes(count: 128); -#else byte[]? header6Name = data.ReadBytes(count: 128); -#endif if (header6Name != null) header6.Name = Encoding.Unicode.GetString(header6Name).TrimEnd('\0'); header6.HeaderLength = data.ReadUInt32(); @@ -144,11 +124,7 @@ namespace SabreTools.Serialization.Streams /// Stream to parse /// SGA major version /// Filled SGA directory on success, null on error -#if NET48 - private static Models.SGA.Directory ParseDirectory(Stream data, ushort majorVersion) -#else private static Models.SGA.Directory? ParseDirectory(Stream data, ushort majorVersion) -#endif { #region Directory @@ -178,17 +154,10 @@ namespace SabreTools.Serialization.Streams // Set the directory header switch (majorVersion) { -#if NET48 - case 4: (directory as Directory4).DirectoryHeader = directoryHeader as DirectoryHeader4; break; - case 5: (directory as Directory5).DirectoryHeader = directoryHeader as DirectoryHeader5; break; - case 6: (directory as Directory6).DirectoryHeader = directoryHeader as DirectoryHeader5; break; - case 7: (directory as Directory7).DirectoryHeader = directoryHeader as DirectoryHeader7; break; -#else case 4: (directory as Directory4)!.DirectoryHeader = directoryHeader as DirectoryHeader4; break; case 5: (directory as Directory5)!.DirectoryHeader = directoryHeader as DirectoryHeader5; break; case 6: (directory as Directory6)!.DirectoryHeader = directoryHeader as DirectoryHeader5; break; case 7: (directory as Directory7)!.DirectoryHeader = directoryHeader as DirectoryHeader7; break; -#endif default: return null; } @@ -200,17 +169,10 @@ namespace SabreTools.Serialization.Streams long sectionOffset; switch (majorVersion) { -#if NET48 - case 4: sectionOffset = (directoryHeader as DirectoryHeader4).SectionOffset; break; - case 5: - case 6: sectionOffset = (directoryHeader as DirectoryHeader5).SectionOffset; break; - case 7: sectionOffset = (directoryHeader as DirectoryHeader7).SectionOffset; break; -#else case 4: sectionOffset = (directoryHeader as DirectoryHeader4)!.SectionOffset; break; case 5: case 6: sectionOffset = (directoryHeader as DirectoryHeader5)!.SectionOffset; break; case 7: sectionOffset = (directoryHeader as DirectoryHeader7)!.SectionOffset; break; -#endif default: return null; } @@ -228,17 +190,10 @@ namespace SabreTools.Serialization.Streams uint sectionCount; switch (majorVersion) { -#if NET48 - case 4: sectionCount = (directoryHeader as DirectoryHeader4).SectionCount; break; - case 5: - case 6: sectionCount = (directoryHeader as DirectoryHeader5).SectionCount; break; - case 7: sectionCount = (directoryHeader as DirectoryHeader7).SectionCount; break; -#else case 4: sectionCount = (directoryHeader as DirectoryHeader4)!.SectionCount; break; case 5: case 6: sectionCount = (directoryHeader as DirectoryHeader5)!.SectionCount; break; case 7: sectionCount = (directoryHeader as DirectoryHeader7)!.SectionCount; break; -#endif default: return null; } @@ -269,17 +224,10 @@ namespace SabreTools.Serialization.Streams // Assign the sections switch (majorVersion) { -#if NET48 - case 4: (directory as Directory4).Sections = sections as Section4[]; break; - case 5: (directory as Directory5).Sections = sections as Section5[]; break; - case 6: (directory as Directory6).Sections = sections as Section5[]; break; - case 7: (directory as Directory7).Sections = sections as Section5[]; break; -#else case 4: (directory as Directory4)!.Sections = sections as Section4[]; break; case 5: (directory as Directory5)!.Sections = sections as Section5[]; break; case 6: (directory as Directory6)!.Sections = sections as Section5[]; break; case 7: (directory as Directory7)!.Sections = sections as Section5[]; break; -#endif default: return null; } @@ -291,17 +239,10 @@ namespace SabreTools.Serialization.Streams long folderOffset; switch (majorVersion) { -#if NET48 - case 4: folderOffset = (directoryHeader as DirectoryHeader4).FolderOffset; break; - case 5: folderOffset = (directoryHeader as DirectoryHeader5).FolderOffset; break; - case 6: folderOffset = (directoryHeader as DirectoryHeader5).FolderOffset; break; - case 7: folderOffset = (directoryHeader as DirectoryHeader7).FolderOffset; break; -#else case 4: folderOffset = (directoryHeader as DirectoryHeader4)!.FolderOffset; break; case 5: folderOffset = (directoryHeader as DirectoryHeader5)!.FolderOffset; break; case 6: folderOffset = (directoryHeader as DirectoryHeader5)!.FolderOffset; break; case 7: folderOffset = (directoryHeader as DirectoryHeader7)!.FolderOffset; break; -#endif default: return null; } @@ -319,17 +260,10 @@ namespace SabreTools.Serialization.Streams uint folderCount; switch (majorVersion) { -#if NET48 - case 4: folderCount = (directoryHeader as DirectoryHeader4).FolderCount; break; - case 5: folderCount = (directoryHeader as DirectoryHeader5).FolderCount; break; - case 6: folderCount = (directoryHeader as DirectoryHeader5).FolderCount; break; - case 7: folderCount = (directoryHeader as DirectoryHeader7).FolderCount; break; -#else case 4: folderCount = (directoryHeader as DirectoryHeader4)!.FolderCount; break; case 5: folderCount = (directoryHeader as DirectoryHeader5)!.FolderCount; break; case 6: folderCount = (directoryHeader as DirectoryHeader5)!.FolderCount; break; case 7: folderCount = (directoryHeader as DirectoryHeader7)!.FolderCount; break; -#endif default: return null; } @@ -360,17 +294,10 @@ namespace SabreTools.Serialization.Streams // Assign the folders switch (majorVersion) { -#if NET48 - case 4: (directory as Directory4).Folders = folders as Folder4[]; break; - case 5: (directory as Directory5).Folders = folders as Folder5[]; break; - case 6: (directory as Directory6).Folders = folders as Folder5[]; break; - case 7: (directory as Directory7).Folders = folders as Folder5[]; break; -#else case 4: (directory as Directory4)!.Folders = folders as Folder4[]; break; case 5: (directory as Directory5)!.Folders = folders as Folder5[]; break; case 6: (directory as Directory6)!.Folders = folders as Folder5[]; break; case 7: (directory as Directory7)!.Folders = folders as Folder5[]; break; -#endif default: return null; } @@ -382,17 +309,10 @@ namespace SabreTools.Serialization.Streams long fileOffset; switch (majorVersion) { -#if NET48 - case 4: fileOffset = (directoryHeader as DirectoryHeader4).FileOffset; break; - case 5: fileOffset = (directoryHeader as DirectoryHeader5).FileOffset; break; - case 6: fileOffset = (directoryHeader as DirectoryHeader5).FileOffset; break; - case 7: fileOffset = (directoryHeader as DirectoryHeader7).FileOffset; break; -#else case 4: fileOffset = (directoryHeader as DirectoryHeader4)!.FileOffset; break; case 5: fileOffset = (directoryHeader as DirectoryHeader5)!.FileOffset; break; case 6: fileOffset = (directoryHeader as DirectoryHeader5)!.FileOffset; break; case 7: fileOffset = (directoryHeader as DirectoryHeader7)!.FileOffset; break; -#endif default: return null; } @@ -410,17 +330,10 @@ namespace SabreTools.Serialization.Streams uint fileCount; switch (majorVersion) { -#if NET48 - case 4: fileCount = (directoryHeader as DirectoryHeader4).FileCount; break; - case 5: fileCount = (directoryHeader as DirectoryHeader5).FileCount; break; - case 6: fileCount = (directoryHeader as DirectoryHeader5).FileCount; break; - case 7: fileCount = (directoryHeader as DirectoryHeader7).FileCount; break; -#else case 4: fileCount = (directoryHeader as DirectoryHeader4)!.FileCount; break; case 5: fileCount = (directoryHeader as DirectoryHeader5)!.FileCount; break; case 6: fileCount = (directoryHeader as DirectoryHeader5)!.FileCount; break; case 7: fileCount = (directoryHeader as DirectoryHeader7)!.FileCount; break; -#endif default: return null; } @@ -451,17 +364,10 @@ namespace SabreTools.Serialization.Streams // Assign the files switch (majorVersion) { -#if NET48 - case 4: (directory as Directory4).Files = files as File4[]; break; - case 5: (directory as Directory5).Files = files as File4[]; break; - case 6: (directory as Directory6).Files = files as File6[]; break; - case 7: (directory as Directory7).Files = files as File7[]; break; -#else case 4: (directory as Directory4)!.Files = files as File4[]; break; case 5: (directory as Directory5)!.Files = files as File4[]; break; case 6: (directory as Directory6)!.Files = files as File6[]; break; case 7: (directory as Directory7)!.Files = files as File7[]; break; -#endif default: return null; } @@ -473,17 +379,10 @@ namespace SabreTools.Serialization.Streams long stringTableOffset; switch (majorVersion) { -#if NET48 - case 4: stringTableOffset = (directoryHeader as DirectoryHeader4).StringTableOffset; break; - case 5: stringTableOffset = (directoryHeader as DirectoryHeader5).StringTableOffset; break; - case 6: stringTableOffset = (directoryHeader as DirectoryHeader5).StringTableOffset; break; - case 7: stringTableOffset = (directoryHeader as DirectoryHeader7).StringTableOffset; break; -#else case 4: stringTableOffset = (directoryHeader as DirectoryHeader4)!.StringTableOffset; break; case 5: stringTableOffset = (directoryHeader as DirectoryHeader5)!.StringTableOffset; break; case 6: stringTableOffset = (directoryHeader as DirectoryHeader5)!.StringTableOffset; break; case 7: stringTableOffset = (directoryHeader as DirectoryHeader7)!.StringTableOffset; break; -#endif default: return null; } @@ -501,17 +400,10 @@ namespace SabreTools.Serialization.Streams uint stringCount; switch (majorVersion) { -#if NET48 - case 4: stringCount = (directoryHeader as DirectoryHeader4).StringTableCount; break; - case 5: stringCount = (directoryHeader as DirectoryHeader5).StringTableCount; break; - case 6: stringCount = (directoryHeader as DirectoryHeader5).StringTableCount; break; - case 7: stringCount = (directoryHeader as DirectoryHeader7).StringTableCount; break; -#else case 4: stringCount = (directoryHeader as DirectoryHeader4)!.StringTableCount; break; case 5: stringCount = (directoryHeader as DirectoryHeader5)!.StringTableCount; break; case 6: stringCount = (directoryHeader as DirectoryHeader5)!.StringTableCount; break; case 7: stringCount = (directoryHeader as DirectoryHeader7)!.StringTableCount; break; -#endif default: return null; } @@ -519,11 +411,7 @@ namespace SabreTools.Serialization.Streams // TODO: If indexed by position, I think it needs to be adjusted by start of table // Create the strings dictionary -#if NET48 - Dictionary strings = new Dictionary((int)stringCount); -#else Dictionary strings = new Dictionary((int)stringCount); -#endif // Get the current position to adjust the offsets long stringTableStart = data.Position; @@ -538,17 +426,10 @@ namespace SabreTools.Serialization.Streams // Assign the files switch (majorVersion) { -#if NET48 - case 4: (directory as Directory4).StringTable = strings; break; - case 5: (directory as Directory5).StringTable = strings; break; - case 6: (directory as Directory6).StringTable = strings; break; - case 7: (directory as Directory7).StringTable = strings; break; -#else case 4: (directory as Directory4)!.StringTable = strings; break; case 5: (directory as Directory5)!.StringTable = strings; break; case 6: (directory as Directory6)!.StringTable = strings; break; case 7: (directory as Directory7)!.StringTable = strings; break; -#endif default: return null; } @@ -558,33 +439,19 @@ namespace SabreTools.Serialization.Streams uint nameOffset; switch (majorVersion) { -#if NET48 - case 4: nameOffset = (directory as Directory4).Folders[i].NameOffset; break; - case 5: nameOffset = (directory as Directory5).Folders[i].NameOffset; break; - case 6: nameOffset = (directory as Directory6).Folders[i].NameOffset; break; - case 7: nameOffset = (directory as Directory7).Folders[i].NameOffset; break; -#else case 4: nameOffset = (directory as Directory4)!.Folders![i]!.NameOffset; break; case 5: nameOffset = (directory as Directory5)!.Folders![i]!.NameOffset; break; case 6: nameOffset = (directory as Directory6)!.Folders![i]!.NameOffset; break; case 7: nameOffset = (directory as Directory7)!.Folders![i]!.NameOffset; break; -#endif default: return null; } switch (majorVersion) { -#if NET48 - case 4: (directory as Directory4).Folders[i].Name = strings[nameOffset]; break; - case 5: (directory as Directory5).Folders[i].Name = strings[nameOffset]; break; - case 6: (directory as Directory6).Folders[i].Name = strings[nameOffset]; break; - case 7: (directory as Directory7).Folders[i].Name = strings[nameOffset]; break; -#else case 4: (directory as Directory4)!.Folders![i]!.Name = strings[nameOffset]; break; case 5: (directory as Directory5)!.Folders![i]!.Name = strings[nameOffset]; break; case 6: (directory as Directory6)!.Folders![i]!.Name = strings[nameOffset]; break; case 7: (directory as Directory7)!.Folders![i]!.Name = strings[nameOffset]; break; -#endif default: return null; } } @@ -595,33 +462,19 @@ namespace SabreTools.Serialization.Streams uint nameOffset; switch (majorVersion) { -#if NET48 - case 4: nameOffset = (directory as Directory4).Files[i].NameOffset; break; - case 5: nameOffset = (directory as Directory5).Files[i].NameOffset; break; - case 6: nameOffset = (directory as Directory6).Files[i].NameOffset; break; - case 7: nameOffset = (directory as Directory7).Files[i].NameOffset; break; -#else case 4: nameOffset = (directory as Directory4)!.Files![i]!.NameOffset; break; case 5: nameOffset = (directory as Directory5)!.Files![i]!.NameOffset; break; case 6: nameOffset = (directory as Directory6)!.Files![i]!.NameOffset; break; case 7: nameOffset = (directory as Directory7)!.Files![i]!.NameOffset; break; -#endif default: return null; } switch (majorVersion) { -#if NET48 - case 4: (directory as Directory4).Files[i].Name = strings[nameOffset]; break; - case 5: (directory as Directory5).Files[i].Name = strings[nameOffset]; break; - case 6: (directory as Directory6).Files[i].Name = strings[nameOffset]; break; - case 7: (directory as Directory7).Files[i].Name = strings[nameOffset]; break; -#else case 4: (directory as Directory4)!.Files![i]!.Name = strings[nameOffset]; break; case 5: (directory as Directory5)!.Files![i]!.Name = strings[nameOffset]; break; case 6: (directory as Directory6)!.Files![i]!.Name = strings[nameOffset]; break; case 7: (directory as Directory7)!.Files![i]!.Name = strings[nameOffset]; break; -#endif default: return null; } } @@ -637,11 +490,7 @@ namespace SabreTools.Serialization.Streams /// Stream to parse /// SGA major version /// Filled SGA directory header on success, null on error -#if NET48 - private static object ParseDirectoryHeader(Stream data, ushort majorVersion) -#else private static object? ParseDirectoryHeader(Stream data, ushort majorVersion) -#endif { switch (majorVersion) { @@ -728,18 +577,10 @@ namespace SabreTools.Serialization.Streams { Section4 section4 = new Section4(); -#if NET48 - byte[] section4Alias = data.ReadBytes(64); -#else byte[]? section4Alias = data.ReadBytes(64); -#endif if (section4Alias != null) section4.Alias = Encoding.ASCII.GetString(section4Alias).TrimEnd('\0'); -#if NET48 - byte[] section4Name = data.ReadBytes(64); -#else byte[]? section4Name = data.ReadBytes(64); -#endif if (section4Name != null) section4.Name = Encoding.ASCII.GetString(section4Name).TrimEnd('\0'); section4.FolderStartIndex = data.ReadUInt16(); @@ -761,18 +602,10 @@ namespace SabreTools.Serialization.Streams { Section5 section5 = new Section5(); -#if NET48 - byte[] section5Alias = data.ReadBytes(64); -#else byte[]? section5Alias = data.ReadBytes(64); -#endif if (section5Alias != null) section5.Alias = Encoding.ASCII.GetString(section5Alias).TrimEnd('\0'); -#if NET48 - byte[] section5Name = data.ReadBytes(64); -#else byte[]? section5Name = data.ReadBytes(64); -#endif if (section5Name != null) section5.Name = Encoding.ASCII.GetString(section5Name).TrimEnd('\0'); section5.FolderStartIndex = data.ReadUInt32(); diff --git a/Streams/SGA.Serializer.cs b/Streams/SGA.Serializer.cs index 5a5d5e07..e860c777 100644 --- a/Streams/SGA.Serializer.cs +++ b/Streams/SGA.Serializer.cs @@ -7,10 +7,6 @@ namespace SabreTools.Serialization.Streams public partial class SGA : IStreamSerializer { /// -#if NET48 - public Stream Serialize(Models.SGA.File obj) => throw new NotImplementedException(); -#else public Stream? Serialize(Models.SGA.File? obj) => throw new NotImplementedException(); -#endif } } \ No newline at end of file diff --git a/Streams/SeparatedValue.Deserializer.cs b/Streams/SeparatedValue.Deserializer.cs index 87341004..334277f5 100644 --- a/Streams/SeparatedValue.Deserializer.cs +++ b/Streams/SeparatedValue.Deserializer.cs @@ -11,18 +11,10 @@ namespace SabreTools.Serialization.Streams public partial class SeparatedValue : IStreamSerializer { /// -#if NET48 - public MetadataFile Deserialize(Stream data) => Deserialize(data, ','); -#else public MetadataFile? Deserialize(Stream? data) => Deserialize(data, ','); -#endif /// -#if NET48 - public MetadataFile Deserialize(Stream data, char delim) -#else public MetadataFile? Deserialize(Stream? data, char delim) -#endif { // If the stream is null if (data == null) @@ -52,11 +44,7 @@ namespace SabreTools.Serialization.Streams break; // Parse the line into a row -#if NET48 - Row row = null; -#else Row? row = null; -#endif if (reader.Line.Count < Serialization.SeparatedValue.HeaderWithExtendedHashesCount) { row = new Row diff --git a/Streams/SeparatedValue.Serializer.cs b/Streams/SeparatedValue.Serializer.cs index 9e7bb4b4..4ad41117 100644 --- a/Streams/SeparatedValue.Serializer.cs +++ b/Streams/SeparatedValue.Serializer.cs @@ -10,18 +10,10 @@ namespace SabreTools.Serialization.Streams public partial class SeparatedValue : IStreamSerializer { /// -#if NET48 - public Stream Serialize(MetadataFile obj) => Serialize(obj, ','); -#else public Stream? Serialize(MetadataFile? obj) => Serialize(obj, ','); -#endif /// -#if NET48 - public Stream Serialize(MetadataFile obj, char delim) -#else public Stream? Serialize(MetadataFile? obj, char delim) -#endif { // If the metadata file is null if (obj == null) @@ -49,11 +41,7 @@ namespace SabreTools.Serialization.Streams /// SeparatedValueWriter representing the output private static void WriteHeader(SeparatedValueWriter writer) { -#if NET48 - var headerArray = new string[] -#else var headerArray = new string?[] -#endif { "File Name", "Internal Name", @@ -83,11 +71,7 @@ namespace SabreTools.Serialization.Streams /// /// Array of Row objects representing the rows information /// SeparatedValueWriter representing the output -#if NET48 - private static void WriteRows(Row[] rows, SeparatedValueWriter writer) -#else private static void WriteRows(Row[]? rows, SeparatedValueWriter writer) -#endif { // If the games information is missing, we can't do anything if (rows == null || !rows.Any()) @@ -96,11 +80,7 @@ namespace SabreTools.Serialization.Streams // Loop through and write out the rows foreach (var row in rows) { -#if NET48 - var rowArray = new string[] -#else var rowArray = new string?[] -#endif { row.FileName, row.InternalName, diff --git a/Streams/SoftwareList.Serializer.cs b/Streams/SoftwareList.Serializer.cs index 2e270edb..58b07cb6 100644 --- a/Streams/SoftwareList.Serializer.cs +++ b/Streams/SoftwareList.Serializer.cs @@ -5,11 +5,7 @@ namespace SabreTools.Serialization.Streams public partial class SoftwareList : XmlFile { /// -#if NET48 - public Stream SerializeToStreamWithDocType(Models.SoftwareList.SoftwareList obj, string path) -#else public Stream? SerializeToStreamWithDocType(Models.SoftwareList.SoftwareList? obj, string path) -#endif => Serialize(obj, Serialization.SoftawreList.DocTypeName, Serialization.SoftawreList.DocTypePubId, Serialization.SoftawreList.DocTypeSysId, Serialization.SoftawreList.DocTypeSysId); } } \ No newline at end of file diff --git a/Streams/VBSP.Deserializer.cs b/Streams/VBSP.Deserializer.cs index 583cc23e..b59c40d1 100644 --- a/Streams/VBSP.Deserializer.cs +++ b/Streams/VBSP.Deserializer.cs @@ -10,11 +10,7 @@ namespace SabreTools.Serialization.Streams public partial class VBSP : IStreamSerializer { /// -#if NET48 - public Models.VBSP.File Deserialize(Stream data) -#else public Models.VBSP.File? Deserialize(Stream? data) -#endif { // If the data is invalid if (data == null || data.Length == 0 || !data.CanSeek || !data.CanRead) @@ -50,20 +46,12 @@ namespace SabreTools.Serialization.Streams /// /// Stream to parse /// Filled Half-Life 2 Level header on success, null on error -#if NET48 - private static Header ParseHeader(Stream data) -#else private static Header? ParseHeader(Stream data) -#endif { // TODO: Use marshalling here instead of building Header header = new Header(); -#if NET48 - byte[] signature = data.ReadBytes(4); -#else byte[]? signature = data.ReadBytes(4); -#endif if (signature == null) return null; diff --git a/Streams/VBSP.Serializer.cs b/Streams/VBSP.Serializer.cs index 5f179aaa..06f1fd9c 100644 --- a/Streams/VBSP.Serializer.cs +++ b/Streams/VBSP.Serializer.cs @@ -7,10 +7,6 @@ namespace SabreTools.Serialization.Streams public partial class VBSP : IStreamSerializer { /// -#if NET48 - public Stream Serialize(Models.VBSP.File obj) => throw new NotImplementedException(); -#else public Stream? Serialize(Models.VBSP.File? obj) => throw new NotImplementedException(); -#endif } } \ No newline at end of file diff --git a/Streams/VPK.Deserializer.cs b/Streams/VPK.Deserializer.cs index de21ab4a..e278b6d8 100644 --- a/Streams/VPK.Deserializer.cs +++ b/Streams/VPK.Deserializer.cs @@ -11,11 +11,7 @@ namespace SabreTools.Serialization.Streams public partial class VPK : IStreamSerializer { /// -#if NET48 - public Models.VPK.File Deserialize(Stream data) -#else public Models.VPK.File? Deserialize(Stream? data) -#endif { // If the data is invalid if (data == null || data.Length == 0 || !data.CanSeek || !data.CanRead) @@ -97,11 +93,7 @@ namespace SabreTools.Serialization.Streams /// /// Stream to parse /// Filled Valve Package header on success, null on error -#if NET48 - private static Header ParseHeader(Stream data) -#else private static Header? ParseHeader(Stream data) -#endif { // TODO: Use marshalling here instead of building Header header = new Header(); @@ -168,11 +160,7 @@ namespace SabreTools.Serialization.Streams while (true) { // Get the extension -#if NET48 - string extensionString = data.ReadString(Encoding.ASCII); -#else string? extensionString = data.ReadString(Encoding.ASCII); -#endif if (string.IsNullOrEmpty(extensionString)) break; @@ -185,11 +173,7 @@ namespace SabreTools.Serialization.Streams while (true) { // Get the path -#if NET48 - string pathString = data.ReadString(Encoding.ASCII); -#else string? pathString = data.ReadString(Encoding.ASCII); -#endif if (string.IsNullOrEmpty(pathString)) break; @@ -202,11 +186,7 @@ namespace SabreTools.Serialization.Streams while (true) { // Get the name -#if NET48 - string nameString = data.ReadString(Encoding.ASCII); -#else string? nameString = data.ReadString(Encoding.ASCII); -#endif if (string.IsNullOrEmpty(nameString)) break; @@ -261,11 +241,7 @@ namespace SabreTools.Serialization.Streams } // If we had a valid preload data pointer -#if NET48 - byte[] preloadData = null; -#else byte[]? preloadData = null; -#endif if (preloadDataPointer >= 0 && preloadDataLength > 0) { // Cache the current offset diff --git a/Streams/VPK.Serializer.cs b/Streams/VPK.Serializer.cs index 4eba675c..e540a0f4 100644 --- a/Streams/VPK.Serializer.cs +++ b/Streams/VPK.Serializer.cs @@ -7,10 +7,6 @@ namespace SabreTools.Serialization.Streams public partial class VPK : IStreamSerializer { /// -#if NET48 - public Stream Serialize(Models.VPK.File obj) => throw new NotImplementedException(); -#else public Stream? Serialize(Models.VPK.File? obj) => throw new NotImplementedException(); -#endif } } \ No newline at end of file diff --git a/Streams/WAD.Deserializer.cs b/Streams/WAD.Deserializer.cs index 5a3937e0..424b2ceb 100644 --- a/Streams/WAD.Deserializer.cs +++ b/Streams/WAD.Deserializer.cs @@ -10,11 +10,7 @@ namespace SabreTools.Serialization.Streams public partial class WAD : IStreamSerializer { /// -#if NET48 - public Models.WAD.File Deserialize(Stream data) -#else public Models.WAD.File? Deserialize(Stream? data) -#endif { // If the data is invalid if (data == null || data.Length == 0 || !data.CanSeek || !data.CanRead) @@ -65,11 +61,7 @@ namespace SabreTools.Serialization.Streams #region Lump Infos // Create the lump info array -#if NET48 - file.LumpInfos = new LumpInfo[header.LumpCount]; -#else file.LumpInfos = new LumpInfo?[header.LumpCount]; -#endif for (int i = 0; i < header.LumpCount; i++) { var lump = file.Lumps[i]; @@ -111,20 +103,12 @@ namespace SabreTools.Serialization.Streams /// /// Stream to parse /// Filled Half-Life Texture Package header on success, null on error -#if NET48 - private static Header ParseHeader(Stream data) -#else private static Header? ParseHeader(Stream data) -#endif { // TODO: Use marshalling here instead of building Header header = new Header(); -#if NET48 - byte[] signature = data.ReadBytes(4); -#else byte[]? signature = data.ReadBytes(4); -#endif if (signature == null) return null; @@ -155,11 +139,7 @@ namespace SabreTools.Serialization.Streams lump.Compression = data.ReadByteValue(); lump.Padding0 = data.ReadByteValue(); lump.Padding1 = data.ReadByteValue(); -#if NET48 - byte[] name = data.ReadBytes(16); -#else byte[]? name = data.ReadBytes(16); -#endif if (name != null) lump.Name = Encoding.ASCII.GetString(name).TrimEnd('\0'); @@ -173,11 +153,7 @@ namespace SabreTools.Serialization.Streams /// Lump type /// Mipmap level /// Filled Half-Life Texture Package lump info on success, null on error -#if NET48 - private static LumpInfo ParseLumpInfo(Stream data, byte type, uint mipmap = 0) -#else private static LumpInfo? ParseLumpInfo(Stream data, byte type, uint mipmap = 0) -#endif { // TODO: Use marshalling here instead of building LumpInfo lumpInfo = new LumpInfo(); @@ -201,11 +177,7 @@ namespace SabreTools.Serialization.Streams if (mipmap > 3) return null; -#if NET48 - byte[] name = data.ReadBytes(16); -#else byte[]? name = data.ReadBytes(16); -#endif if (name != null) lumpInfo.Name = Encoding.ASCII.GetString(name); lumpInfo.Width = data.ReadUInt32(); diff --git a/Streams/WAD.Serializer.cs b/Streams/WAD.Serializer.cs index 058e9c95..d33a7c42 100644 --- a/Streams/WAD.Serializer.cs +++ b/Streams/WAD.Serializer.cs @@ -7,10 +7,6 @@ namespace SabreTools.Serialization.Streams public partial class WAD : IStreamSerializer { /// -#if NET48 - public Stream Serialize(Models.WAD.File obj) => throw new NotImplementedException(); -#else public Stream? Serialize(Models.WAD.File? obj) => throw new NotImplementedException(); -#endif } } \ No newline at end of file diff --git a/Streams/XCP.Deserializer.cs b/Streams/XCP.Deserializer.cs index 3c89eb8d..b4750ddb 100644 --- a/Streams/XCP.Deserializer.cs +++ b/Streams/XCP.Deserializer.cs @@ -10,11 +10,7 @@ namespace SabreTools.Serialization.Streams public partial class XZP : IStreamSerializer { /// -#if NET48 - public Models.XZP.File Deserialize(Stream data) -#else public Models.XZP.File? Deserialize(Stream? data) -#endif { // If the data is invalid if (data == null || data.Length == 0 || !data.CanSeek || !data.CanRead) @@ -138,20 +134,12 @@ namespace SabreTools.Serialization.Streams /// /// Stream to parse /// Filled XBox Package File header on success, null on error -#if NET48 - private static Header ParseHeader(Stream data) -#else private static Header? ParseHeader(Stream data) -#endif { // TODO: Use marshalling here instead of building Header header = new Header(); -#if NET48 - byte[] signature = data.ReadBytes(4); -#else byte[]? signature = data.ReadBytes(4); -#endif if (signature == null) return null; @@ -240,21 +228,13 @@ namespace SabreTools.Serialization.Streams /// /// Stream to parse /// Filled XBox Package File footer on success, null on error -#if NET48 - private static Footer ParseFooter(Stream data) -#else private static Footer? ParseFooter(Stream data) -#endif { // TODO: Use marshalling here instead of building Footer footer = new Footer(); footer.FileLength = data.ReadUInt32(); -#if NET48 - byte[] signature = data.ReadBytes(4); -#else byte[]? signature = data.ReadBytes(4); -#endif if (signature == null) return null; diff --git a/Streams/XCP.Serializer.cs b/Streams/XCP.Serializer.cs index b1186750..bf4772eb 100644 --- a/Streams/XCP.Serializer.cs +++ b/Streams/XCP.Serializer.cs @@ -7,10 +7,6 @@ namespace SabreTools.Serialization.Streams public partial class XZP : IStreamSerializer { /// -#if NET48 - public Stream Serialize(Models.XZP.File obj) => throw new NotImplementedException(); -#else public Stream? Serialize(Models.XZP.File? obj) => throw new NotImplementedException(); -#endif } } \ No newline at end of file diff --git a/Streams/XmlFile.Deserializer.cs b/Streams/XmlFile.Deserializer.cs index e74912d5..292a1f59 100644 --- a/Streams/XmlFile.Deserializer.cs +++ b/Streams/XmlFile.Deserializer.cs @@ -13,11 +13,7 @@ namespace SabreTools.Serialization.Streams public partial class XmlFile : IStreamSerializer { /// -#if NET48 - public T Deserialize(Stream data) -#else public T? Deserialize(Stream? data) -#endif { // If the stream is null if (data == null) @@ -36,11 +32,7 @@ namespace SabreTools.Serialization.Streams var xmlReader = XmlReader.Create(streamReader, settings); // Perform the deserialization and return -#if NET48 - return (T)serializer.Deserialize(xmlReader); -#else return (T?)serializer.Deserialize(xmlReader); -#endif } } } \ No newline at end of file diff --git a/Streams/XmlFile.Serializer.cs b/Streams/XmlFile.Serializer.cs index 2474f779..ce53e4a2 100644 --- a/Streams/XmlFile.Serializer.cs +++ b/Streams/XmlFile.Serializer.cs @@ -17,11 +17,7 @@ namespace SabreTools.Serialization.Streams /// /// Data to serialize /// Stream containing serialized data on success, null otherwise -#if NET48 - public Stream Serialize(T obj) -#else public Stream? Serialize(T? obj) -#endif => Serialize(obj, null, null, null, null); /// @@ -33,11 +29,7 @@ namespace SabreTools.Serialization.Streams /// Optional DOCTYPE sysid /// Optional DOCTYPE name /// Stream containing serialized data on success, null otherwise -#if NET48 - public Stream Serialize(T obj, string name = null, string pubid = null, string sysid = null, string subset = null) -#else public Stream? Serialize(T? obj, string? name = null, string? pubid = null, string? sysid = null, string? subset = null) -#endif { // If the object is null if (obj == null) diff --git a/Strings/XMID.Deserializer.cs b/Strings/XMID.Deserializer.cs index 1fcbac4a..0780d45a 100644 --- a/Strings/XMID.Deserializer.cs +++ b/Strings/XMID.Deserializer.cs @@ -5,16 +5,12 @@ namespace SabreTools.Serialization.Strings public partial class XMID : IStringSerializer { /// -#if NET48 - public Models.Xbox.XMID Deserialize(string path) -#else - public Models.Xbox.XMID? Deserialize(string? path) -#endif + public Models.Xbox.XMID? Deserialize(string? str) { - if (string.IsNullOrWhiteSpace(path)) + if (string.IsNullOrWhiteSpace(str)) return null; - string xmid = path.TrimEnd('\0'); + string xmid = str!.TrimEnd('\0'); if (string.IsNullOrWhiteSpace(xmid)) return null; @@ -26,11 +22,7 @@ namespace SabreTools.Serialization.Strings /// /// XMID string to attempt to parse /// Filled XMID on success, null on error -#if NET48 - private static Models.Xbox.XMID ParseXMID(string xmidString) -#else private static Models.Xbox.XMID? ParseXMID(string? xmidString) -#endif { if (xmidString == null || xmidString.Length != 8) return null; diff --git a/Strings/XMID.Serializer.cs b/Strings/XMID.Serializer.cs index 96e410d7..c8fd342a 100644 --- a/Strings/XMID.Serializer.cs +++ b/Strings/XMID.Serializer.cs @@ -6,11 +6,7 @@ namespace SabreTools.Serialization.Strings public partial class XMID : IStringSerializer { /// -#if NET48 - public string Serialize(Models.Xbox.XMID obj) -#else public string? Serialize(Models.Xbox.XMID? obj) -#endif { if (obj == null) return null; diff --git a/Strings/XeMID.Deserializer.cs b/Strings/XeMID.Deserializer.cs index e5bbbf4b..d7ba6682 100644 --- a/Strings/XeMID.Deserializer.cs +++ b/Strings/XeMID.Deserializer.cs @@ -5,16 +5,12 @@ namespace SabreTools.Serialization.Strings public partial class XeMID : IStringSerializer { /// -#if NET48 - public Models.Xbox.XeMID Deserialize(string path) -#else - public Models.Xbox.XeMID? Deserialize(string? path) -#endif + public Models.Xbox.XeMID? Deserialize(string? str) { - if (string.IsNullOrWhiteSpace(path)) + if (string.IsNullOrWhiteSpace(str)) return null; - string xemid = path.TrimEnd('\0'); + string xemid = str!.TrimEnd('\0'); if (string.IsNullOrWhiteSpace(xemid)) return null; @@ -26,11 +22,7 @@ namespace SabreTools.Serialization.Strings /// /// XeMID string to attempt to parse /// Filled XeMID on success, null on error -#if NET48 - private static Models.Xbox.XeMID ParseXeMID(string xemidString) -#else private static Models.Xbox.XeMID? ParseXeMID(string? xemidString) -#endif { if (xemidString == null) return null; diff --git a/Strings/XeMID.Serializer.cs b/Strings/XeMID.Serializer.cs index dc232c8a..ef05a6a7 100644 --- a/Strings/XeMID.Serializer.cs +++ b/Strings/XeMID.Serializer.cs @@ -6,11 +6,7 @@ namespace SabreTools.Serialization.Strings public partial class XeMID : IStringSerializer { /// -#if NET48 - public string Serialize(Models.Xbox.XeMID obj) -#else public string? Serialize(Models.Xbox.XeMID? obj) -#endif { if (obj == null) return null; diff --git a/Wrappers/AACSMediaKeyBlock.cs b/Wrappers/AACSMediaKeyBlock.cs index 76360978..f99fe189 100644 --- a/Wrappers/AACSMediaKeyBlock.cs +++ b/Wrappers/AACSMediaKeyBlock.cs @@ -15,22 +15,14 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// -#if NET48 - public AACSMediaKeyBlock(MediaKeyBlock model, byte[] data, int offset) -#else public AACSMediaKeyBlock(MediaKeyBlock? model, byte[]? data, int offset) -#endif : base(model, data, offset) { // All logic is handled by the base class } /// -#if NET48 - public AACSMediaKeyBlock(MediaKeyBlock model, Stream data) -#else public AACSMediaKeyBlock(MediaKeyBlock? model, Stream? data) -#endif : base(model, data) { // All logic is handled by the base class @@ -42,11 +34,7 @@ namespace SabreTools.Serialization.Wrappers /// Byte array representing the archive /// Offset within the array to parse /// An AACS media key block wrapper on success, null on failure -#if NET48 - public static AACSMediaKeyBlock Create(byte[] data, int offset) -#else public static AACSMediaKeyBlock? Create(byte[]? data, int offset) -#endif { // If the data is invalid if (data == null) @@ -66,11 +54,7 @@ namespace SabreTools.Serialization.Wrappers /// /// Stream representing the archive /// An AACS media key block wrapper on success, null on failure -#if NET48 - public static AACSMediaKeyBlock Create(Stream data) -#else public static AACSMediaKeyBlock? Create(Stream? data) -#endif { // If the data is invalid if (data == null || data.Length == 0 || !data.CanSeek || !data.CanRead) diff --git a/Wrappers/BDPlusSVM.cs b/Wrappers/BDPlusSVM.cs index d5e46a2b..9e3037da 100644 --- a/Wrappers/BDPlusSVM.cs +++ b/Wrappers/BDPlusSVM.cs @@ -15,22 +15,14 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// -#if NET48 - public BDPlusSVM(SVM model, byte[] data, int offset) -#else public BDPlusSVM(SVM? model, byte[]? data, int offset) -#endif : base(model, data, offset) { // All logic is handled by the base class } /// -#if NET48 - public BDPlusSVM(SVM model, Stream data) -#else public BDPlusSVM(SVM? model, Stream? data) -#endif : base(model, data) { // All logic is handled by the base class @@ -42,11 +34,7 @@ namespace SabreTools.Serialization.Wrappers /// Byte array representing the archive /// Offset within the array to parse /// A BD+ SVM wrapper on success, null on failure -#if NET48 - public static BDPlusSVM Create(byte[] data, int offset) -#else public static BDPlusSVM? Create(byte[]? data, int offset) -#endif { // If the data is invalid if (data == null) @@ -66,11 +54,7 @@ namespace SabreTools.Serialization.Wrappers /// /// Stream representing the archive /// A BD+ SVM wrapper on success, null on failure -#if NET48 - public static BDPlusSVM Create(Stream data) -#else public static BDPlusSVM? Create(Stream? data) -#endif { // If the data is invalid if (data == null || data.Length == 0 || !data.CanSeek || !data.CanRead) diff --git a/Wrappers/BFPK.cs b/Wrappers/BFPK.cs index c798c00e..2d0513b0 100644 --- a/Wrappers/BFPK.cs +++ b/Wrappers/BFPK.cs @@ -14,22 +14,14 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// -#if NET48 - public BFPK(Models.BFPK.Archive model, byte[] data, int offset) -#else public BFPK(Models.BFPK.Archive? model, byte[]? data, int offset) -#endif : base(model, data, offset) { // All logic is handled by the base class } /// -#if NET48 - public BFPK(Models.BFPK.Archive model, Stream data) -#else public BFPK(Models.BFPK.Archive? model, Stream? data) -#endif : base(model, data) { // All logic is handled by the base class @@ -41,11 +33,7 @@ namespace SabreTools.Serialization.Wrappers /// Byte array representing the archive /// Offset within the array to parse /// A BFPK archive wrapper on success, null on failure -#if NET48 - public static BFPK Create(byte[] data, int offset) -#else public static BFPK? Create(byte[]? data, int offset) -#endif { // If the data is invalid if (data == null) @@ -65,11 +53,7 @@ namespace SabreTools.Serialization.Wrappers /// /// Stream representing the archive /// A BFPK archive wrapper on success, null on failure -#if NET48 - public static BFPK Create(Stream data) -#else public static BFPK? Create(Stream? data) -#endif { // If the data is invalid if (data == null || data.Length == 0 || !data.CanSeek || !data.CanRead) diff --git a/Wrappers/BSP.cs b/Wrappers/BSP.cs index aa6d3aac..5fca10a5 100644 --- a/Wrappers/BSP.cs +++ b/Wrappers/BSP.cs @@ -14,22 +14,14 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// -#if NET48 - public BSP(Models.BSP.File model, byte[] data, int offset) -#else public BSP(Models.BSP.File? model, byte[]? data, int offset) -#endif : base(model, data, offset) { // All logic is handled by the base class } /// -#if NET48 - public BSP(Models.BSP.File model, Stream data) -#else public BSP(Models.BSP.File? model, Stream? data) -#endif : base(model, data) { // All logic is handled by the base class @@ -41,11 +33,7 @@ namespace SabreTools.Serialization.Wrappers /// Byte array representing the BSP /// Offset within the array to parse /// A BSP wrapper on success, null on failure -#if NET48 - public static BSP Create(byte[] data, int offset) -#else public static BSP? Create(byte[]? data, int offset) -#endif { // If the data is invalid if (data == null) @@ -65,11 +53,7 @@ namespace SabreTools.Serialization.Wrappers /// /// Stream representing the BSP /// An BSP wrapper on success, null on failure -#if NET48 - public static BSP Create(Stream data) -#else public static BSP? Create(Stream? data) -#endif { // If the data is invalid if (data == null || data.Length == 0 || !data.CanSeek || !data.CanRead) diff --git a/Wrappers/CFB.cs b/Wrappers/CFB.cs index 20356ddb..3807443a 100644 --- a/Wrappers/CFB.cs +++ b/Wrappers/CFB.cs @@ -18,42 +18,26 @@ namespace SabreTools.Serialization.Wrappers /// /// Normal sector size in bytes /// -#if NET48 - public long SectorSize => (long)Math.Pow(2, this.Model.Header.SectorShift); -#else public long SectorSize => (long)Math.Pow(2, this.Model.Header?.SectorShift ?? 0); -#endif /// /// Mini sector size in bytes /// -#if NET48 - public long MiniSectorSize => (long)Math.Pow(2, this.Model.Header.MiniSectorShift); -#else public long MiniSectorSize => (long)Math.Pow(2, this.Model.Header?.MiniSectorShift ?? 0); -#endif #endregion #region Constructors /// -#if NET48 - public CFB(Models.CFB.Binary model, byte[] data, int offset) -#else public CFB(Models.CFB.Binary? model, byte[]? data, int offset) -#endif : base(model, data, offset) { // All logic is handled by the base class } /// -#if NET48 - public CFB(Models.CFB.Binary model, Stream data) -#else public CFB(Models.CFB.Binary? model, Stream? data) -#endif : base(model, data) { // All logic is handled by the base class @@ -65,11 +49,7 @@ namespace SabreTools.Serialization.Wrappers /// Byte array representing the archive /// Offset within the array to parse /// A Compound File Binary wrapper on success, null on failure -#if NET48 - public static CFB Create(byte[] data, int offset) -#else public static CFB? Create(byte[]? data, int offset) -#endif { // If the data is invalid if (data == null) @@ -89,11 +69,7 @@ namespace SabreTools.Serialization.Wrappers /// /// Stream representing the archive /// A Compound File Binary wrapper on success, null on failure -#if NET48 - public static CFB Create(Stream data) -#else public static CFB? Create(Stream? data) -#endif { // If the data is invalid if (data == null || data.Length == 0 || !data.CanSeek || !data.CanRead) @@ -122,41 +98,23 @@ namespace SabreTools.Serialization.Wrappers /// /// Initial FAT sector /// Ordered list of sector numbers, null on error -#if NET48 - public List GetFATSectorChain(Models.CFB.SectorNumber startingSector) -#else public List? GetFATSectorChain(Models.CFB.SectorNumber? startingSector) -#endif { // If we have an invalid sector -#if NET48 - if (startingSector < 0 || this.Model.FATSectorNumbers == null || (long)startingSector >= this.Model.FATSectorNumbers.Length) -#else if (startingSector == null || startingSector < 0 || this.Model.FATSectorNumbers == null || (long)startingSector >= this.Model.FATSectorNumbers.Length) -#endif return null; // Setup the returned list -#if NET48 - var sectors = new List { startingSector }; -#else var sectors = new List { startingSector }; -#endif var lastSector = startingSector; while (true) { -#if NET6_0_OR_GREATER if (lastSector == null) break; -#endif // Get the next sector from the lookup table -#if NET48 - var nextSector = this.Model.FATSectorNumbers[(uint)lastSector]; -#else var nextSector = this.Model.FATSectorNumbers[(uint)lastSector!.Value]; -#endif // If we have an end of chain or free sector if (nextSector == SabreTools.Models.CFB.SectorNumber.ENDOFCHAIN || nextSector == SabreTools.Models.CFB.SectorNumber.FREESECT) @@ -175,11 +133,7 @@ namespace SabreTools.Serialization.Wrappers /// /// Initial FAT sector /// Ordered list of sector numbers, null on error -#if NET48 - public byte[] GetFATSectorChainData(Models.CFB.SectorNumber startingSector) -#else public byte[]? GetFATSectorChainData(Models.CFB.SectorNumber startingSector) -#endif { // Get the sector chain first var sectorChain = GetFATSectorChain(startingSector); @@ -212,18 +166,10 @@ namespace SabreTools.Serialization.Wrappers /// /// Sector to convert /// File offset in bytes, -1 on error -#if NET48 - public long FATSectorToFileOffset(Models.CFB.SectorNumber sector) -#else public long FATSectorToFileOffset(Models.CFB.SectorNumber? sector) -#endif { // If we have an invalid sector number -#if NET48 - if (sector > SabreTools.Models.CFB.SectorNumber.MAXREGSECT) -#else if (sector == null || sector > SabreTools.Models.CFB.SectorNumber.MAXREGSECT) -#endif return -1; // Convert based on the sector shift value @@ -239,41 +185,23 @@ namespace SabreTools.Serialization.Wrappers /// /// Initial Mini FAT sector /// Ordered list of sector numbers, null on error -#if NET48 - public List GetMiniFATSectorChain(Models.CFB.SectorNumber startingSector) -#else public List? GetMiniFATSectorChain(Models.CFB.SectorNumber? startingSector) -#endif { // If we have an invalid sector -#if NET48 - if (startingSector < 0 || this.Model.MiniFATSectorNumbers == null || (long)startingSector >= this.Model.MiniFATSectorNumbers.Length) -#else if (startingSector == null || startingSector < 0 || this.Model.MiniFATSectorNumbers == null || (long)startingSector >= this.Model.MiniFATSectorNumbers.Length) -#endif return null; // Setup the returned list -#if NET48 - var sectors = new List { startingSector }; -#else var sectors = new List { startingSector }; -#endif var lastSector = startingSector; while (true) { -#if NET6_0_OR_GREATER if (lastSector == null) break; -#endif // Get the next sector from the lookup table -#if NET48 - var nextSector = this.Model.MiniFATSectorNumbers[(uint)lastSector]; -#else var nextSector = this.Model.MiniFATSectorNumbers[(uint)lastSector!.Value]; -#endif // If we have an end of chain or free sector if (nextSector == SabreTools.Models.CFB.SectorNumber.ENDOFCHAIN || nextSector == SabreTools.Models.CFB.SectorNumber.FREESECT) @@ -292,11 +220,7 @@ namespace SabreTools.Serialization.Wrappers /// /// Initial Mini FAT sector /// Ordered list of sector numbers, null on error -#if NET48 - public byte[] GetMiniFATSectorChainData(Models.CFB.SectorNumber startingSector) -#else public byte[]? GetMiniFATSectorChainData(Models.CFB.SectorNumber startingSector) -#endif { // Get the sector chain first var sectorChain = GetMiniFATSectorChain(startingSector); @@ -329,18 +253,10 @@ namespace SabreTools.Serialization.Wrappers /// /// Sector to convert /// File offset in bytes, -1 on error -#if NET48 - public long MiniFATSectorToFileOffset(Models.CFB.SectorNumber sector) -#else public long MiniFATSectorToFileOffset(Models.CFB.SectorNumber? sector) -#endif { // If we have an invalid sector number -#if NET48 - if (sector > SabreTools.Models.CFB.SectorNumber.MAXREGSECT) -#else if (sector == null || sector > SabreTools.Models.CFB.SectorNumber.MAXREGSECT) -#endif return -1; // Convert based on the sector shift value diff --git a/Wrappers/CIA.cs b/Wrappers/CIA.cs index 91fde5fd..b46ac045 100644 --- a/Wrappers/CIA.cs +++ b/Wrappers/CIA.cs @@ -14,22 +14,14 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// -#if NET48 - public CIA(Models.N3DS.CIA model, byte[] data, int offset) -#else public CIA(Models.N3DS.CIA? model, byte[]? data, int offset) -#endif : base(model, data, offset) { // All logic is handled by the base class } /// -#if NET48 - public CIA(Models.N3DS.CIA model, Stream data) -#else public CIA(Models.N3DS.CIA? model, Stream? data) -#endif : base(model, data) { // All logic is handled by the base class @@ -41,11 +33,7 @@ namespace SabreTools.Serialization.Wrappers /// Byte array representing the archive /// Offset within the array to parse /// A CIA archive wrapper on success, null on failure -#if NET48 - public static CIA Create(byte[] data, int offset) -#else public static CIA? Create(byte[]? data, int offset) -#endif { // If the data is invalid if (data == null) @@ -65,11 +53,7 @@ namespace SabreTools.Serialization.Wrappers /// /// Stream representing the archive /// A CIA archive wrapper on success, null on failure -#if NET48 - public static CIA Create(Stream data) -#else public static CIA? Create(Stream? data) -#endif { // If the data is invalid if (data == null || data.Length == 0 || !data.CanSeek || !data.CanRead) diff --git a/Wrappers/ConcreteInterfaceSerializer.cs b/Wrappers/ConcreteInterfaceSerializer.cs index eefb5e1c..315026d9 100644 --- a/Wrappers/ConcreteInterfaceSerializer.cs +++ b/Wrappers/ConcreteInterfaceSerializer.cs @@ -1,4 +1,4 @@ -#if NET6_0_OR_GREATER +#if !NETFRAMEWORK using System; using System.Reflection; using System.Text.Json; diff --git a/Wrappers/GCF.cs b/Wrappers/GCF.cs index 4269aa1e..8505b294 100644 --- a/Wrappers/GCF.cs +++ b/Wrappers/GCF.cs @@ -17,11 +17,7 @@ namespace SabreTools.Serialization.Wrappers /// /// Set of all files and their information /// -#if NET48 - public FileInfo[] Files -#else public FileInfo[]? Files -#endif { get { @@ -54,11 +50,7 @@ namespace SabreTools.Serialization.Wrappers Encrypted = directoryEntry.DirectoryFlags.HasFlag(Models.GCF.HL_GCF_FLAG.HL_GCF_FLAG_ENCRYPTED), }; var pathParts = new List { directoryEntry.Name ?? string.Empty }; -#if NET48 - var blockEntries = new List(); -#else var blockEntries = new List(); -#endif // Traverse the parent tree uint index = directoryEntry.ParentIndex; @@ -104,11 +96,7 @@ namespace SabreTools.Serialization.Wrappers /// /// Set of all data block offsets /// -#if NET48 - public long[] DataBlockOffsets -#else public long[]? DataBlockOffsets -#endif { get { @@ -116,11 +104,9 @@ namespace SabreTools.Serialization.Wrappers if (_dataBlockOffsets != null) return _dataBlockOffsets; -#if NET6_0_OR_GREATER // If we don't have a block count, offset, or size if (this.Model.DataBlockHeader?.BlockCount == null || this.Model.DataBlockHeader?.FirstBlockOffset == null || this.Model.DataBlockHeader?.BlockSize == null) return null; -#endif // Otherwise, build the data block set _dataBlockOffsets = new long[this.Model.DataBlockHeader.BlockCount]; @@ -142,42 +128,26 @@ namespace SabreTools.Serialization.Wrappers /// /// Set of all files and their information /// -#if NET48 - private FileInfo[] _files = null; -#else private FileInfo[]? _files = null; -#endif /// /// Set of all data block offsets /// -#if NET48 - private long[] _dataBlockOffsets = null; -#else private long[]? _dataBlockOffsets = null; -#endif #endregion #region Constructors /// -#if NET48 - public GCF(Models.GCF.File model, byte[] data, int offset) -#else public GCF(Models.GCF.File? model, byte[]? data, int offset) -#endif : base(model, data, offset) { // All logic is handled by the base class } /// -#if NET48 - public GCF(Models.GCF.File model, Stream data) -#else public GCF(Models.GCF.File? model, Stream? data) -#endif : base(model, data) { // All logic is handled by the base class @@ -189,11 +159,7 @@ namespace SabreTools.Serialization.Wrappers /// Byte array representing the GCF /// Offset within the array to parse /// An GCF wrapper on success, null on failure -#if NET48 - public static GCF Create(byte[] data, int offset) -#else public static GCF? Create(byte[]? data, int offset) -#endif { // If the data is invalid if (data == null) @@ -213,11 +179,7 @@ namespace SabreTools.Serialization.Wrappers /// /// Stream representing the GCF /// An GCF wrapper on success, null on failure -#if NET48 - public static GCF Create(Stream data) -#else public static GCF? Create(Stream? data) -#endif { // If the data is invalid if (data == null || data.Length == 0 || !data.CanSeek || !data.CanRead) @@ -249,11 +211,7 @@ namespace SabreTools.Serialization.Wrappers /// /// Full item path /// -#if NET48 - public string Path; -#else public string? Path; -#endif /// /// File size @@ -268,11 +226,7 @@ namespace SabreTools.Serialization.Wrappers /// /// Array of block entries /// -#if NET48 - public SabreTools.Models.GCF.BlockEntry[] BlockEntries; -#else public SabreTools.Models.GCF.BlockEntry?[]? BlockEntries; -#endif } #endregion diff --git a/Wrappers/IRD.cs b/Wrappers/IRD.cs index e4676718..0e330825 100644 --- a/Wrappers/IRD.cs +++ b/Wrappers/IRD.cs @@ -14,22 +14,14 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// -#if NET48 - public IRD(Models.IRD.IRD model, byte[] data, int offset) -#else public IRD(Models.IRD.IRD? model, byte[]? data, int offset) -#endif : base(model, data, offset) { // All logic is handled by the base class } /// -#if NET48 - public IRD(Models.IRD.IRD model, Stream data) -#else public IRD(Models.IRD.IRD? model, Stream? data) -#endif : base(model, data) { // All logic is handled by the base class @@ -41,11 +33,7 @@ namespace SabreTools.Serialization.Wrappers /// Byte array representing the archive /// Offset within the array to parse /// An IRD wrapper on success, null on failure -#if NET48 - public static IRD Create(byte[] data, int offset) -#else public static IRD? Create(byte[]? data, int offset) -#endif { // If the data is invalid if (data == null) @@ -65,11 +53,7 @@ namespace SabreTools.Serialization.Wrappers /// /// Stream representing the archive /// An IRD wrapper on success, null on failure -#if NET48 - public static IRD Create(Stream data) -#else public static IRD? Create(Stream? data) -#endif { // If the data is invalid if (data == null || data.Length == 0 || !data.CanSeek || !data.CanRead) diff --git a/Wrappers/InstallShieldCabinet.cs b/Wrappers/InstallShieldCabinet.cs index 365779a1..3a83bcc9 100644 --- a/Wrappers/InstallShieldCabinet.cs +++ b/Wrappers/InstallShieldCabinet.cs @@ -41,22 +41,14 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// -#if NET48 - public InstallShieldCabinet(Models.InstallShieldCabinet.Cabinet model, byte[] data, int offset) -#else public InstallShieldCabinet(Models.InstallShieldCabinet.Cabinet? model, byte[]? data, int offset) -#endif : base(model, data, offset) { // All logic is handled by the base class } /// -#if NET48 - public InstallShieldCabinet(Models.InstallShieldCabinet.Cabinet model, Stream data) -#else public InstallShieldCabinet(Models.InstallShieldCabinet.Cabinet? model, Stream? data) -#endif : base(model, data) { // All logic is handled by the base class @@ -68,11 +60,7 @@ namespace SabreTools.Serialization.Wrappers /// Byte array representing the cabinet /// Offset within the array to parse /// A cabinet wrapper on success, null on failure -#if NET48 - public static InstallShieldCabinet Create(byte[] data, int offset) -#else public static InstallShieldCabinet? Create(byte[]? data, int offset) -#endif { // If the data is invalid if (data == null) @@ -92,11 +80,7 @@ namespace SabreTools.Serialization.Wrappers /// /// Stream representing the cabinet /// A cabinet wrapper on success, null on failure -#if NET48 - public static InstallShieldCabinet Create(Stream data) -#else public static InstallShieldCabinet? Create(Stream? data) -#endif { // If the data is invalid if (data == null || data.Length == 0 || !data.CanSeek || !data.CanRead) diff --git a/Wrappers/LinearExecutable.cs b/Wrappers/LinearExecutable.cs index 0fecd79f..4f7e602f 100644 --- a/Wrappers/LinearExecutable.cs +++ b/Wrappers/LinearExecutable.cs @@ -15,22 +15,14 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// -#if NET48 - public LinearExecutable(Models.LinearExecutable.Executable model, byte[] data, int offset) -#else public LinearExecutable(Models.LinearExecutable.Executable? model, byte[]? data, int offset) -#endif : base(model, data, offset) { // All logic is handled by the base class } /// -#if NET48 - public LinearExecutable(Models.LinearExecutable.Executable model, Stream data) -#else public LinearExecutable(Models.LinearExecutable.Executable? model, Stream? data) -#endif : base(model, data) { // All logic is handled by the base class @@ -40,11 +32,7 @@ namespace SabreTools.Serialization.Wrappers /// Byte array representing the executable /// Offset within the array to parse /// An LE/LX executable wrapper on success, null on failure -#if NET48 - public static LinearExecutable Create(byte[] data, int offset) -#else public static LinearExecutable? Create(byte[]? data, int offset) -#endif { // If the data is invalid if (data == null) @@ -64,11 +52,7 @@ namespace SabreTools.Serialization.Wrappers /// /// Stream representing the executable /// An LE/LX executable wrapper on success, null on failure -#if NET48 - public static LinearExecutable Create(Stream data) -#else public static LinearExecutable? Create(Stream? data) -#endif { // If the data is invalid if (data == null || data.Length == 0 || !data.CanSeek || !data.CanRead) @@ -99,11 +83,7 @@ namespace SabreTools.Serialization.Wrappers /// How many bytes to read, -1 means read until end /// Byte array representing the range, null on error [Obsolete] -#if NET48 - public byte[] ReadArbitraryRange(int rangeStart = -1, int length = -1) -#else public byte[]? ReadArbitraryRange(int rangeStart = -1, int length = -1) -#endif { // If we have an unset range start, read from the start of the source if (rangeStart == -1) @@ -115,19 +95,11 @@ namespace SabreTools.Serialization.Wrappers switch (_dataSource) { case DataSource.ByteArray: -#if NET48 - length = _byteArrayData.Length - _byteArrayOffset; -#else length = _byteArrayData!.Length - _byteArrayOffset; -#endif break; case DataSource.Stream: -#if NET48 - length = (int)_streamData.Length; -#else length = (int)_streamData!.Length; -#endif break; } } diff --git a/Wrappers/MSDOS.cs b/Wrappers/MSDOS.cs index 2cbfffa6..818c2abf 100644 --- a/Wrappers/MSDOS.cs +++ b/Wrappers/MSDOS.cs @@ -14,22 +14,14 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// -#if NET48 - public MSDOS(Models.MSDOS.Executable model, byte[] data, int offset) -#else public MSDOS(Models.MSDOS.Executable? model, byte[]? data, int offset) -#endif : base(model, data, offset) { // All logic is handled by the base class } /// -#if NET48 - public MSDOS(Models.MSDOS.Executable model, Stream data) -#else public MSDOS(Models.MSDOS.Executable? model, Stream? data) -#endif : base(model, data) { // All logic is handled by the base class @@ -39,11 +31,7 @@ namespace SabreTools.Serialization.Wrappers /// Byte array representing the executable /// Offset within the array to parse /// An MS-DOS executable wrapper on success, null on failure -#if NET48 - public static MSDOS Create(byte[] data, int offset) -#else public static MSDOS? Create(byte[]? data, int offset) -#endif { // If the data is invalid if (data == null) @@ -63,11 +51,7 @@ namespace SabreTools.Serialization.Wrappers /// /// Stream representing the executable /// An MS-DOS executable wrapper on success, null on failure -#if NET48 - public static MSDOS Create(Stream data) -#else public static MSDOS? Create(Stream? data) -#endif { // If the data is invalid if (data == null || data.Length == 0 || !data.CanSeek || !data.CanRead) diff --git a/Wrappers/MicrosoftCabinet.cs b/Wrappers/MicrosoftCabinet.cs index 810df160..fa5c033b 100644 --- a/Wrappers/MicrosoftCabinet.cs +++ b/Wrappers/MicrosoftCabinet.cs @@ -15,22 +15,14 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// -#if NET48 - public MicrosoftCabinet(Models.MicrosoftCabinet.Cabinet model, byte[] data, int offset) -#else public MicrosoftCabinet(Models.MicrosoftCabinet.Cabinet? model, byte[]? data, int offset) -#endif : base(model, data, offset) { // All logic is handled by the base class } /// -#if NET48 - public MicrosoftCabinet(Models.MicrosoftCabinet.Cabinet model, Stream data) -#else public MicrosoftCabinet(Models.MicrosoftCabinet.Cabinet? model, Stream? data) -#endif : base(model, data) { // All logic is handled by the base class @@ -40,11 +32,7 @@ namespace SabreTools.Serialization.Wrappers /// Byte array representing the cabinet /// Offset within the array to parse /// A cabinet wrapper on success, null on failure -#if NET48 - public static MicrosoftCabinet Create(byte[] data, int offset) -#else public static MicrosoftCabinet? Create(byte[]? data, int offset) -#endif { // If the data is invalid if (data == null) @@ -64,11 +52,7 @@ namespace SabreTools.Serialization.Wrappers /// /// Stream representing the cabinet /// A cabinet wrapper on success, null on failure -#if NET48 - public static MicrosoftCabinet Create(Stream data) -#else public static MicrosoftCabinet? Create(Stream? data) -#endif { // If the data is invalid if (data == null || data.Length == 0 || !data.CanSeek || !data.CanRead) diff --git a/Wrappers/N3DS.cs b/Wrappers/N3DS.cs index ac7861c6..e418e9a7 100644 --- a/Wrappers/N3DS.cs +++ b/Wrappers/N3DS.cs @@ -14,22 +14,14 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// -#if NET48 - public N3DS(Models.N3DS.Cart model, byte[] data, int offset) -#else public N3DS(Models.N3DS.Cart? model, byte[]? data, int offset) -#endif : base(model, data, offset) { // All logic is handled by the base class } /// -#if NET48 - public N3DS(Models.N3DS.Cart model, Stream data) -#else public N3DS(Models.N3DS.Cart? model, Stream? data) -#endif : base(model, data) { // All logic is handled by the base class @@ -41,11 +33,7 @@ namespace SabreTools.Serialization.Wrappers /// Byte array representing the archive /// Offset within the array to parse /// A 3DS cart image wrapper on success, null on failure -#if NET48 - public static N3DS Create(byte[] data, int offset) -#else public static N3DS? Create(byte[]? data, int offset) -#endif { // If the data is invalid if (data == null) @@ -65,11 +53,7 @@ namespace SabreTools.Serialization.Wrappers /// /// Stream representing the archive /// A 3DS cart image wrapper on success, null on failure -#if NET48 - public static N3DS Create(Stream data) -#else public static N3DS? Create(Stream? data) -#endif { // If the data is invalid if (data == null || data.Length == 0 || !data.CanSeek || !data.CanRead) diff --git a/Wrappers/NCF.cs b/Wrappers/NCF.cs index 7db6b0c4..58407217 100644 --- a/Wrappers/NCF.cs +++ b/Wrappers/NCF.cs @@ -14,22 +14,14 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// -#if NET48 - public NCF(Models.NCF.File model, byte[] data, int offset) -#else public NCF(Models.NCF.File? model, byte[]? data, int offset) -#endif : base(model, data, offset) { // All logic is handled by the base class } /// -#if NET48 - public NCF(Models.NCF.File model, Stream data) -#else public NCF(Models.NCF.File? model, Stream? data) -#endif : base(model, data) { // All logic is handled by the base class @@ -41,11 +33,7 @@ namespace SabreTools.Serialization.Wrappers /// Byte array representing the NCF /// Offset within the array to parse /// An NCF wrapper on success, null on failure -#if NET48 - public static NCF Create(byte[] data, int offset) -#else public static NCF? Create(byte[]? data, int offset) -#endif { // If the data is invalid if (data == null) @@ -65,11 +53,7 @@ namespace SabreTools.Serialization.Wrappers /// /// Stream representing the NCF /// An NCF wrapper on success, null on failure -#if NET48 - public static NCF Create(Stream data) -#else public static NCF? Create(Stream? data) -#endif { // If the data is invalid if (data == null || data.Length == 0 || !data.CanSeek || !data.CanRead) diff --git a/Wrappers/NewExecutable.cs b/Wrappers/NewExecutable.cs index 8c9148bd..116c96cb 100644 --- a/Wrappers/NewExecutable.cs +++ b/Wrappers/NewExecutable.cs @@ -15,22 +15,14 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// -#if NET48 - public NewExecutable(Models.NewExecutable.Executable model, byte[] data, int offset) -#else public NewExecutable(Models.NewExecutable.Executable? model, byte[]? data, int offset) -#endif : base(model, data, offset) { // All logic is handled by the base class } /// -#if NET48 - public NewExecutable(Models.NewExecutable.Executable model, Stream data) -#else public NewExecutable(Models.NewExecutable.Executable? model, Stream? data) -#endif : base(model, data) { // All logic is handled by the base class @@ -42,11 +34,7 @@ namespace SabreTools.Serialization.Wrappers /// Byte array representing the executable /// Offset within the array to parse /// An NE executable wrapper on success, null on failure -#if NET48 - public static NewExecutable Create(byte[] data, int offset) -#else public static NewExecutable? Create(byte[]? data, int offset) -#endif { // If the data is invalid if (data == null) @@ -66,11 +54,7 @@ namespace SabreTools.Serialization.Wrappers /// /// Stream representing the executable /// An NE executable wrapper on success, null on failure -#if NET48 - public static NewExecutable Create(Stream data) -#else public static NewExecutable? Create(Stream? data) -#endif { // If the data is invalid if (data == null || data.Length == 0 || !data.CanSeek || !data.CanRead) @@ -101,11 +85,7 @@ namespace SabreTools.Serialization.Wrappers /// How many bytes to read, -1 means read until end /// Byte array representing the range, null on error [Obsolete] -#if NET48 - public byte[] ReadArbitraryRange(int rangeStart = -1, int length = -1) -#else public byte[]? ReadArbitraryRange(int rangeStart = -1, int length = -1) -#endif { // If we have an unset range start, read from the start of the source if (rangeStart == -1) @@ -117,19 +97,11 @@ namespace SabreTools.Serialization.Wrappers switch (_dataSource) { case DataSource.ByteArray: -#if NET48 - length = _byteArrayData.Length - _byteArrayOffset; -#else length = _byteArrayData!.Length - _byteArrayOffset; -#endif break; case DataSource.Stream: -#if NET48 - length = (int)_streamData.Length; -#else length = (int)_streamData!.Length; -#endif break; } } diff --git a/Wrappers/Nitro.cs b/Wrappers/Nitro.cs index 3ccc3390..a2bad27b 100644 --- a/Wrappers/Nitro.cs +++ b/Wrappers/Nitro.cs @@ -14,22 +14,14 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// -#if NET48 - public Nitro(Models.Nitro.Cart model, byte[] data, int offset) -#else public Nitro(Models.Nitro.Cart? model, byte[]? data, int offset) -#endif : base(model, data, offset) { // All logic is handled by the base class } /// -#if NET48 - public Nitro(Models.Nitro.Cart model, Stream data) -#else public Nitro(Models.Nitro.Cart? model, Stream? data) -#endif : base(model, data) { // All logic is handled by the base class @@ -41,11 +33,7 @@ namespace SabreTools.Serialization.Wrappers /// Byte array representing the archive /// Offset within the array to parse /// A NDS cart image wrapper on success, null on failure -#if NET48 - public static Nitro Create(byte[] data, int offset) -#else public static Nitro? Create(byte[]? data, int offset) -#endif { // If the data is invalid if (data == null) @@ -65,11 +53,7 @@ namespace SabreTools.Serialization.Wrappers /// /// Stream representing the archive /// A NDS cart image wrapper on success, null on failure -#if NET48 - public static Nitro Create(Stream data) -#else public static Nitro? Create(Stream? data) -#endif { // If the data is invalid if (data == null || data.Length == 0 || !data.CanSeek || !data.CanRead) diff --git a/Wrappers/PAK.cs b/Wrappers/PAK.cs index 1ca915ba..0153f5b9 100644 --- a/Wrappers/PAK.cs +++ b/Wrappers/PAK.cs @@ -14,22 +14,14 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// -#if NET48 - public PAK(Models.PAK.File model, byte[] data, int offset) -#else public PAK(Models.PAK.File? model, byte[]? data, int offset) -#endif : base(model, data, offset) { // All logic is handled by the base class } /// -#if NET48 - public PAK(Models.PAK.File model, Stream data) -#else public PAK(Models.PAK.File? model, Stream? data) -#endif : base(model, data) { // All logic is handled by the base class @@ -41,11 +33,7 @@ namespace SabreTools.Serialization.Wrappers /// Byte array representing the PAK /// Offset within the array to parse /// A PAK wrapper on success, null on failure -#if NET48 - public static PAK Create(byte[] data, int offset) -#else public static PAK? Create(byte[]? data, int offset) -#endif { // If the data is invalid if (data == null) @@ -65,11 +53,7 @@ namespace SabreTools.Serialization.Wrappers /// /// Stream representing the PAK /// A PAK wrapper on success, null on failure -#if NET48 - public static PAK Create(Stream data) -#else public static PAK? Create(Stream? data) -#endif { // If the data is invalid if (data == null || data.Length == 0 || !data.CanSeek || !data.CanRead) diff --git a/Wrappers/PFF.cs b/Wrappers/PFF.cs index eafc1494..8045ad4b 100644 --- a/Wrappers/PFF.cs +++ b/Wrappers/PFF.cs @@ -15,22 +15,14 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// -#if NET48 - public PFF(Models.PFF.Archive model, byte[] data, int offset) -#else public PFF(Models.PFF.Archive? model, byte[]? data, int offset) -#endif : base(model, data, offset) { // All logic is handled by the base class } /// -#if NET48 - public PFF(Models.PFF.Archive model, Stream data) -#else public PFF(Models.PFF.Archive? model, Stream? data) -#endif : base(model, data) { // All logic is handled by the base class @@ -40,11 +32,7 @@ namespace SabreTools.Serialization.Wrappers /// Byte array representing the archive /// Offset within the array to parse /// A PFF archive wrapper on success, null on failure -#if NET48 - public static PFF Create(byte[] data, int offset) -#else public static PFF? Create(byte[]? data, int offset) -#endif { // If the data is invalid if (data == null) @@ -64,11 +52,7 @@ namespace SabreTools.Serialization.Wrappers /// /// Stream representing the archive /// A PFF archive wrapper on success, null on failure -#if NET48 - public static PFF Create(Stream data) -#else public static PFF? Create(Stream? data) -#endif { // If the data is invalid if (data == null || data.Length == 0 || !data.CanSeek || !data.CanRead) diff --git a/Wrappers/PlayJAudioFile.cs b/Wrappers/PlayJAudioFile.cs index f2b6161d..b8d41724 100644 --- a/Wrappers/PlayJAudioFile.cs +++ b/Wrappers/PlayJAudioFile.cs @@ -14,22 +14,14 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// -#if NET48 - public PlayJAudioFile(Models.PlayJ.AudioFile model, byte[] data, int offset) -#else public PlayJAudioFile(Models.PlayJ.AudioFile? model, byte[]? data, int offset) -#endif : base(model, data, offset) { // All logic is handled by the base class } /// -#if NET48 - public PlayJAudioFile(Models.PlayJ.AudioFile model, Stream data) -#else public PlayJAudioFile(Models.PlayJ.AudioFile? model, Stream? data) -#endif : base(model, data) { // All logic is handled by the base class @@ -41,11 +33,7 @@ namespace SabreTools.Serialization.Wrappers /// Byte array representing the archive /// Offset within the array to parse /// A PlayJ audio file wrapper on success, null on failure -#if NET48 - public static PlayJAudioFile Create(byte[] data, int offset) -#else public static PlayJAudioFile? Create(byte[]? data, int offset) -#endif { // If the data is invalid if (data == null) @@ -65,11 +53,7 @@ namespace SabreTools.Serialization.Wrappers /// /// Stream representing the archive /// A PlayJ audio file wrapper on success, null on failure -#if NET48 - public static PlayJAudioFile Create(Stream data) -#else public static PlayJAudioFile? Create(Stream? data) -#endif { // If the data is invalid if (data == null || data.Length == 0 || !data.CanSeek || !data.CanRead) diff --git a/Wrappers/PortableExecutable.cs b/Wrappers/PortableExecutable.cs index 6d701464..1cfe52e7 100644 --- a/Wrappers/PortableExecutable.cs +++ b/Wrappers/PortableExecutable.cs @@ -21,11 +21,7 @@ namespace SabreTools.Serialization.Wrappers /// /// Header padding data, if it exists /// -#if NET48 - public byte[] HeaderPaddingData -#else public byte[]? HeaderPaddingData -#endif { get { @@ -60,11 +56,7 @@ namespace SabreTools.Serialization.Wrappers /// /// Header padding strings, if they exist /// -#if NET48 - public List HeaderPaddingStrings -#else public List? HeaderPaddingStrings -#endif { get { @@ -99,11 +91,7 @@ namespace SabreTools.Serialization.Wrappers /// /// Entry point data, if it exists /// -#if NET48 - public byte[] EntryPointData -#else public byte[]? EntryPointData -#endif { get { @@ -215,11 +203,7 @@ namespace SabreTools.Serialization.Wrappers /// Overlay data, if it exists /// /// -#if NET48 - public byte[] OverlayData -#else public byte[]? OverlayData -#endif { get { @@ -297,11 +281,7 @@ namespace SabreTools.Serialization.Wrappers /// /// Overlay strings, if they exist /// -#if NET48 - public List OverlayStrings -#else public List? OverlayStrings -#endif { get { @@ -379,11 +359,7 @@ namespace SabreTools.Serialization.Wrappers /// /// Sanitized section names /// -#if NET48 - public string[] SectionNames -#else public string[]? SectionNames -#endif { get { @@ -406,11 +382,7 @@ namespace SabreTools.Serialization.Wrappers continue; // TODO: Handle long section names with leading `/` -#if NET48 - byte[] sectionNameBytes = section.Name; -#else byte[]? sectionNameBytes = section.Name; -#endif if (sectionNameBytes != null) { string sectionNameString = Encoding.UTF8.GetString(sectionNameBytes).TrimEnd('\0'); @@ -426,11 +398,7 @@ namespace SabreTools.Serialization.Wrappers /// /// Stub executable data, if it exists /// -#if NET48 - public byte[] StubExecutableData -#else public byte[]? StubExecutableData -#endif { get { @@ -457,11 +425,7 @@ namespace SabreTools.Serialization.Wrappers /// /// Dictionary of debug data /// -#if NET48 - public Dictionary DebugData -#else public Dictionary? DebugData -#endif { get { @@ -486,11 +450,7 @@ namespace SabreTools.Serialization.Wrappers /// /// Dictionary of resource data /// -#if NET48 - public Dictionary ResourceData -#else public Dictionary? ResourceData -#endif { get { @@ -518,101 +478,61 @@ namespace SabreTools.Serialization.Wrappers /// /// "Build GUID" /// -#if NET48 - public string BuildGuid => GetVersionInfoString("BuildGuid"); -#else public string? BuildGuid => GetVersionInfoString("BuildGuid"); -#endif /// /// "Build signature" /// -#if NET48 - public string BuildSignature => GetVersionInfoString("BuildSignature"); -#else public string? BuildSignature => GetVersionInfoString("BuildSignature"); -#endif /// /// Additional information that should be displayed for diagnostic purposes. /// -#if NET48 - public string Comments => GetVersionInfoString("Comments"); -#else public string? Comments => GetVersionInfoString("Comments"); -#endif /// /// Company that produced the file—for example, "Microsoft Corporation" or /// "Standard Microsystems Corporation, Inc." This string is required. /// -#if NET48 - public string CompanyName => GetVersionInfoString("CompanyName"); -#else public string? CompanyName => GetVersionInfoString("CompanyName"); -#endif /// /// "Debug version" /// -#if NET48 - public string DebugVersion => GetVersionInfoString("DebugVersion"); -#else public string? DebugVersion => GetVersionInfoString("DebugVersion"); -#endif /// /// File description to be presented to users. This string may be displayed in a /// list box when the user is choosing files to install—for example, "Keyboard /// Driver for AT-Style Keyboards". This string is required. /// -#if NET48 - public string FileDescription => GetVersionInfoString("FileDescription"); -#else public string? FileDescription => GetVersionInfoString("FileDescription"); -#endif /// /// Version number of the file—for example, "3.10" or "5.00.RC2". This string /// is required. /// -#if NET48 - public string FileVersion => GetVersionInfoString("FileVersion"); -#else public string? FileVersion => GetVersionInfoString("FileVersion"); -#endif /// /// Internal name of the file, if one exists—for example, a module name if the /// file is a dynamic-link library. If the file has no internal name, this /// string should be the original filename, without extension. This string is required. /// -#if NET48 - public string InternalName => GetVersionInfoString(key: "InternalName"); -#else public string? InternalName => GetVersionInfoString(key: "InternalName"); -#endif /// /// Copyright notices that apply to the file. This should include the full text of /// all notices, legal symbols, copyright dates, and so on. This string is optional. /// -#if NET48 - public string LegalCopyright => GetVersionInfoString(key: "LegalCopyright"); -#else public string? LegalCopyright => GetVersionInfoString(key: "LegalCopyright"); -#endif /// /// Trademarks and registered trademarks that apply to the file. This should include /// the full text of all notices, legal symbols, trademark numbers, and so on. This /// string is optional. /// -#if NET48 - public string LegalTrademarks => GetVersionInfoString(key: "LegalTrademarks"); -#else public string? LegalTrademarks => GetVersionInfoString(key: "LegalTrademarks"); -#endif /// /// Original name of the file, not including a path. This information enables an @@ -620,50 +540,30 @@ namespace SabreTools.Serialization.Wrappers /// the name depends on the file system for which the file was created. This string /// is required. /// -#if NET48 - public string OriginalFilename => GetVersionInfoString(key: "OriginalFilename"); -#else public string? OriginalFilename => GetVersionInfoString(key: "OriginalFilename"); -#endif /// /// Information about a private version of the file—for example, "Built by TESTER1 on /// \TESTBED". This string should be present only if VS_FF_PRIVATEBUILD is specified in /// the fileflags parameter of the root block. /// -#if NET48 - public string PrivateBuild => GetVersionInfoString(key: "PrivateBuild"); -#else public string? PrivateBuild => GetVersionInfoString(key: "PrivateBuild"); -#endif /// /// "Product GUID" /// -#if NET48 - public string ProductGuid => GetVersionInfoString("ProductGuid"); -#else public string? ProductGuid => GetVersionInfoString("ProductGuid"); -#endif /// /// Name of the product with which the file is distributed. This string is required. /// -#if NET48 - public string ProductName => GetVersionInfoString(key: "ProductName"); -#else public string? ProductName => GetVersionInfoString(key: "ProductName"); -#endif /// /// Version of the product with which the file is distributed—for example, "3.10" or /// "5.00.RC2". This string is required. /// -#if NET48 - public string ProductVersion => GetVersionInfoString(key: "ProductVersion"); -#else public string? ProductVersion => GetVersionInfoString(key: "ProductVersion"); -#endif /// /// Text that specifies how this version of the file differs from the standard @@ -671,43 +571,27 @@ namespace SabreTools.Serialization.Wrappers /// M250E computers". This string should be present only if VS_FF_SPECIALBUILD is /// specified in the fileflags parameter of the root block. /// -#if NET48 - public string SpecialBuild => GetVersionInfoString(key: "SpecialBuild") ?? GetVersionInfoString(key: "Special Build"); -#else public string? SpecialBuild => GetVersionInfoString(key: "SpecialBuild") ?? GetVersionInfoString(key: "Special Build"); -#endif /// /// "Trade name" /// -#if NET48 - public string TradeName => GetVersionInfoString(key: "TradeName"); -#else public string? TradeName => GetVersionInfoString(key: "TradeName"); -#endif /// /// Get the internal version as reported by the resources /// /// Version string, null on error /// The internal version is either the file version, product version, or assembly version, in that order -#if NET48 - public string GetInternalVersion() -#else public string? GetInternalVersion() -#endif { -#if NET48 - string version = this.FileVersion; -#else string? version = this.FileVersion; -#endif if (!string.IsNullOrWhiteSpace(version)) - return version.Replace(", ", "."); + return version!.Replace(", ", "."); version = this.ProductVersion; if (!string.IsNullOrWhiteSpace(version)) - return version.Replace(", ", "."); + return version!.Replace(", ", "."); version = this.AssemblyVersion; if (!string.IsNullOrWhiteSpace(version)) @@ -723,11 +607,7 @@ namespace SabreTools.Serialization.Wrappers /// /// Description as derived from the assembly manifest /// -#if NET48 - public string AssemblyDescription -#else public string? AssemblyDescription -#endif { get { @@ -746,11 +626,7 @@ namespace SabreTools.Serialization.Wrappers /// this will only retrieve the value from the first that doesn't /// have a null or empty version. /// -#if NET48 - public string AssemblyVersion -#else public string? AssemblyVersion -#endif { get { @@ -771,29 +647,17 @@ namespace SabreTools.Serialization.Wrappers /// /// Header padding data, if it exists /// -#if NET48 - private byte[] _headerPaddingData = null; -#else private byte[]? _headerPaddingData = null; -#endif /// /// Header padding strings, if they exist /// -#if NET48 - private List _headerPaddingStrings = null; -#else private List? _headerPaddingStrings = null; -#endif /// /// Entry point data, if it exists and isn't aligned to a section /// -#if NET48 - private byte[] _entryPointData = null; -#else private byte[]? _entryPointData = null; -#endif /// /// Address of the overlay, if it exists @@ -803,74 +667,42 @@ namespace SabreTools.Serialization.Wrappers /// /// Overlay data, if it exists /// -#if NET48 - private byte[] _overlayData = null; -#else private byte[]? _overlayData = null; -#endif /// /// Overlay strings, if they exist /// -#if NET48 - private List _overlayStrings = null; -#else private List? _overlayStrings = null; -#endif /// /// Stub executable data, if it exists /// -#if NET48 - private byte[] _stubExecutableData = null; -#else private byte[]? _stubExecutableData = null; -#endif /// /// Sanitized section names /// -#if NET48 - private string[] _sectionNames = null; -#else private string[]? _sectionNames = null; -#endif /// /// Cached raw section data /// -#if NET48 - private byte[][] _sectionData = null; -#else private byte[]?[]? _sectionData = null; -#endif /// /// Cached found string data in sections /// -#if NET48 - private List[] _sectionStringData = null; -#else private List?[]? _sectionStringData = null; -#endif /// /// Cached raw table data /// -#if NET48 - private byte[][] _tableData = null; -#else private byte[]?[]? _tableData = null; -#endif /// /// Cached found string data in tables /// -#if NET48 - private List[] _tableStringData = null; -#else private List?[]? _tableStringData = null; -#endif /// /// Cached debug data @@ -880,29 +712,17 @@ namespace SabreTools.Serialization.Wrappers /// /// Cached resource data /// -#if NET48 - private readonly Dictionary _resourceData = new Dictionary(); -#else private readonly Dictionary _resourceData = new Dictionary(); -#endif /// /// Cached version info data /// -#if NET48 - private Models.PortableExecutable.VersionInfo _versionInfo = null; -#else private Models.PortableExecutable.VersionInfo? _versionInfo = null; -#endif /// /// Cached assembly manifest data /// -#if NET48 - private Models.PortableExecutable.AssemblyManifest _assemblyManifest = null; -#else private Models.PortableExecutable.AssemblyManifest? _assemblyManifest = null; -#endif /// /// Lock object for reading from the source @@ -914,22 +734,14 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// -#if NET48 - public PortableExecutable(Models.PortableExecutable.Executable model, byte[] data, int offset) -#else public PortableExecutable(Models.PortableExecutable.Executable? model, byte[]? data, int offset) -#endif : base(model, data, offset) { // All logic is handled by the base class } /// -#if NET48 - public PortableExecutable(Models.PortableExecutable.Executable model, Stream data) -#else public PortableExecutable(Models.PortableExecutable.Executable? model, Stream? data) -#endif : base(model, data) { // All logic is handled by the base class @@ -941,11 +753,7 @@ namespace SabreTools.Serialization.Wrappers /// Byte array representing the executable /// Offset within the array to parse /// A PE executable wrapper on success, null on failure -#if NET48 - public static PortableExecutable Create(byte[] data, int offset) -#else public static PortableExecutable? Create(byte[]? data, int offset) -#endif { // If the data is invalid if (data == null) @@ -965,11 +773,7 @@ namespace SabreTools.Serialization.Wrappers /// /// Stream representing the executable /// A PE executable wrapper on success, null on failure -#if NET48 - public static PortableExecutable Create(Stream data) -#else public static PortableExecutable? Create(Stream? data) -#endif { // If the data is invalid if (data == null || data.Length == 0 || !data.CanSeek || !data.CanRead) @@ -1005,11 +809,7 @@ namespace SabreTools.Serialization.Wrappers /// the first available value. This may not actually matter for version info, /// but it is worth mentioning. /// -#if NET48 - public string GetVersionInfoString(string key) -#else public string? GetVersionInfoString(string key) -#endif { // If we have an invalid key, we can't do anything if (string.IsNullOrEmpty(key)) @@ -1037,11 +837,7 @@ namespace SabreTools.Serialization.Wrappers /// Get the assembly manifest, if possible /// /// Assembly manifest object, null on error -#if NET48 - private Models.PortableExecutable.AssemblyManifest GetAssemblyManifest() -#else private Models.PortableExecutable.AssemblyManifest? GetAssemblyManifest() -#endif { // Use the cached data if possible if (_assemblyManifest != null) @@ -1064,19 +860,11 @@ namespace SabreTools.Serialization.Wrappers /// /// Partial path to check for /// Enumerable of matching debug data -#if NET48 - public IEnumerable FindCodeViewDebugTableByPath(string path) -#else public IEnumerable FindCodeViewDebugTableByPath(string path) -#endif { // Ensure that we have the debug data cached if (DebugData == null) -#if NET48 - return Enumerable.Empty(); -#else return Enumerable.Empty(); -#endif var nb10Found = DebugData.Select(r => r.Value) .Select(r => r as SabreTools.Models.PortableExecutable.NB10ProgramDatabase) @@ -1098,19 +886,11 @@ namespace SabreTools.Serialization.Wrappers /// /// String value to check for /// Enumerable of matching debug data -#if NET48 - public IEnumerable FindGenericDebugTableByValue(string value) -#else public IEnumerable FindGenericDebugTableByValue(string value) -#endif { // Ensure that we have the resource data cached if (DebugData == null) -#if NET48 return Enumerable.Empty(); -#else - return Enumerable.Empty(); -#endif return DebugData.Select(r => r.Value) .Select(b => b as byte[]) @@ -1119,11 +899,7 @@ namespace SabreTools.Serialization.Wrappers { try { -#if NET48 - string arrayAsASCII = Encoding.ASCII.GetString(b); -#else string? arrayAsASCII = Encoding.ASCII.GetString(b!); -#endif if (arrayAsASCII.Contains(value)) return true; } @@ -1131,11 +907,7 @@ namespace SabreTools.Serialization.Wrappers try { -#if NET48 - string arrayAsUTF8 = Encoding.UTF8.GetString(b); -#else string? arrayAsUTF8 = Encoding.UTF8.GetString(b!); -#endif if (arrayAsUTF8.Contains(value)) return true; } @@ -1143,11 +915,7 @@ namespace SabreTools.Serialization.Wrappers try { -#if NET48 - string arrayAsUnicode = Encoding.Unicode.GetString(b); -#else string? arrayAsUnicode = Encoding.Unicode.GetString(b!); -#endif if (arrayAsUnicode.Contains(value)) return true; } @@ -1180,11 +948,7 @@ namespace SabreTools.Serialization.Wrappers uint address = entry.PointerToRawData; uint size = entry.SizeOfData; -#if NET48 - byte[] entryData = ReadFromDataSource((int)address, (int)size); -#else byte[]? entryData = ReadFromDataSource((int)address, (int)size); -#endif if (entryData == null) continue; @@ -1236,19 +1000,11 @@ namespace SabreTools.Serialization.Wrappers /// /// Dialog box title to check for /// Enumerable of matching resources -#if NET48 - public IEnumerable FindDialogByTitle(string title) -#else public IEnumerable FindDialogByTitle(string title) -#endif { // Ensure that we have the resource data cached if (ResourceData == null) -#if NET48 - return Enumerable.Empty(); -#else return Enumerable.Empty(); -#endif return ResourceData.Select(r => r.Value) .Select(r => r as SabreTools.Models.PortableExecutable.DialogBoxResource) @@ -1265,19 +1021,11 @@ namespace SabreTools.Serialization.Wrappers /// /// Dialog box item title to check for /// Enumerable of matching resources -#if NET48 - public IEnumerable FindDialogBoxByItemTitle(string title) -#else public IEnumerable FindDialogBoxByItemTitle(string title) -#endif { // Ensure that we have the resource data cached if (ResourceData == null) -#if NET48 - return Enumerable.Empty(); -#else return Enumerable.Empty(); -#endif return ResourceData.Select(r => r.Value) .Select(r => r as SabreTools.Models.PortableExecutable.DialogBoxResource) @@ -1306,26 +1054,14 @@ namespace SabreTools.Serialization.Wrappers /// /// String entry to check for /// Enumerable of matching resources -#if NET48 - public IEnumerable> FindStringTableByEntry(string entry) -#else public IEnumerable?> FindStringTableByEntry(string entry) -#endif { // Ensure that we have the resource data cached if (ResourceData == null) -#if NET48 - return Enumerable.Empty>(); -#else return Enumerable.Empty?>(); -#endif return ResourceData.Select(r => r.Value) -#if NET48 - .Select(r => r as Dictionary) -#else .Select(r => r as Dictionary) -#endif .Where(st => st != null) .Where(st => st?.Select(kvp => kvp.Value)? .Any(s => s != null && s.Contains(entry)) == true); @@ -1336,19 +1072,11 @@ namespace SabreTools.Serialization.Wrappers /// /// Type name to check for /// Enumerable of matching resources -#if NET48 - public IEnumerable FindResourceByNamedType(string typeName) -#else public IEnumerable FindResourceByNamedType(string typeName) -#endif { // Ensure that we have the resource data cached if (ResourceData == null) -#if NET48 - return Enumerable.Empty(); -#else return Enumerable.Empty(); -#endif return ResourceData.Where(kvp => kvp.Key.Contains(typeName)) .Select(kvp => kvp.Value as byte[]) @@ -1360,19 +1088,11 @@ namespace SabreTools.Serialization.Wrappers /// /// String value to check for /// Enumerable of matching resources -#if NET48 - public IEnumerable FindGenericResource(string value) -#else public IEnumerable FindGenericResource(string value) -#endif { // Ensure that we have the resource data cached if (ResourceData == null) -#if NET48 - return Enumerable.Empty(); -#else return Enumerable.Empty(); -#endif return ResourceData.Select(r => r.Value) .Select(r => r as byte[]) @@ -1381,11 +1101,7 @@ namespace SabreTools.Serialization.Wrappers { try { -#if NET48 - string arrayAsASCII = Encoding.ASCII.GetString(b); -#else string? arrayAsASCII = Encoding.ASCII.GetString(b!); -#endif if (arrayAsASCII.Contains(value)) return true; } @@ -1393,11 +1109,7 @@ namespace SabreTools.Serialization.Wrappers try { -#if NET48 - string arrayAsUTF8 = Encoding.UTF8.GetString(b); -#else string? arrayAsUTF8 = Encoding.UTF8.GetString(b!); -#endif if (arrayAsUTF8.Contains(value)) return true; } @@ -1405,11 +1117,7 @@ namespace SabreTools.Serialization.Wrappers try { -#if NET48 - string arrayAsUnicode = Encoding.Unicode.GetString(b); -#else string? arrayAsUnicode = Encoding.Unicode.GetString(b!); -#endif if (arrayAsUnicode.Contains(value)) return true; } @@ -1471,11 +1179,7 @@ namespace SabreTools.Serialization.Wrappers { // Create the key and value objects string key = types == null ? $"UNKNOWN_{Guid.NewGuid()}" : string.Join(", ", types); -#if NET48 - object value = entry.Data; -#else object? value = entry.Data; -#endif // If we have a known resource type if (types != null && types.Count > 0 && types[0] is uint resourceType) @@ -1581,11 +1285,7 @@ namespace SabreTools.Serialization.Wrappers /// Name of the section to check for /// True to enable exact matching of names, false for starts-with /// True if the section is in the executable, false otherwise -#if NET48 - public bool ContainsSection(string sectionName, bool exact = false) -#else public bool ContainsSection(string? sectionName, bool exact = false) -#endif { // If no section name is provided if (sectionName == null) @@ -1623,15 +1323,10 @@ namespace SabreTools.Serialization.Wrappers return -1; // Otherwise, find the section it exists within -#if NET48 - return this.Model.OptionalHeader.AddressOfEntryPoint.ContainingSectionIndex(this.Model.SectionTable); -#else - // Otherwise, find the section it exists within return this.Model.OptionalHeader.AddressOfEntryPoint.ContainingSectionIndex(this.Model.SectionTable .Where(sh => sh != null) .Cast() .ToArray()); -#endif } /// @@ -1640,11 +1335,7 @@ namespace SabreTools.Serialization.Wrappers /// Name of the section to check for /// True to enable exact matching of names, false for starts-with /// Section data on success, null on error -#if NET48 - public SabreTools.Models.PortableExecutable.SectionHeader GetFirstSection(string name, bool exact = false) -#else public SabreTools.Models.PortableExecutable.SectionHeader? GetFirstSection(string? name, bool exact = false) -#endif { // If we have no sections if (SectionNames == null || !SectionNames.Any() || this.Model.SectionTable == null || !this.Model.SectionTable.Any()) @@ -1669,11 +1360,7 @@ namespace SabreTools.Serialization.Wrappers /// Name of the section to check for /// True to enable exact matching of names, false for starts-with /// Section data on success, null on error -#if NET48 - public SabreTools.Models.PortableExecutable.SectionHeader GetLastSection(string name, bool exact = false) -#else public SabreTools.Models.PortableExecutable.SectionHeader? GetLastSection(string? name, bool exact = false) -#endif { // If we have no sections if (SectionNames == null || !SectionNames.Any() || this.Model.SectionTable == null || !this.Model.SectionTable.Any()) @@ -1697,11 +1384,7 @@ namespace SabreTools.Serialization.Wrappers /// /// Index of the section to check for /// Section data on success, null on error -#if NET48 - public SabreTools.Models.PortableExecutable.SectionHeader GetSection(int index) -#else public SabreTools.Models.PortableExecutable.SectionHeader? GetSection(int index) -#endif { // If we have no sections if (this.Model.SectionTable == null || !this.Model.SectionTable.Any()) @@ -1721,11 +1404,7 @@ namespace SabreTools.Serialization.Wrappers /// Name of the section to check for /// True to enable exact matching of names, false for starts-with /// Section data on success, null on error -#if NET48 - public byte[] GetFirstSectionData(string name, bool exact = false) -#else public byte[]? GetFirstSectionData(string? name, bool exact = false) -#endif { // If we have no sections if (SectionNames == null || !SectionNames.Any() || this.Model.SectionTable == null || !this.Model.SectionTable.Any()) @@ -1746,11 +1425,7 @@ namespace SabreTools.Serialization.Wrappers /// Name of the section to check for /// True to enable exact matching of names, false for starts-with /// Section data on success, null on error -#if NET48 - public byte[] GetLastSectionData(string name, bool exact = false) -#else public byte[]? GetLastSectionData(string? name, bool exact = false) -#endif { // If we have no sections if (SectionNames == null || !SectionNames.Any() || this.Model.SectionTable == null || !this.Model.SectionTable.Any()) @@ -1770,11 +1445,7 @@ namespace SabreTools.Serialization.Wrappers /// /// Index of the section to check for /// Section data on success, null on error -#if NET48 - public byte[] GetSectionData(int index) -#else public byte[]? GetSectionData(int index) -#endif { // If we have no sections if (SectionNames == null || !SectionNames.Any() || this.Model.SectionTable == null || !this.Model.SectionTable.Any()) @@ -1806,11 +1477,7 @@ namespace SabreTools.Serialization.Wrappers return _sectionData[index]; // Populate the raw section data based on the source -#if NET48 - byte[] sectionData = ReadFromDataSource((int)address, (int)size); -#else byte[]? sectionData = ReadFromDataSource((int)address, (int)size); -#endif // Cache and return the section data, even if null _sectionData[index] = sectionData; @@ -1824,11 +1491,7 @@ namespace SabreTools.Serialization.Wrappers /// Name of the section to check for /// True to enable exact matching of names, false for starts-with /// Section strings on success, null on error -#if NET48 - public List GetFirstSectionStrings(string name, bool exact = false) -#else public List? GetFirstSectionStrings(string? name, bool exact = false) -#endif { // If we have no sections if (SectionNames == null || !SectionNames.Any() || this.Model.SectionTable == null || !this.Model.SectionTable.Any()) @@ -1849,11 +1512,7 @@ namespace SabreTools.Serialization.Wrappers /// Name of the section to check for /// True to enable exact matching of names, false for starts-with /// Section strings on success, null on error -#if NET48 - public List GetLastSectionStrings(string name, bool exact = false) -#else public List? GetLastSectionStrings(string? name, bool exact = false) -#endif { // If we have no sections if (SectionNames == null || !SectionNames.Any() || this.Model.SectionTable == null || !this.Model.SectionTable.Any()) @@ -1873,11 +1532,7 @@ namespace SabreTools.Serialization.Wrappers /// /// Index of the section to check for /// Section strings on success, null on error -#if NET48 - public List GetSectionStrings(int index) -#else public List? GetSectionStrings(int index) -#endif { // If we have no sections if (SectionNames == null || !SectionNames.Any() || this.Model.SectionTable == null || !this.Model.SectionTable.Any()) @@ -1909,11 +1564,7 @@ namespace SabreTools.Serialization.Wrappers return _sectionStringData[index]; // Populate the section string data based on the source -#if NET48 - List sectionStringData = ReadStringsFromDataSource((int)address, (int)size); -#else List? sectionStringData = ReadStringsFromDataSource((int)address, (int)size); -#endif // Cache and return the section string data, even if null _sectionStringData[index] = sectionStringData; @@ -1930,11 +1581,7 @@ namespace SabreTools.Serialization.Wrappers /// /// Index of the table to check for /// Table data on success, null on error -#if NET48 - public byte[] GetTableData(int index) -#else public byte[]? GetTableData(int index) -#endif { // If the table doesn't exist if (this.Model.OptionalHeader == null || index < 0 || index > 16) @@ -2030,11 +1677,7 @@ namespace SabreTools.Serialization.Wrappers return _tableData[index]; // Populate the raw table data based on the source -#if NET48 - byte[] tableData = ReadFromDataSource((int)address, (int)size); -#else byte[]? tableData = ReadFromDataSource((int)address, (int)size); -#endif // Cache and return the table data, even if null _tableData[index] = tableData; @@ -2047,11 +1690,7 @@ namespace SabreTools.Serialization.Wrappers /// /// Index of the table to check for /// Table strings on success, null on error -#if NET48 - public List GetTableStrings(int index) -#else public List? GetTableStrings(int index) -#endif { // If the table doesn't exist if (this.Model.OptionalHeader == null || index < 0 || index > 16) @@ -2147,11 +1786,7 @@ namespace SabreTools.Serialization.Wrappers return _tableStringData[index]; // Populate the table string data based on the source -#if NET48 - List tableStringData = ReadStringsFromDataSource((int)address, (int)size); -#else List? tableStringData = ReadStringsFromDataSource((int)address, (int)size); -#endif // Cache and return the table string data, even if null _tableStringData[index] = tableStringData; diff --git a/Wrappers/Quantum.cs b/Wrappers/Quantum.cs index dd4700fc..ff0724e4 100644 --- a/Wrappers/Quantum.cs +++ b/Wrappers/Quantum.cs @@ -14,22 +14,14 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// -#if NET48 - public Quantum(Models.Quantum.Archive model, byte[] data, int offset) -#else public Quantum(Models.Quantum.Archive? model, byte[]? data, int offset) -#endif : base(model, data, offset) { // All logic is handled by the base class } /// -#if NET48 - public Quantum(Models.Quantum.Archive model, Stream data) -#else public Quantum(Models.Quantum.Archive? model, Stream? data) -#endif : base(model, data) { // All logic is handled by the base class @@ -41,11 +33,7 @@ namespace SabreTools.Serialization.Wrappers /// Byte array representing the archive /// Offset within the array to parse /// A Quantum archive wrapper on success, null on failure -#if NET48 - public static Quantum Create(byte[] data, int offset) -#else public static Quantum? Create(byte[]? data, int offset) -#endif { // If the data is invalid if (data == null) @@ -65,11 +53,7 @@ namespace SabreTools.Serialization.Wrappers /// /// Stream representing the archive /// A Quantum archive wrapper on success, null on failure -#if NET48 - public static Quantum Create(Stream data) -#else public static Quantum? Create(Stream? data) -#endif { // If the data is invalid if (data == null || data.Length == 0 || !data.CanSeek || !data.CanRead) diff --git a/Wrappers/SGA.cs b/Wrappers/SGA.cs index 40c98680..604b510f 100644 --- a/Wrappers/SGA.cs +++ b/Wrappers/SGA.cs @@ -14,22 +14,14 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// -#if NET48 - public SGA(Models.SGA.File model, byte[] data, int offset) -#else public SGA(Models.SGA.File? model, byte[]? data, int offset) -#endif : base(model, data, offset) { // All logic is handled by the base class } /// -#if NET48 - public SGA(Models.SGA.File model, Stream data) -#else public SGA(Models.SGA.File? model, Stream? data) -#endif : base(model, data) { // All logic is handled by the base class @@ -41,11 +33,7 @@ namespace SabreTools.Serialization.Wrappers /// Byte array representing the SGA /// Offset within the array to parse /// An SGA wrapper on success, null on failure -#if NET48 - public static SGA Create(byte[] data, int offset) -#else public static SGA? Create(byte[]? data, int offset) -#endif { // If the data is invalid if (data == null) @@ -65,11 +53,7 @@ namespace SabreTools.Serialization.Wrappers /// /// Stream representing the SGA /// An SGA wrapper on success, null on failure -#if NET48 - public static SGA Create(Stream data) -#else public static SGA? Create(Stream? data) -#endif { // If the data is invalid if (data == null || data.Length == 0 || !data.CanSeek || !data.CanRead) diff --git a/Wrappers/VBSP.cs b/Wrappers/VBSP.cs index dac509c2..719accee 100644 --- a/Wrappers/VBSP.cs +++ b/Wrappers/VBSP.cs @@ -14,22 +14,14 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// -#if NET48 - public VBSP(Models.VBSP.File model, byte[] data, int offset) -#else public VBSP(Models.VBSP.File? model, byte[]? data, int offset) -#endif : base(model, data, offset) { // All logic is handled by the base class } /// -#if NET48 - public VBSP(Models.VBSP.File model, Stream data) -#else public VBSP(Models.VBSP.File? model, Stream? data) -#endif : base(model, data) { // All logic is handled by the base class @@ -41,11 +33,7 @@ namespace SabreTools.Serialization.Wrappers /// Byte array representing the VBSP /// Offset within the array to parse /// A VBSP wrapper on success, null on failure -#if NET48 - public static VBSP Create(byte[] data, int offset) -#else public static VBSP? Create(byte[]? data, int offset) -#endif { // If the data is invalid if (data == null) @@ -65,11 +53,7 @@ namespace SabreTools.Serialization.Wrappers /// /// Stream representing the VBSP /// An VBSP wrapper on success, null on failure -#if NET48 - public static VBSP Create(Stream data) -#else public static VBSP? Create(Stream? data) -#endif { // If the data is invalid if (data == null || data.Length == 0 || !data.CanSeek || !data.CanRead) diff --git a/Wrappers/VPK.cs b/Wrappers/VPK.cs index 2578b071..1406cdd4 100644 --- a/Wrappers/VPK.cs +++ b/Wrappers/VPK.cs @@ -18,11 +18,7 @@ namespace SabreTools.Serialization.Wrappers /// /// Array of archive filenames attached to the given VPK /// -#if NET48 - public string[] ArchiveFilenames -#else public string[]? ArchiveFilenames -#endif { get { @@ -36,11 +32,7 @@ namespace SabreTools.Serialization.Wrappers // If the filename is not the right format string extension = Path.GetExtension(fs.Name).TrimStart('.'); -#if NET48 - string directoryName = Path.GetDirectoryName(fs.Name); -#else string? directoryName = Path.GetDirectoryName(fs.Name); -#endif string fileName = directoryName == null ? Path.GetFileNameWithoutExtension(fs.Name) : Path.Combine(directoryName, Path.GetFileNameWithoutExtension(fs.Name)); @@ -82,33 +74,21 @@ namespace SabreTools.Serialization.Wrappers /// /// Array of archive filenames attached to the given VPK /// -#if NET48 - private string[] _archiveFilenames = null; -#else private string[]? _archiveFilenames = null; -#endif #endregion #region Constructors /// -#if NET48 - public VPK(Models.VPK.File model, byte[] data, int offset) -#else public VPK(Models.VPK.File? model, byte[]? data, int offset) -#endif : base(model, data, offset) { // All logic is handled by the base class } /// -#if NET48 - public VPK(Models.VPK.File model, Stream data) -#else public VPK(Models.VPK.File? model, Stream? data) -#endif : base(model, data) { // All logic is handled by the base class @@ -120,11 +100,7 @@ namespace SabreTools.Serialization.Wrappers /// Byte array representing the VPK /// Offset within the array to parse /// A VPK wrapper on success, null on failure -#if NET48 - public static VPK Create(byte[] data, int offset) -#else public static VPK? Create(byte[]? data, int offset) -#endif { // If the data is invalid if (data == null) @@ -144,11 +120,7 @@ namespace SabreTools.Serialization.Wrappers /// /// Stream representing the VPK /// A VPK wrapper on success, null on failure -#if NET48 - public static VPK Create(Stream data) -#else public static VPK? Create(Stream? data) -#endif { // If the data is invalid if (data == null || data.Length == 0 || !data.CanSeek || !data.CanRead) diff --git a/Wrappers/WAD.cs b/Wrappers/WAD.cs index f668f532..42ead404 100644 --- a/Wrappers/WAD.cs +++ b/Wrappers/WAD.cs @@ -14,22 +14,14 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// -#if NET48 - public WAD(Models.WAD.File model, byte[] data, int offset) -#else public WAD(Models.WAD.File? model, byte[]? data, int offset) -#endif : base(model, data, offset) { // All logic is handled by the base class } /// -#if NET48 - public WAD(Models.WAD.File model, Stream data) -#else public WAD(Models.WAD.File? model, Stream? data) -#endif : base(model, data) { // All logic is handled by the base class @@ -41,11 +33,7 @@ namespace SabreTools.Serialization.Wrappers /// Byte array representing the WAD /// Offset within the array to parse /// A WAD wrapper on success, null on failure -#if NET48 - public static WAD Create(byte[] data, int offset) -#else public static WAD? Create(byte[]? data, int offset) -#endif { // If the data is invalid if (data == null) @@ -65,11 +53,7 @@ namespace SabreTools.Serialization.Wrappers /// /// Stream representing the WAD /// An WAD wrapper on success, null on failure -#if NET48 - public static WAD Create(Stream data) -#else public static WAD? Create(Stream? data) -#endif { // If the data is invalid if (data == null || data.Length == 0 || !data.CanSeek || !data.CanRead) diff --git a/Wrappers/WrapperBase.cs b/Wrappers/WrapperBase.cs index 5dd7155c..3626874e 100644 --- a/Wrappers/WrapperBase.cs +++ b/Wrappers/WrapperBase.cs @@ -27,11 +27,7 @@ namespace SabreTools.Serialization.Wrappers /// /// Internal model /// -#if NET48 public T Model { get; private set; } -#else - public T Model { get; init; } -#endif #endregion @@ -46,11 +42,7 @@ namespace SabreTools.Serialization.Wrappers /// Source byte array data /// /// This is only populated if is -#if NET48 - protected byte[] _byteArrayData = null; -#else protected byte[]? _byteArrayData = null; -#endif /// /// Source byte array data offset @@ -62,13 +54,9 @@ namespace SabreTools.Serialization.Wrappers /// Source Stream data /// /// This is only populated if is -#if NET48 - protected Stream _streamData = null; -#else protected Stream? _streamData = null; -#endif -#if NET6_0_OR_GREATER +#if !NETFRAMEWORK /// /// JSON serializer options for output printing @@ -94,11 +82,7 @@ namespace SabreTools.Serialization.Wrappers /// /// Construct a new instance of the wrapper from a byte array /// -#if NET48 - protected WrapperBase(T model, byte[] data, int offset) -#else protected WrapperBase(T? model, byte[]? data, int offset) -#endif { if (model == null) throw new ArgumentNullException(nameof(model)); @@ -116,11 +100,7 @@ namespace SabreTools.Serialization.Wrappers /// /// Construct a new instance of the wrapper from a Stream /// -#if NET48 - protected WrapperBase(T model, Stream data) -#else protected WrapperBase(T? model, Stream? data) -#endif { if (model == null) throw new ArgumentNullException(nameof(model)); @@ -180,18 +160,10 @@ namespace SabreTools.Serialization.Wrappers switch (_dataSource) { case DataSource.ByteArray: -#if NET48 - return _byteArrayOffset + position + length <= _byteArrayData.Length; -#else return _byteArrayOffset + position + length <= _byteArrayData!.Length; -#endif case DataSource.Stream: -#if NET48 - return position + length <= _streamData.Length; -#else return position + length <= _streamData!.Length; -#endif // Everything else is invalid case DataSource.UNKNOWN: @@ -206,11 +178,7 @@ namespace SabreTools.Serialization.Wrappers /// Position in the source to read from /// Length of the requested data /// Byte array containing the requested data, null on error -#if NET48 - public byte[] ReadFromDataSource(int position, int length) -#else public byte[]? ReadFromDataSource(int position, int length) -#endif { // Validate the data source if (!DataSourceIsValid()) @@ -221,28 +189,16 @@ namespace SabreTools.Serialization.Wrappers return null; // Read and return the data -#if NET48 - byte[] sectionData = null; -#else byte[]? sectionData = null; -#endif switch (_dataSource) { case DataSource.ByteArray: sectionData = new byte[length]; -#if NET48 - Array.Copy(_byteArrayData, _byteArrayOffset + position, sectionData, 0, length); -#else Array.Copy(_byteArrayData!, _byteArrayOffset + position, sectionData, 0, length); -#endif break; case DataSource.Stream: -#if NET48 - long currentLocation = _streamData.Position; -#else long currentLocation = _streamData!.Position; -#endif _streamData.Seek(position, SeekOrigin.Begin); sectionData = _streamData.ReadBytes(length); _streamData.Seek(currentLocation, SeekOrigin.Begin); @@ -259,18 +215,10 @@ namespace SabreTools.Serialization.Wrappers /// Length of the requested data /// Number of characters needed to be a valid string /// String list containing the requested data, null on error -#if NET48 - public List ReadStringsFromDataSource(int position, int length, int charLimit = 5) -#else public List? ReadStringsFromDataSource(int position, int length, int charLimit = 5) -#endif { // Read the data as a byte array first -#if NET48 - byte[] sourceData = ReadFromDataSource(position, length); -#else byte[]? sourceData = ReadFromDataSource(position, length); -#endif if (sourceData == null) return null; @@ -380,18 +328,10 @@ namespace SabreTools.Serialization.Wrappers switch (_dataSource) { case DataSource.ByteArray: -#if NET48 - return _byteArrayData.Length - _byteArrayOffset; -#else return _byteArrayData!.Length - _byteArrayOffset; -#endif case DataSource.Stream: -#if NET48 - return (int)_streamData.Length; -#else return (int)_streamData!.Length; -#endif case DataSource.UNKNOWN: default: @@ -403,7 +343,7 @@ namespace SabreTools.Serialization.Wrappers #region JSON Export -#if NET6_0_OR_GREATER +#if !NETFRAMEWORK /// /// Export the item information as JSON /// diff --git a/Wrappers/XMID.cs b/Wrappers/XMID.cs index 1bf1554b..eb18f770 100644 --- a/Wrappers/XMID.cs +++ b/Wrappers/XMID.cs @@ -63,22 +63,14 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// -#if NET48 - public XMID(Models.Xbox.XMID model, byte[] data, int offset) -#else public XMID(Models.Xbox.XMID? model, byte[]? data, int offset) -#endif : base(model, data, offset) { // All logic is handled by the base class } /// -#if NET48 - public XMID(Models.Xbox.XMID model, Stream data) -#else public XMID(Models.Xbox.XMID? model, Stream? data) -#endif : base(model, data) { // All logic is handled by the base class @@ -89,11 +81,7 @@ namespace SabreTools.Serialization.Wrappers /// /// String representing the data /// A XMID wrapper on success, null on failure -#if NET48 - public static XMID Create(string data) -#else public static XMID? Create(string? data) -#endif { // If the data is invalid if (data == null || data.Length == 0) diff --git a/Wrappers/XZP.cs b/Wrappers/XZP.cs index 78ae7985..8088c155 100644 --- a/Wrappers/XZP.cs +++ b/Wrappers/XZP.cs @@ -14,22 +14,14 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// -#if NET48 - public XZP(Models.XZP.File model, byte[] data, int offset) -#else public XZP(Models.XZP.File? model, byte[]? data, int offset) -#endif : base(model, data, offset) { // All logic is handled by the base class } /// -#if NET48 - public XZP(Models.XZP.File model, Stream data) -#else public XZP(Models.XZP.File? model, Stream? data) -#endif : base(model, data) { // All logic is handled by the base class @@ -41,11 +33,7 @@ namespace SabreTools.Serialization.Wrappers /// Byte array representing the XZP /// Offset within the array to parse /// A XZP wrapper on success, null on failure -#if NET48 - public static XZP Create(byte[] data, int offset) -#else public static XZP? Create(byte[]? data, int offset) -#endif { // If the data is invalid if (data == null) @@ -65,11 +53,7 @@ namespace SabreTools.Serialization.Wrappers /// /// Stream representing the XZP /// A XZP wrapper on success, null on failure -#if NET48 - public static XZP Create(Stream data) -#else public static XZP? Create(Stream? data) -#endif { // If the data is invalid if (data == null || data.Length == 0 || !data.CanSeek || !data.CanRead) diff --git a/Wrappers/XeMID.cs b/Wrappers/XeMID.cs index 74a97565..cab01a78 100644 --- a/Wrappers/XeMID.cs +++ b/Wrappers/XeMID.cs @@ -78,22 +78,14 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// -#if NET48 - public XeMID(Models.Xbox.XeMID model, byte[] data, int offset) -#else public XeMID(Models.Xbox.XeMID? model, byte[]? data, int offset) -#endif : base(model, data, offset) { // All logic is handled by the base class } /// -#if NET48 - public XeMID(Models.Xbox.XeMID model, Stream data) -#else public XeMID(Models.Xbox.XeMID? model, Stream? data) -#endif : base(model, data) { // All logic is handled by the base class @@ -104,11 +96,7 @@ namespace SabreTools.Serialization.Wrappers /// /// String representing the data /// A XeMID wrapper on success, null on failure -#if NET48 - public static XeMID Create(string data) -#else public static XeMID? Create(string? data) -#endif { // If the data is invalid if (data == null || data.Length == 0)