From d7c1e4e83a2120849482093d067b406cb5af4cd0 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Tue, 14 Nov 2023 14:50:47 -0500 Subject: [PATCH] Support ancient .NET --- Bytes/IRD.Deserializer.cs | 4 ++-- CrossModel/ArchiveDotOrg.Deserializer.cs | 4 ++++ CrossModel/AttractMode.Deserializer.cs | 4 ++++ CrossModel/EverdriveSMDB.Deserializer.cs | 4 ++++ CrossModel/Logiqx.Serializer.cs | 4 ++++ CrossModel/RomCenter.Deserializer.cs | 4 ++++ Extensions.PortableExecutable.cs | 2 +- Files/IRD.Deserializer.cs | 4 ++-- Files/IRD.Serializer.cs | 4 ++-- Internal.cs | 8 ++++++++ SabreTools.Serialization.csproj | 8 ++++---- Streams/ClrMamePro.Deserializer.cs | 4 ++++ Streams/ClrMamePro.Serializer.cs | 4 ++++ Streams/CueSheet.Serializer.cs | 4 ++++ Streams/HashFile.Deserializer.cs | 2 +- Streams/Hashfile.Serializer.cs | 14 +++++++------- Streams/IRD.Deserializer.cs | 14 +++++++++++--- Streams/IRD.Serializer.cs | 4 ++-- Streams/Listrom.Deserializer.cs | 4 ++-- Streams/Listrom.Serializer.cs | 2 +- Streams/N3DS.Deserializer.cs | 4 ++++ Streams/NewExecutable.Deserializer.cs | 4 ++++ Streams/VPK.Deserializer.cs | 8 ++++---- Wrappers/ConcreteInterfaceSerializer.cs | 12 ++++++++++++ Wrappers/IRD.cs | 6 +++--- Wrappers/PortableExecutable.cs | 4 ++++ Wrappers/WrapperBase.cs | 4 ++++ Wrappers/XMID.cs | 4 ++-- Wrappers/XeMID.cs | 4 ++-- 29 files changed, 114 insertions(+), 38 deletions(-) diff --git a/Bytes/IRD.Deserializer.cs b/Bytes/IRD.Deserializer.cs index 1d0299e1..c5eeb4bd 100644 --- a/Bytes/IRD.Deserializer.cs +++ b/Bytes/IRD.Deserializer.cs @@ -3,10 +3,10 @@ using SabreTools.Serialization.Interfaces; namespace SabreTools.Serialization.Bytes { - public partial class IRD : IByteSerializer + public partial class IRD : IByteSerializer { /// - public Models.IRD.IRD? Deserialize(byte[]? data, int offset) + public Models.IRD.File? Deserialize(byte[]? data, int offset) { // If the data is invalid if (data == null) diff --git a/CrossModel/ArchiveDotOrg.Deserializer.cs b/CrossModel/ArchiveDotOrg.Deserializer.cs index b150f23b..d3efe646 100644 --- a/CrossModel/ArchiveDotOrg.Deserializer.cs +++ b/CrossModel/ArchiveDotOrg.Deserializer.cs @@ -34,7 +34,11 @@ namespace SabreTools.Serialization.CrossModel { var roms = item.Read(Models.Metadata.Machine.RomKey); if (roms == null) +#if NET40 || NET452 + return []; +#else return Array.Empty(); +#endif return roms .Where(r => r != null) diff --git a/CrossModel/AttractMode.Deserializer.cs b/CrossModel/AttractMode.Deserializer.cs index 57c56a5b..3cad1413 100644 --- a/CrossModel/AttractMode.Deserializer.cs +++ b/CrossModel/AttractMode.Deserializer.cs @@ -47,7 +47,11 @@ namespace SabreTools.Serialization.CrossModel { var roms = item.Read(Models.Metadata.Machine.RomKey); if (roms == null || !roms.Any()) +#if NET40 || NET452 + return []; +#else return Array.Empty(); +#endif return roms .Where(r => r != null) diff --git a/CrossModel/EverdriveSMDB.Deserializer.cs b/CrossModel/EverdriveSMDB.Deserializer.cs index b30a6abd..30009261 100644 --- a/CrossModel/EverdriveSMDB.Deserializer.cs +++ b/CrossModel/EverdriveSMDB.Deserializer.cs @@ -34,7 +34,11 @@ namespace SabreTools.Serialization.CrossModel { var roms = item.Read(Models.Metadata.Machine.RomKey); if (roms == null || !roms.Any()) +#if NET40 || NET452 + return []; +#else return Array.Empty(); +#endif return roms .Where(r => r != null) diff --git a/CrossModel/Logiqx.Serializer.cs b/CrossModel/Logiqx.Serializer.cs index 6c9b8844..ede47edb 100644 --- a/CrossModel/Logiqx.Serializer.cs +++ b/CrossModel/Logiqx.Serializer.cs @@ -104,7 +104,11 @@ namespace SabreTools.Serialization.CrossModel private static Models.Metadata.Machine[] ConvertDirToInternalModel(Dir item) { if (item.Game == null || !item.Game.Any()) +#if NET40 || NET452 + return []; +#else return Array.Empty(); +#endif return item.Game .Where(g => g != null) diff --git a/CrossModel/RomCenter.Deserializer.cs b/CrossModel/RomCenter.Deserializer.cs index 6a6e208c..f92a1dd7 100644 --- a/CrossModel/RomCenter.Deserializer.cs +++ b/CrossModel/RomCenter.Deserializer.cs @@ -91,7 +91,11 @@ namespace SabreTools.Serialization.CrossModel { var roms = item.Read(Models.Metadata.Machine.RomKey); if (roms == null) +#if NET40 || NET452 + return []; +#else return Array.Empty(); +#endif return roms .Where(r => r != null) diff --git a/Extensions.PortableExecutable.cs b/Extensions.PortableExecutable.cs index db8bbc8e..2f27fd20 100644 --- a/Extensions.PortableExecutable.cs +++ b/Extensions.PortableExecutable.cs @@ -123,7 +123,7 @@ namespace SabreTools.Serialization // Distinguish between v1 and v2 int bytesToRead = 112; // v2 if (string.IsNullOrWhiteSpace(addD.Version) - || addD.Version.StartsWith("3") + || addD.Version!.StartsWith("3") || addD.Version.StartsWith("4.47")) { bytesToRead = 44; diff --git a/Files/IRD.Deserializer.cs b/Files/IRD.Deserializer.cs index 7728a4ed..75c1855f 100644 --- a/Files/IRD.Deserializer.cs +++ b/Files/IRD.Deserializer.cs @@ -2,10 +2,10 @@ using SabreTools.Serialization.Interfaces; namespace SabreTools.Serialization.Files { - public partial class IRD : IFileSerializer + public partial class IRD : IFileSerializer { /// - public Models.IRD.IRD? Deserialize(string? path) + public Models.IRD.File? Deserialize(string? path) { using (var stream = PathProcessor.OpenStream(path)) { diff --git a/Files/IRD.Serializer.cs b/Files/IRD.Serializer.cs index f9952629..c08f4270 100644 --- a/Files/IRD.Serializer.cs +++ b/Files/IRD.Serializer.cs @@ -2,10 +2,10 @@ using SabreTools.Serialization.Interfaces; namespace SabreTools.Serialization.Files { - public partial class IRD : IFileSerializer + public partial class IRD : IFileSerializer { /// - public bool Serialize(Models.IRD.IRD? obj, string? path) + public bool Serialize(Models.IRD.File? obj, string? path) { if (string.IsNullOrWhiteSpace(path)) return false; diff --git a/Internal.cs b/Internal.cs index a5acf58f..88ac6428 100644 --- a/Internal.cs +++ b/Internal.cs @@ -79,7 +79,11 @@ namespace SabreTools.Serialization { var roms = item.Read(DataArea.RomKey); if (roms == null || !roms.Any()) +#if NET40 || NET452 + return []; +#else return Array.Empty(); +#endif return roms.ToArray(); } @@ -91,7 +95,11 @@ namespace SabreTools.Serialization { var roms = item.Read(DiskArea.DiskKey); if (roms == null || !roms.Any()) +#if NET40 || NET452 + return []; +#else return Array.Empty(); +#endif return roms.ToArray(); } diff --git a/SabreTools.Serialization.csproj b/SabreTools.Serialization.csproj index 609751d6..1260dbd5 100644 --- a/SabreTools.Serialization.csproj +++ b/SabreTools.Serialization.csproj @@ -2,13 +2,13 @@ - net48;net6.0;net7.0;net8.0 + net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0 win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64;osx-arm64 true latest enable true - 1.1.7 + 1.2.0 Matt Nadareski @@ -27,8 +27,8 @@ - - + + diff --git a/Streams/ClrMamePro.Deserializer.cs b/Streams/ClrMamePro.Deserializer.cs index b365e4fa..e1e250cb 100644 --- a/Streams/ClrMamePro.Deserializer.cs +++ b/Streams/ClrMamePro.Deserializer.cs @@ -241,7 +241,11 @@ namespace SabreTools.Serialization.Streams var sample = new Sample { Name = reader.Standalone?.Value ?? string.Empty, +#if NET40 || NET452 + ADDITIONAL_ELEMENTS = [] +#else ADDITIONAL_ELEMENTS = Array.Empty() +#endif }; samples.Add(sample); break; diff --git a/Streams/ClrMamePro.Serializer.cs b/Streams/ClrMamePro.Serializer.cs index d503b0cf..89cacf83 100644 --- a/Streams/ClrMamePro.Serializer.cs +++ b/Streams/ClrMamePro.Serializer.cs @@ -412,7 +412,11 @@ namespace SabreTools.Serialization.Streams { writer.WriteStartElement("dipswitch"); writer.WriteRequiredAttributeString("name", dipswitch.Name, throwOnError: true); +#if NET40 || NET452 + foreach (var entry in dipswitch.Entry ?? []) +#else foreach (var entry in dipswitch.Entry ?? Array.Empty()) +#endif { writer.WriteRequiredAttributeString("entry", entry); } diff --git a/Streams/CueSheet.Serializer.cs b/Streams/CueSheet.Serializer.cs index 725b4d65..0f1f15f1 100644 --- a/Streams/CueSheet.Serializer.cs +++ b/Streams/CueSheet.Serializer.cs @@ -25,7 +25,11 @@ namespace SabreTools.Serialization.Streams // Setup the writer and output var stream = new MemoryStream(); +#if NET40 + var writer = new StreamWriter(stream, Encoding.ASCII, 1024); +#else var writer = new StreamWriter(stream, Encoding.ASCII, 1024, true); +#endif // Write the file WriteCueSheet(obj, writer); diff --git a/Streams/HashFile.Deserializer.cs b/Streams/HashFile.Deserializer.cs index a7ab7115..a49e1815 100644 --- a/Streams/HashFile.Deserializer.cs +++ b/Streams/HashFile.Deserializer.cs @@ -30,7 +30,7 @@ namespace SabreTools.Serialization.Streams { // Read and split the line string? line = reader.ReadLine(); -#if NETFRAMEWORK +#if NETFRAMEWORK || NETCOREAPP3_1 string[]? lineParts = line?.Split(new char[] { ' ' } , StringSplitOptions.RemoveEmptyEntries); #else string[]? lineParts = line?.Split(' ', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries); diff --git a/Streams/Hashfile.Serializer.cs b/Streams/Hashfile.Serializer.cs index 4b94ad97..4b4ad71a 100644 --- a/Streams/Hashfile.Serializer.cs +++ b/Streams/Hashfile.Serializer.cs @@ -81,7 +81,7 @@ namespace SabreTools.Serialization.Streams if (string.IsNullOrWhiteSpace(sfv.File) || string.IsNullOrWhiteSpace(sfv.Hash)) continue; - writer.WriteValues(new string[] { sfv.File, sfv.Hash }); + writer.WriteValues(new string[] { sfv.File!, sfv.Hash! }); writer.Flush(); } } @@ -105,7 +105,7 @@ namespace SabreTools.Serialization.Streams if (string.IsNullOrWhiteSpace(md5.Hash) || string.IsNullOrWhiteSpace(md5.File)) continue; - writer.WriteValues(new string[] { md5.Hash, md5.File }); + writer.WriteValues(new string[] { md5.Hash!, md5.File! }); writer.Flush(); } } @@ -129,7 +129,7 @@ namespace SabreTools.Serialization.Streams if (string.IsNullOrWhiteSpace(sha1.Hash) || string.IsNullOrWhiteSpace(sha1.File)) continue; - writer.WriteValues(new string[] { sha1.Hash, sha1.File }); + writer.WriteValues(new string[] { sha1.Hash!, sha1.File! }); writer.Flush(); } } @@ -153,7 +153,7 @@ namespace SabreTools.Serialization.Streams if (string.IsNullOrWhiteSpace(sha256.Hash) || string.IsNullOrWhiteSpace(sha256.File)) continue; - writer.WriteValues(new string[] { sha256.Hash, sha256.File }); + writer.WriteValues(new string[] { sha256.Hash!, sha256.File! }); writer.Flush(); } } @@ -177,7 +177,7 @@ namespace SabreTools.Serialization.Streams if (string.IsNullOrWhiteSpace(sha384.Hash) || string.IsNullOrWhiteSpace(sha384.File)) continue; - writer.WriteValues(new string[] { sha384.Hash, sha384.File }); + writer.WriteValues(new string[] { sha384.Hash!, sha384.File! }); writer.Flush(); } } @@ -201,7 +201,7 @@ namespace SabreTools.Serialization.Streams if (string.IsNullOrWhiteSpace(sha512.Hash) || string.IsNullOrWhiteSpace(sha512.File)) continue; - writer.WriteValues(new string[] { sha512.Hash, sha512.File }); + writer.WriteValues(new string[] { sha512.Hash!, sha512.File! }); writer.Flush(); } } @@ -225,7 +225,7 @@ namespace SabreTools.Serialization.Streams if (string.IsNullOrWhiteSpace(spamsum.Hash) || string.IsNullOrWhiteSpace(spamsum.File)) continue; - writer.WriteValues(new string[] { spamsum.Hash, spamsum.File }); + writer.WriteValues(new string[] { spamsum.Hash!, spamsum.File! }); writer.Flush(); } } diff --git a/Streams/IRD.Deserializer.cs b/Streams/IRD.Deserializer.cs index d805bd09..56bcb2a2 100644 --- a/Streams/IRD.Deserializer.cs +++ b/Streams/IRD.Deserializer.cs @@ -6,10 +6,10 @@ using SabreTools.Serialization.Interfaces; namespace SabreTools.Serialization.Streams { - public partial class IRD : IStreamSerializer + public partial class IRD : IStreamSerializer { /// - public Models.IRD.IRD? Deserialize(Stream? data) + public Models.IRD.File? Deserialize(Stream? data) { // If the data is invalid if (data == null || data.Length == 0 || !data.CanSeek || !data.CanRead) @@ -23,7 +23,7 @@ namespace SabreTools.Serialization.Streams int initialOffset = (int)data.Position; // Create a new media key block to fill - var ird = new Models.IRD.IRD(); + var ird = new Models.IRD.File(); ird.Magic = data.ReadBytes(4); if (ird.Magic == null) @@ -80,7 +80,11 @@ namespace SabreTools.Serialization.Streams ird.RegionHashes = new byte[ird.RegionCount][]; for (int i = 0; i < ird.RegionCount; i++) { +#if NET40 || NET452 + ird.RegionHashes[i] = data.ReadBytes(16) ?? []; +#else ird.RegionHashes[i] = data.ReadBytes(16) ?? Array.Empty(); +#endif } ird.FileCount = data.ReadByteValue(); @@ -89,7 +93,11 @@ namespace SabreTools.Serialization.Streams for (int i = 0; i < ird.FileCount; i++) { ird.FileKeys[i] = data.ReadUInt64(); +#if NET40 || NET452 + ird.FileHashes[i] = data.ReadBytes(16) ?? []; +#else ird.FileHashes[i] = data.ReadBytes(16) ?? Array.Empty(); +#endif } ird.ExtraConfig = data.ReadUInt16(); diff --git a/Streams/IRD.Serializer.cs b/Streams/IRD.Serializer.cs index ede35c46..29c5f2d3 100644 --- a/Streams/IRD.Serializer.cs +++ b/Streams/IRD.Serializer.cs @@ -6,10 +6,10 @@ using SabreTools.Serialization.Interfaces; namespace SabreTools.Serialization.Streams { - public partial class IRD : IStreamSerializer + public partial class IRD : IStreamSerializer { /// - public Stream? Serialize(Models.IRD.IRD? obj) + public Stream? Serialize(Models.IRD.File? obj) { // If the data is invalid if (obj?.Magic == null) diff --git a/Streams/Listrom.Deserializer.cs b/Streams/Listrom.Deserializer.cs index 6aaab992..c481d333 100644 --- a/Streams/Listrom.Deserializer.cs +++ b/Streams/Listrom.Deserializer.cs @@ -91,7 +91,7 @@ namespace SabreTools.Serialization.Streams } // Split the line for the name iteratively -#if NETFRAMEWORK +#if NETFRAMEWORK || NETCOREAPP3_1 string[] lineParts = line.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries); if (lineParts.Length == 1) lineParts = line.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries); @@ -119,7 +119,7 @@ namespace SabreTools.Serialization.Streams if (trimmedLine == null) continue; -#if NETFRAMEWORK +#if NETFRAMEWORK || NETCOREAPP3_1 lineParts = trimmedLine.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); #else lineParts = trimmedLine.Split(' ', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries); diff --git a/Streams/Listrom.Serializer.cs b/Streams/Listrom.Serializer.cs index ddb820c8..8eec68c4 100644 --- a/Streams/Listrom.Serializer.cs +++ b/Streams/Listrom.Serializer.cs @@ -118,7 +118,7 @@ namespace SabreTools.Serialization.Streams var rowBuilder = new StringBuilder(); int padding = 40 - (row.Size?.Length ?? 0); - if (padding < row.Name.Length) + if (padding < row.Name!.Length) padding = row.Name.Length + 2; rowBuilder.Append($"{row.Name.PadRight(padding, ' ')}"); diff --git a/Streams/N3DS.Deserializer.cs b/Streams/N3DS.Deserializer.cs index 921bd466..b906a12b 100644 --- a/Streams/N3DS.Deserializer.cs +++ b/Streams/N3DS.Deserializer.cs @@ -643,7 +643,11 @@ namespace SabreTools.Serialization.Streams exeFSHeader.FileHashes = new byte[10][]; for (int i = 0; i < 10; i++) { +#if NET40 || NET452 + exeFSHeader.FileHashes[i] = data.ReadBytes(0x20) ?? []; +#else exeFSHeader.FileHashes[i] = data.ReadBytes(0x20) ?? Array.Empty(); +#endif } return exeFSHeader; diff --git a/Streams/NewExecutable.Deserializer.cs b/Streams/NewExecutable.Deserializer.cs index eb931237..9e048e38 100644 --- a/Streams/NewExecutable.Deserializer.cs +++ b/Streams/NewExecutable.Deserializer.cs @@ -327,7 +327,11 @@ namespace SabreTools.Serialization.Streams .Select(rt => rt!.TypeID) .Union(resourceTable.ResourceTypes .Where(rt => rt != null) +#if NET40 || NET452 + .SelectMany(rt => rt!.Resources ?? []) +#else .SelectMany(rt => rt!.Resources ?? System.Array.Empty()) +#endif .Where(r => r!.IsIntegerType() == false) .Select(r => r!.ResourceID)) .Distinct() diff --git a/Streams/VPK.Deserializer.cs b/Streams/VPK.Deserializer.cs index e278b6d8..11960b33 100644 --- a/Streams/VPK.Deserializer.cs +++ b/Streams/VPK.Deserializer.cs @@ -167,7 +167,7 @@ namespace SabreTools.Serialization.Streams // Sanitize the extension for (int i = 0; i < 0x20; i++) { - extensionString = extensionString.Replace($"{(char)i}", string.Empty); + extensionString = extensionString!.Replace($"{(char)i}", string.Empty); } while (true) @@ -180,7 +180,7 @@ namespace SabreTools.Serialization.Streams // Sanitize the path for (int i = 0; i < 0x20; i++) { - pathString = pathString.Replace($"{(char)i}", string.Empty); + pathString = pathString!.Replace($"{(char)i}", string.Empty); } while (true) @@ -193,11 +193,11 @@ namespace SabreTools.Serialization.Streams // Sanitize the name for (int i = 0; i < 0x20; i++) { - nameString = nameString.Replace($"{(char)i}", string.Empty); + nameString = nameString!.Replace($"{(char)i}", string.Empty); } // Get the directory item - var directoryItem = ParseDirectoryItem(data, extensionString, pathString, nameString); + var directoryItem = ParseDirectoryItem(data, extensionString!, pathString!, nameString!); // Add the directory item directoryItems.Add(directoryItem); diff --git a/Wrappers/ConcreteInterfaceSerializer.cs b/Wrappers/ConcreteInterfaceSerializer.cs index 315026d9..97a84a0f 100644 --- a/Wrappers/ConcreteInterfaceSerializer.cs +++ b/Wrappers/ConcreteInterfaceSerializer.cs @@ -1,4 +1,5 @@ #if !NETFRAMEWORK + using System; using System.Reflection; using System.Text.Json; @@ -22,8 +23,13 @@ namespace SabreTools.Serialization.Wrappers throw new NotImplementedException(string.Format("Concrete class {0} is not supported", typeof(TAbstract))); } +#if NETCOREAPP3_1 + public override TAbstract Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) => + throw new NotImplementedException(); +#else public override TAbstract? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) => throw new NotImplementedException(); +#endif public override void Write(Utf8JsonWriter writer, TAbstract value, JsonSerializerOptions options) => JsonSerializer.Serialize(writer, value!, options); @@ -54,8 +60,13 @@ namespace SabreTools.Serialization.Wrappers throw new NotImplementedException(string.Format("Concrete class {0} is not supported", typeof(TInterface))); } +#if NETCOREAPP3_1 + public override TInterface Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) => + throw new NotImplementedException(); +#else public override TInterface? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) => throw new NotImplementedException(); +#endif public override void Write(System.Text.Json.Utf8JsonWriter writer, TInterface value, JsonSerializerOptions options) => JsonSerializer.Serialize(writer, value!, options); @@ -79,4 +90,5 @@ namespace SabreTools.Serialization.Wrappers public static T ThrowOnNull(this T? value) where T : class => value ?? throw new ArgumentNullException(); } } + #endif \ No newline at end of file diff --git a/Wrappers/IRD.cs b/Wrappers/IRD.cs index 0e330825..aa1f56d5 100644 --- a/Wrappers/IRD.cs +++ b/Wrappers/IRD.cs @@ -2,7 +2,7 @@ using System.IO; namespace SabreTools.Serialization.Wrappers { - public class IRD : WrapperBase + public class IRD : WrapperBase { #region Descriptive Properties @@ -14,14 +14,14 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// - public IRD(Models.IRD.IRD? model, byte[]? data, int offset) + public IRD(Models.IRD.File? model, byte[]? data, int offset) : base(model, data, offset) { // All logic is handled by the base class } /// - public IRD(Models.IRD.IRD? model, Stream? data) + public IRD(Models.IRD.File? model, Stream? data) : base(model, data) { // All logic is handled by the base class diff --git a/Wrappers/PortableExecutable.cs b/Wrappers/PortableExecutable.cs index 1cfe52e7..cd35abac 100644 --- a/Wrappers/PortableExecutable.cs +++ b/Wrappers/PortableExecutable.cs @@ -826,7 +826,11 @@ namespace SabreTools.Serialization.Wrappers // Try to find a key that matches var match = stringTable +#if NET40 || NET452 + .SelectMany(st => st?.Children ?? []) +#else .SelectMany(st => st?.Children ?? Array.Empty()) +#endif .FirstOrDefault(sd => sd != null && key.Equals(sd.Key, StringComparison.OrdinalIgnoreCase)); // Return either the match or null diff --git a/Wrappers/WrapperBase.cs b/Wrappers/WrapperBase.cs index 3626874e..7ab54896 100644 --- a/Wrappers/WrapperBase.cs +++ b/Wrappers/WrapperBase.cs @@ -65,7 +65,11 @@ namespace SabreTools.Serialization.Wrappers { get { +#if NETCOREAPP3_1 + var serializer = new System.Text.Json.JsonSerializerOptions { WriteIndented = true }; +#else var serializer = new System.Text.Json.JsonSerializerOptions { IncludeFields = true, WriteIndented = true }; +#endif serializer.Converters.Add(new ConcreteAbstractSerializer()); serializer.Converters.Add(new ConcreteInterfaceSerializer()); serializer.Converters.Add(new System.Text.Json.Serialization.JsonStringEnumConverter()); diff --git a/Wrappers/XMID.cs b/Wrappers/XMID.cs index eb18f770..4c135fef 100644 --- a/Wrappers/XMID.cs +++ b/Wrappers/XMID.cs @@ -26,8 +26,8 @@ namespace SabreTools.Serialization.Wrappers if (string.IsNullOrWhiteSpace(publisherIdentifier)) return "Unknown"; - if (Publishers.ContainsKey(publisherIdentifier)) - return Publishers[publisherIdentifier]; + if (Publishers.ContainsKey(publisherIdentifier!)) + return Publishers[publisherIdentifier!]; return $"Unknown ({publisherIdentifier})"; } diff --git a/Wrappers/XeMID.cs b/Wrappers/XeMID.cs index cab01a78..15e4f543 100644 --- a/Wrappers/XeMID.cs +++ b/Wrappers/XeMID.cs @@ -41,8 +41,8 @@ namespace SabreTools.Serialization.Wrappers if (string.IsNullOrWhiteSpace(publisherIdentifier)) return "Unknown"; - if (Publishers.ContainsKey(publisherIdentifier)) - return Publishers[publisherIdentifier]; + if (Publishers.ContainsKey(publisherIdentifier!)) + return Publishers[publisherIdentifier!]; return $"Unknown ({publisherIdentifier})"; }