From 4300d94858a471de24ff33254c02f14b45eb41cc Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Sun, 25 Jan 2026 14:32:49 -0500 Subject: [PATCH] Use newer "is not null" syntax --- InfoPrint/Features/MainFeature.cs | 26 ++--- .../CrossModel/ArchiveDotOrg.Serializer.cs | 4 +- .../CrossModel/AttractMode.Deserializer.cs | 2 +- .../CrossModel/AttractMode.Serializer.cs | 2 +- .../CrossModel/ClrMamePro.Deserializer.cs | 34 +++--- .../CrossModel/ClrMamePro.Serializer.cs | 34 +++--- .../CrossModel/DosCenter.Deserializer.cs | 6 +- .../CrossModel/DosCenter.Serializer.cs | 6 +- .../CrossModel/EverdriveSMDB.Serializer.cs | 2 +- .../CrossModel/Hashfile.Deserializer.cs | 22 ++-- .../CrossModel/Hashfile.Serializer.cs | 22 ++-- .../CrossModel/Listrom.Deserializer.cs | 6 +- .../CrossModel/Listrom.Serializer.cs | 4 +- .../CrossModel/Listxml.Deserializer.cs | 74 ++++++------ .../CrossModel/Listxml.Serializer.cs | 70 ++++++------ .../CrossModel/Logiqx.Deserializer.cs | 70 ++++++------ .../CrossModel/Logiqx.Serializer.cs | 34 +++--- .../CrossModel/M1.Deserializer.cs | 4 +- .../CrossModel/M1.Serializer.cs | 2 +- .../CrossModel/Mess.Deserializer.cs | 4 +- .../CrossModel/Mess.Serializer.cs | 2 +- .../CrossModel/OfflineList.Deserializer.cs | 6 +- .../CrossModel/OfflineList.Serializer.cs | 8 +- .../CrossModel/OpenMSX.Deserializer.cs | 14 +-- .../CrossModel/OpenMSX.Serializer.cs | 8 +- .../CrossModel/RomCenter.Deserializer.cs | 2 +- .../CrossModel/RomCenter.Serializer.cs | 8 +- .../CrossModel/SeparatedValue.Deserializer.cs | 8 +- .../CrossModel/SeparatedValue.Serializer.cs | 4 +- .../CrossModel/SoftwareList.Deserializer.cs | 24 ++-- .../CrossModel/SoftwareList.Serializer.cs | 22 ++-- .../Extensions/PortableExecutable.cs | 4 +- .../Extensions/StringBuilderExtensions.cs | 20 ++-- .../Models/Metadata/DictionaryBase.cs | 20 ++-- .../Readers/AbstractSyntaxNotationOne.cs | 2 +- SabreTools.Serialization/Readers/BSP.cs | 2 +- SabreTools.Serialization/Readers/CFB.cs | 2 +- .../Readers/ClrMamePro.cs | 32 +++--- SabreTools.Serialization/Readers/DosCenter.cs | 4 +- SabreTools.Serialization/Readers/ISO9660.cs | 8 +- .../Readers/InstallShieldCabinet.cs | 2 +- .../Readers/LinearExecutable.cs | 2 +- SabreTools.Serialization/Readers/Listrom.cs | 6 +- SabreTools.Serialization/Readers/MoPaQ.cs | 10 +- SabreTools.Serialization/Readers/N3DS.cs | 2 +- SabreTools.Serialization/Readers/PKZIP.cs | 6 +- .../Readers/PlayJAudio.cs | 4 +- .../Readers/PortableExecutable.cs | 40 +++---- SabreTools.Serialization/Readers/RomCenter.cs | 2 +- SabreTools.Serialization/Readers/VBSP.cs | 48 ++++---- SabreTools.Serialization/Readers/VPK.cs | 2 +- SabreTools.Serialization/Readers/WAD3.cs | 2 +- .../Readers/WiseOverlayHeader.cs | 2 +- .../Readers/WiseScript.cs | 28 ++--- .../Wrappers/AACSMediaKeyBlock.cs | 2 +- .../Wrappers/BFPK.Extraction.cs | 2 +- .../Wrappers/BSP.Extraction.cs | 2 +- .../Wrappers/BZip2.Extraction.cs | 2 +- .../Wrappers/CFB.Extraction.cs | 2 +- .../Wrappers/CFB.Printing.cs | 2 +- SabreTools.Serialization/Wrappers/CFB.cs | 2 +- .../Wrappers/GCF.Extraction.cs | 2 +- SabreTools.Serialization/Wrappers/GCF.cs | 4 +- .../Wrappers/GZip.Extraction.cs | 4 +- SabreTools.Serialization/Wrappers/GZip.cs | 10 +- .../Wrappers/ISO9660.Extraction.cs | 2 +- .../Wrappers/ISO9660.Printing.cs | 14 +-- .../InstallShieldArchiveV3.Extraction.cs | 2 +- .../Wrappers/InstallShieldArchiveV3.cs | 4 +- .../InstallShieldCabinet.Extraction.cs | 10 +- .../Wrappers/InstallShieldCabinet.cs | 4 +- .../InstallShieldExecutable.Extraction.cs | 2 +- .../Wrappers/LZKWAJ.Extraction.cs | 4 +- .../Wrappers/LZQBasic.Extraction.cs | 2 +- .../Wrappers/LZSZDD.Extraction.cs | 4 +- .../Wrappers/LinearExecutable.cs | 2 +- .../Wrappers/MicrosoftCabinet.Extraction.cs | 12 +- .../Wrappers/MicrosoftCabinet.cs | 4 +- .../Wrappers/MoPaQ.Extraction.cs | 2 +- .../Wrappers/NewExecutable.Extraction.cs | 10 +- .../Wrappers/NewExecutable.cs | 10 +- .../Wrappers/Nitro.Encryption.cs | 4 +- .../Wrappers/PAK.Extraction.cs | 2 +- .../Wrappers/PFF.Extraction.cs | 2 +- .../Wrappers/PKZIP.Extraction.cs | 4 +- .../Wrappers/PortableExecutable.Extraction.cs | 20 ++-- .../Wrappers/PortableExecutable.Printing.cs | 106 +++++++++--------- .../Wrappers/PortableExecutable.cs | 104 ++++++++--------- .../Wrappers/Quantum.Printing.cs | 2 +- .../Wrappers/RAR.Extraction.cs | 4 +- .../Wrappers/SGA.Extraction.cs | 4 +- SabreTools.Serialization/Wrappers/SGA.cs | 8 +- .../SecuROMMatroschkaPackage.Extraction.cs | 2 +- .../Wrappers/SevenZip.Extraction.cs | 6 +- .../Wrappers/TapeArchive.Extraction.cs | 2 +- .../Wrappers/VBSP.Extraction.cs | 2 +- .../Wrappers/VPK.Extraction.cs | 4 +- SabreTools.Serialization/Wrappers/VPK.cs | 2 +- .../Wrappers/WAD3.Extraction.cs | 2 +- .../Wrappers/WiseOverlayHeader.Extraction.cs | 2 +- .../Wrappers/WiseOverlayHeader.Printing.cs | 2 +- .../Wrappers/WiseOverlayHeader.cs | 4 +- .../Wrappers/WiseScript.cs | 8 +- .../Wrappers/WiseSectionHeader.Extraction.cs | 6 +- SabreTools.Serialization/Wrappers/XMID.cs | 4 +- .../Wrappers/XZ.Extraction.cs | 4 +- .../Wrappers/XZP.Extraction.cs | 2 +- SabreTools.Serialization/Wrappers/XeMID.cs | 6 +- .../Wrappers/ZSTD.Extraction.cs | 2 +- SabreTools.Serialization/Writers/CueSheet.cs | 4 +- .../Writers/EverdriveSMDB.cs | 2 +- SabreTools.Serialization/Writers/Listrom.cs | 8 +- SabreTools.Serialization/Writers/RomCenter.cs | 26 ++--- .../_EXTERNAL/StormLibSharp/MpqArchive.cs | 2 +- .../_EXTERNAL/StormLibSharp/MpqFileStream.cs | 2 +- 115 files changed, 635 insertions(+), 635 deletions(-) diff --git a/InfoPrint/Features/MainFeature.cs b/InfoPrint/Features/MainFeature.cs index e221d7e7..efb694e2 100644 --- a/InfoPrint/Features/MainFeature.cs +++ b/InfoPrint/Features/MainFeature.cs @@ -142,7 +142,7 @@ namespace InfoPrint.Features if (Hash) { var hashBuilder = PrintHashInfo(file); - if (hashBuilder != null) + if (hashBuilder is not null) { // Create the output data string hashData = hashBuilder.ToString(); @@ -243,29 +243,29 @@ namespace InfoPrint.Features // Output subset of available hashes var builder = new StringBuilder(); - if (hashes.TryGetValue(HashType.CRC16, out string? crc16) && crc16 != null) + if (hashes.TryGetValue(HashType.CRC16, out string? crc16) && crc16 is not null) builder.AppendLine($"CRC-16 checksum: {crc16}"); - if (hashes.TryGetValue(HashType.CRC32, out string? crc32) && crc32 != null) + if (hashes.TryGetValue(HashType.CRC32, out string? crc32) && crc32 is not null) builder.AppendLine($"CRC-32 checksum: {crc32}"); - if (hashes.TryGetValue(HashType.CRC64, out string? crc64) && crc64 != null) + if (hashes.TryGetValue(HashType.CRC64, out string? crc64) && crc64 is not null) builder.AppendLine($"CRC-64 checksum: {crc64}"); - if (hashes.TryGetValue(HashType.MD2, out string? md2) && md2 != null) + if (hashes.TryGetValue(HashType.MD2, out string? md2) && md2 is not null) builder.AppendLine($"MD2 hash: {md2}"); - if (hashes.TryGetValue(HashType.MD4, out string? md4) && md4 != null) + if (hashes.TryGetValue(HashType.MD4, out string? md4) && md4 is not null) builder.AppendLine($"MD4 hash: {md4}"); - if (hashes.TryGetValue(HashType.MD5, out string? md5) && md5 != null) + if (hashes.TryGetValue(HashType.MD5, out string? md5) && md5 is not null) builder.AppendLine($"MD5 hash: {md5}"); - if (hashes.TryGetValue(HashType.RIPEMD128, out string? ripemd128) && ripemd128 != null) + if (hashes.TryGetValue(HashType.RIPEMD128, out string? ripemd128) && ripemd128 is not null) builder.AppendLine($"RIPEMD-128 hash: {ripemd128}"); - if (hashes.TryGetValue(HashType.RIPEMD160, out string? ripemd160) && ripemd160 != null) + if (hashes.TryGetValue(HashType.RIPEMD160, out string? ripemd160) && ripemd160 is not null) builder.AppendLine($"RIPEMD-160 hash: {ripemd160}"); - if (hashes.TryGetValue(HashType.SHA1, out string? sha1) && sha1 != null) + if (hashes.TryGetValue(HashType.SHA1, out string? sha1) && sha1 is not null) builder.AppendLine($"SHA-1 hash: {sha1}"); - if (hashes.TryGetValue(HashType.SHA256, out string? sha256) && sha256 != null) + if (hashes.TryGetValue(HashType.SHA256, out string? sha256) && sha256 is not null) builder.AppendLine($"SHA-256 hash: {sha256}"); - if (hashes.TryGetValue(HashType.SHA384, out string? sha384) && sha384 != null) + if (hashes.TryGetValue(HashType.SHA384, out string? sha384) && sha384 is not null) builder.AppendLine($"SHA-384 hash: {sha384}"); - if (hashes.TryGetValue(HashType.SHA512, out string? sha512) && sha512 != null) + if (hashes.TryGetValue(HashType.SHA512, out string? sha512) && sha512 is not null) builder.AppendLine($"SHA-512 hash: {sha512}"); return builder; diff --git a/SabreTools.Serialization/CrossModel/ArchiveDotOrg.Serializer.cs b/SabreTools.Serialization/CrossModel/ArchiveDotOrg.Serializer.cs index 46027165..815abf05 100644 --- a/SabreTools.Serialization/CrossModel/ArchiveDotOrg.Serializer.cs +++ b/SabreTools.Serialization/CrossModel/ArchiveDotOrg.Serializer.cs @@ -16,7 +16,7 @@ namespace SabreTools.Serialization.CrossModel [Data.Models.Metadata.MetadataFile.HeaderKey] = ConvertHeaderToInternalModel(), }; - if (item?.File != null && item.File.Length > 0) + if (item?.File is not null && item.File.Length > 0) { metadataFile[Data.Models.Metadata.MetadataFile.MachineKey] = Array.ConvertAll(item.File, ConvertMachineToInternalModel); @@ -45,7 +45,7 @@ namespace SabreTools.Serialization.CrossModel var machine = new Data.Models.Metadata.Machine(); var rom = ConvertToInternalModel(item); - if (rom != null) + if (rom is not null) machine[Data.Models.Metadata.Machine.RomKey] = new Data.Models.Metadata.Rom[] { rom }; return machine; diff --git a/SabreTools.Serialization/CrossModel/AttractMode.Deserializer.cs b/SabreTools.Serialization/CrossModel/AttractMode.Deserializer.cs index e0db00de..533f8e97 100644 --- a/SabreTools.Serialization/CrossModel/AttractMode.Deserializer.cs +++ b/SabreTools.Serialization/CrossModel/AttractMode.Deserializer.cs @@ -13,7 +13,7 @@ namespace SabreTools.Serialization.CrossModel return null; var header = obj.Read(Data.Models.Metadata.MetadataFile.HeaderKey); - var metadataFile = header != null ? ConvertHeaderFromInternalModel(header) : new MetadataFile(); + var metadataFile = header is not null ? ConvertHeaderFromInternalModel(header) : new MetadataFile(); var machines = obj.Read(Data.Models.Metadata.MetadataFile.MachineKey); var items = new List(); diff --git a/SabreTools.Serialization/CrossModel/AttractMode.Serializer.cs b/SabreTools.Serialization/CrossModel/AttractMode.Serializer.cs index a874a27f..3f8188d2 100644 --- a/SabreTools.Serialization/CrossModel/AttractMode.Serializer.cs +++ b/SabreTools.Serialization/CrossModel/AttractMode.Serializer.cs @@ -16,7 +16,7 @@ namespace SabreTools.Serialization.CrossModel [Data.Models.Metadata.MetadataFile.HeaderKey] = ConvertHeaderToInternalModel(obj), }; - if (obj?.Row != null && obj.Row.Length > 0) + if (obj?.Row is not null && obj.Row.Length > 0) { metadataFile[Data.Models.Metadata.MetadataFile.MachineKey] = Array.ConvertAll(obj.Row, ConvertMachineToInternalModel); diff --git a/SabreTools.Serialization/CrossModel/ClrMamePro.Deserializer.cs b/SabreTools.Serialization/CrossModel/ClrMamePro.Deserializer.cs index f988c53d..735923a8 100644 --- a/SabreTools.Serialization/CrossModel/ClrMamePro.Deserializer.cs +++ b/SabreTools.Serialization/CrossModel/ClrMamePro.Deserializer.cs @@ -18,18 +18,18 @@ namespace SabreTools.Serialization.CrossModel var metadataFile = new MetadataFile(); var header = obj.Read(Data.Models.Metadata.MetadataFile.HeaderKey); - if (header != null) + if (header is not null) metadataFile.ClrMamePro = ConvertHeaderFromInternalModel(header); var machines = obj.Read(Data.Models.Metadata.MetadataFile.MachineKey); - if (machines != null && machines.Length > 0) + if (machines is not null && machines.Length > 0) { metadataFile.Game = Array.ConvertAll(machines, m => ConvertMachineFromInternalModel(m, game)); } var info = obj.Read(Data.Models.Metadata.MetadataFile.InfoSourceKey); - if (info != null) + if (info is not null) metadataFile.Info = ConvertInfoSourceFromInternalModel(info); return metadataFile; @@ -78,55 +78,55 @@ namespace SabreTools.Serialization.CrossModel gameBase.SampleOf = item.ReadString(Data.Models.Metadata.Machine.SampleOfKey); var releases = item.Read(Data.Models.Metadata.Machine.ReleaseKey); - if (releases != null && releases.Length > 0) + if (releases is not null && releases.Length > 0) gameBase.Release = Array.ConvertAll(releases, ConvertFromInternalModel); var biosSets = item.Read(Data.Models.Metadata.Machine.BiosSetKey); - if (biosSets != null && biosSets.Length > 0) + if (biosSets is not null && biosSets.Length > 0) gameBase.BiosSet = Array.ConvertAll(biosSets, ConvertFromInternalModel); var roms = item.Read(Data.Models.Metadata.Machine.RomKey); - if (roms != null && roms.Length > 0) + if (roms is not null && roms.Length > 0) gameBase.Rom = Array.ConvertAll(roms, ConvertFromInternalModel); var disks = item.Read(Data.Models.Metadata.Machine.DiskKey); - if (disks != null && disks.Length > 0) + if (disks is not null && disks.Length > 0) gameBase.Disk = Array.ConvertAll(disks, ConvertFromInternalModel); var medias = item.Read(Data.Models.Metadata.Machine.MediaKey); - if (medias != null && medias.Length > 0) + if (medias is not null && medias.Length > 0) gameBase.Media = Array.ConvertAll(medias, ConvertFromInternalModel); var samples = item.Read(Data.Models.Metadata.Machine.SampleKey); - if (samples != null && samples.Length > 0) + if (samples is not null && samples.Length > 0) gameBase.Sample = Array.ConvertAll(samples, ConvertFromInternalModel); var archives = item.Read(Data.Models.Metadata.Machine.ArchiveKey); - if (archives != null && archives.Length > 0) + if (archives is not null && archives.Length > 0) gameBase.Archive = Array.ConvertAll(archives, ConvertFromInternalModel); var chips = item.Read(Data.Models.Metadata.Machine.ChipKey); - if (chips != null && chips.Length > 0) + if (chips is not null && chips.Length > 0) gameBase.Chip = Array.ConvertAll(chips, ConvertFromInternalModel); var videos = item.Read(Data.Models.Metadata.Machine.VideoKey); - if (videos != null && videos.Length > 0) + if (videos is not null && videos.Length > 0) gameBase.Video = Array.ConvertAll(videos, ConvertFromInternalModel); var sound = item.Read(Data.Models.Metadata.Machine.SoundKey); - if (sound != null) + if (sound is not null) gameBase.Sound = ConvertFromInternalModel(sound); var input = item.Read(Data.Models.Metadata.Machine.InputKey); - if (input != null) + if (input is not null) gameBase.Input = ConvertFromInternalModel(input); var dipSwitches = item.Read(Data.Models.Metadata.Machine.DipSwitchKey); - if (dipSwitches != null && dipSwitches.Length > 0) + if (dipSwitches is not null && dipSwitches.Length > 0) gameBase.DipSwitch = Array.ConvertAll(dipSwitches, ConvertFromInternalModel); var driver = item.Read(Data.Models.Metadata.Machine.DriverKey); - if (driver != null) + if (driver is not null) gameBase.Driver = ConvertFromInternalModel(driver); return gameBase; @@ -357,7 +357,7 @@ namespace SabreTools.Serialization.CrossModel var info = new Info(); var sources = item.Read(Data.Models.Metadata.InfoSource.SourceKey); - if (sources != null && sources.Length > 0) + if (sources is not null && sources.Length > 0) info.Source = [.. sources]; return info; diff --git a/SabreTools.Serialization/CrossModel/ClrMamePro.Serializer.cs b/SabreTools.Serialization/CrossModel/ClrMamePro.Serializer.cs index 20779db2..88464923 100644 --- a/SabreTools.Serialization/CrossModel/ClrMamePro.Serializer.cs +++ b/SabreTools.Serialization/CrossModel/ClrMamePro.Serializer.cs @@ -13,16 +13,16 @@ namespace SabreTools.Serialization.CrossModel var metadataFile = new Data.Models.Metadata.MetadataFile(); - if (obj?.ClrMamePro != null) + if (obj?.ClrMamePro is not null) metadataFile[Data.Models.Metadata.MetadataFile.HeaderKey] = ConvertHeaderToInternalModel(obj.ClrMamePro); - if (obj?.Game != null && obj.Game.Length > 0) + if (obj?.Game is not null && obj.Game.Length > 0) { metadataFile[Data.Models.Metadata.MetadataFile.MachineKey] = Array.ConvertAll(obj.Game, ConvertMachineToInternalModel); } - if (obj?.Info != null) + if (obj?.Info is not null) metadataFile[Data.Models.Metadata.MetadataFile.InfoSourceKey] = ConvertInfoSourceToInternalModel(obj.Info); return metadataFile; @@ -74,73 +74,73 @@ namespace SabreTools.Serialization.CrossModel [Data.Models.Metadata.Machine.SampleOfKey] = item.SampleOf, }; - if (item.Release != null && item.Release.Length > 0) + if (item.Release is not null && item.Release.Length > 0) { machine[Data.Models.Metadata.Machine.ReleaseKey] = Array.ConvertAll(item.Release, ConvertToInternalModel); } - if (item.BiosSet != null && item.BiosSet.Length > 0) + if (item.BiosSet is not null && item.BiosSet.Length > 0) { machine[Data.Models.Metadata.Machine.BiosSetKey] = Array.ConvertAll(item.BiosSet, ConvertToInternalModel); } - if (item.Rom != null && item.Rom.Length > 0) + if (item.Rom is not null && item.Rom.Length > 0) { machine[Data.Models.Metadata.Machine.RomKey] = Array.ConvertAll(item.Rom, ConvertToInternalModel); } - if (item.Disk != null && item.Disk.Length > 0) + if (item.Disk is not null && item.Disk.Length > 0) { machine[Data.Models.Metadata.Machine.DiskKey] = Array.ConvertAll(item.Disk, ConvertToInternalModel); } - if (item.Media != null && item.Media.Length > 0) + if (item.Media is not null && item.Media.Length > 0) { machine[Data.Models.Metadata.Machine.MediaKey] = Array.ConvertAll(item.Media, ConvertToInternalModel); } - if (item.Sample != null && item.Sample.Length > 0) + if (item.Sample is not null && item.Sample.Length > 0) { machine[Data.Models.Metadata.Machine.SampleKey] = Array.ConvertAll(item.Sample, ConvertToInternalModel); } - if (item.Archive != null && item.Archive.Length > 0) + if (item.Archive is not null && item.Archive.Length > 0) { machine[Data.Models.Metadata.Machine.ArchiveKey] = Array.ConvertAll(item.Archive, ConvertToInternalModel); } - if (item.Chip != null && item.Chip.Length > 0) + if (item.Chip is not null && item.Chip.Length > 0) { machine[Data.Models.Metadata.Machine.ChipKey] = Array.ConvertAll(item.Chip, ConvertToInternalModel); } - if (item.Video != null) + if (item.Video is not null) { machine[Data.Models.Metadata.Machine.VideoKey] = Array.ConvertAll(item.Video, ConvertToInternalModel); } - if (item.Sound != null) + if (item.Sound is not null) machine[Data.Models.Metadata.Machine.SoundKey] = ConvertToInternalModel(item.Sound); - if (item.Input != null) + if (item.Input is not null) machine[Data.Models.Metadata.Machine.InputKey] = ConvertToInternalModel(item.Input); - if (item.DipSwitch != null && item.DipSwitch.Length > 0) + if (item.DipSwitch is not null && item.DipSwitch.Length > 0) { machine[Data.Models.Metadata.Machine.DipSwitchKey] = Array.ConvertAll(item.DipSwitch, ConvertToInternalModel); } - if (item.Driver != null) + if (item.Driver is not null) machine[Data.Models.Metadata.Machine.DriverKey] = ConvertToInternalModel(item.Driver); return machine; @@ -371,7 +371,7 @@ namespace SabreTools.Serialization.CrossModel var infoSource = new Data.Models.Metadata.InfoSource(); var sources = item.Source; - if (sources != null && sources.Length > 0) + if (sources is not null && sources.Length > 0) { string[] sourcesCopy = [.. sources]; infoSource[Data.Models.Metadata.InfoSource.SourceKey] = sourcesCopy; diff --git a/SabreTools.Serialization/CrossModel/DosCenter.Deserializer.cs b/SabreTools.Serialization/CrossModel/DosCenter.Deserializer.cs index 876f2034..a73db67f 100644 --- a/SabreTools.Serialization/CrossModel/DosCenter.Deserializer.cs +++ b/SabreTools.Serialization/CrossModel/DosCenter.Deserializer.cs @@ -14,11 +14,11 @@ namespace SabreTools.Serialization.CrossModel var metadataFile = new MetadataFile(); var header = obj.Read(Data.Models.Metadata.MetadataFile.HeaderKey); - if (header != null) + if (header is not null) metadataFile.DosCenter = ConvertHeaderFromInternalModel(header); var machines = obj.Read(Data.Models.Metadata.MetadataFile.MachineKey); - if (machines != null && machines.Length > 0) + if (machines is not null && machines.Length > 0) metadataFile.Game = Array.ConvertAll(machines, ConvertMachineFromInternalModel); return metadataFile; @@ -53,7 +53,7 @@ namespace SabreTools.Serialization.CrossModel }; var roms = item.Read(Data.Models.Metadata.Machine.RomKey); - if (roms != null && roms.Length > 0) + if (roms is not null && roms.Length > 0) game.File = Array.ConvertAll(roms, ConvertFromInternalModel); return game; diff --git a/SabreTools.Serialization/CrossModel/DosCenter.Serializer.cs b/SabreTools.Serialization/CrossModel/DosCenter.Serializer.cs index 3d64a453..c800e016 100644 --- a/SabreTools.Serialization/CrossModel/DosCenter.Serializer.cs +++ b/SabreTools.Serialization/CrossModel/DosCenter.Serializer.cs @@ -13,10 +13,10 @@ namespace SabreTools.Serialization.CrossModel var metadataFile = new Data.Models.Metadata.MetadataFile(); - if (obj?.DosCenter != null) + if (obj?.DosCenter is not null) metadataFile[Data.Models.Metadata.MetadataFile.HeaderKey] = ConvertHeaderToInternalModel(obj.DosCenter); - if (obj?.Game != null && obj.Game.Length > 0) + if (obj?.Game is not null && obj.Game.Length > 0) { metadataFile[Data.Models.Metadata.MetadataFile.MachineKey] = Array.ConvertAll(obj.Game, ConvertMachineToInternalModel); @@ -53,7 +53,7 @@ namespace SabreTools.Serialization.CrossModel [Data.Models.Metadata.Machine.NameKey] = item.Name, }; - if (item.File != null && item.File.Length > 0) + if (item.File is not null && item.File.Length > 0) { machine[Data.Models.Metadata.Machine.RomKey] = Array.ConvertAll(item.File, ConvertToInternalModel); diff --git a/SabreTools.Serialization/CrossModel/EverdriveSMDB.Serializer.cs b/SabreTools.Serialization/CrossModel/EverdriveSMDB.Serializer.cs index 46c4dd29..dccf6ccd 100644 --- a/SabreTools.Serialization/CrossModel/EverdriveSMDB.Serializer.cs +++ b/SabreTools.Serialization/CrossModel/EverdriveSMDB.Serializer.cs @@ -16,7 +16,7 @@ namespace SabreTools.Serialization.CrossModel [Data.Models.Metadata.MetadataFile.HeaderKey] = ConvertHeaderToInternalModel(), }; - if (obj?.Row != null && obj.Row.Length > 0) + if (obj?.Row is not null && obj.Row.Length > 0) { metadataFile[Data.Models.Metadata.MetadataFile.MachineKey] = Array.ConvertAll(obj.Row, ConvertMachineToInternalModel); diff --git a/SabreTools.Serialization/CrossModel/Hashfile.Deserializer.cs b/SabreTools.Serialization/CrossModel/Hashfile.Deserializer.cs index f4b30147..fa349c9d 100644 --- a/SabreTools.Serialization/CrossModel/Hashfile.Deserializer.cs +++ b/SabreTools.Serialization/CrossModel/Hashfile.Deserializer.cs @@ -38,27 +38,27 @@ namespace SabreTools.Serialization.CrossModel foreach (var hashfile in hashfiles) { - if (hashfile.SFV != null && hashfile.SFV.Length > 0) + if (hashfile.SFV is not null && hashfile.SFV.Length > 0) sfvs.AddRange(hashfile.SFV); - if (hashfile.MD2 != null && hashfile.MD2.Length > 0) + if (hashfile.MD2 is not null && hashfile.MD2.Length > 0) md2s.AddRange(hashfile.MD2); - if (hashfile.MD4 != null && hashfile.MD4.Length > 0) + if (hashfile.MD4 is not null && hashfile.MD4.Length > 0) md4s.AddRange(hashfile.MD4); - if (hashfile.MD5 != null && hashfile.MD5.Length > 0) + if (hashfile.MD5 is not null && hashfile.MD5.Length > 0) md5s.AddRange(hashfile.MD5); - if (hashfile.RIPEMD128 != null && hashfile.RIPEMD128.Length > 0) + if (hashfile.RIPEMD128 is not null && hashfile.RIPEMD128.Length > 0) ripemd128s.AddRange(hashfile.RIPEMD128); - if (hashfile.RIPEMD160 != null && hashfile.RIPEMD160.Length > 0) + if (hashfile.RIPEMD160 is not null && hashfile.RIPEMD160.Length > 0) ripemd160s.AddRange(hashfile.RIPEMD160); - if (hashfile.SHA1 != null && hashfile.SHA1.Length > 0) + if (hashfile.SHA1 is not null && hashfile.SHA1.Length > 0) sha1s.AddRange(hashfile.SHA1); - if (hashfile.SHA256 != null && hashfile.SHA256.Length > 0) + if (hashfile.SHA256 is not null && hashfile.SHA256.Length > 0) sha256s.AddRange(hashfile.SHA256); - if (hashfile.SHA384 != null && hashfile.SHA384.Length > 0) + if (hashfile.SHA384 is not null && hashfile.SHA384.Length > 0) sha384s.AddRange(hashfile.SHA384); - if (hashfile.SHA512 != null && hashfile.SHA512.Length > 0) + if (hashfile.SHA512 is not null && hashfile.SHA512.Length > 0) sha512s.AddRange(hashfile.SHA512); - if (hashfile.SpamSum != null && hashfile.SpamSum.Length > 0) + if (hashfile.SpamSum is not null && hashfile.SpamSum.Length > 0) spamsums.AddRange(hashfile.SpamSum); } diff --git a/SabreTools.Serialization/CrossModel/Hashfile.Serializer.cs b/SabreTools.Serialization/CrossModel/Hashfile.Serializer.cs index 232bf04d..4d79740a 100644 --- a/SabreTools.Serialization/CrossModel/Hashfile.Serializer.cs +++ b/SabreTools.Serialization/CrossModel/Hashfile.Serializer.cs @@ -41,27 +41,27 @@ namespace SabreTools.Serialization.CrossModel { var machine = new Data.Models.Metadata.Machine(); - if (item.SFV != null && item.SFV.Length > 0) + if (item.SFV is not null && item.SFV.Length > 0) machine[Data.Models.Metadata.Machine.RomKey] = Array.ConvertAll(item.SFV, ConvertToInternalModel); - else if (item.MD2 != null && item.MD2.Length > 0) + else if (item.MD2 is not null && item.MD2.Length > 0) machine[Data.Models.Metadata.Machine.RomKey] = Array.ConvertAll(item.MD2, ConvertToInternalModel); - else if (item.MD4 != null && item.MD4.Length > 0) + else if (item.MD4 is not null && item.MD4.Length > 0) machine[Data.Models.Metadata.Machine.RomKey] = Array.ConvertAll(item.MD4, ConvertToInternalModel); - else if (item.MD5 != null && item.MD5.Length > 0) + else if (item.MD5 is not null && item.MD5.Length > 0) machine[Data.Models.Metadata.Machine.RomKey] = Array.ConvertAll(item.MD5, ConvertToInternalModel); - else if (item.RIPEMD128 != null && item.RIPEMD128.Length > 0) + else if (item.RIPEMD128 is not null && item.RIPEMD128.Length > 0) machine[Data.Models.Metadata.Machine.RomKey] = Array.ConvertAll(item.RIPEMD128, ConvertToInternalModel); - else if (item.RIPEMD160 != null && item.RIPEMD160.Length > 0) + else if (item.RIPEMD160 is not null && item.RIPEMD160.Length > 0) machine[Data.Models.Metadata.Machine.RomKey] = Array.ConvertAll(item.RIPEMD160, ConvertToInternalModel); - else if (item.SHA1 != null && item.SHA1.Length > 0) + else if (item.SHA1 is not null && item.SHA1.Length > 0) machine[Data.Models.Metadata.Machine.RomKey] = Array.ConvertAll(item.SHA1, ConvertToInternalModel); - else if (item.SHA256 != null && item.SHA256.Length > 0) + else if (item.SHA256 is not null && item.SHA256.Length > 0) machine[Data.Models.Metadata.Machine.RomKey] = Array.ConvertAll(item.SHA256, ConvertToInternalModel); - else if (item.SHA384 != null && item.SHA384.Length > 0) + else if (item.SHA384 is not null && item.SHA384.Length > 0) machine[Data.Models.Metadata.Machine.RomKey] = Array.ConvertAll(item.SHA384, ConvertToInternalModel); - else if (item.SHA512 != null && item.SHA512.Length > 0) + else if (item.SHA512 is not null && item.SHA512.Length > 0) machine[Data.Models.Metadata.Machine.RomKey] = Array.ConvertAll(item.SHA512, ConvertToInternalModel); - else if (item.SpamSum != null && item.SpamSum.Length > 0) + else if (item.SpamSum is not null && item.SpamSum.Length > 0) machine[Data.Models.Metadata.Machine.RomKey] = Array.ConvertAll(item.SpamSum, ConvertToInternalModel); return machine; diff --git a/SabreTools.Serialization/CrossModel/Listrom.Deserializer.cs b/SabreTools.Serialization/CrossModel/Listrom.Deserializer.cs index 1f8c4497..c5b36cb1 100644 --- a/SabreTools.Serialization/CrossModel/Listrom.Deserializer.cs +++ b/SabreTools.Serialization/CrossModel/Listrom.Deserializer.cs @@ -15,7 +15,7 @@ namespace SabreTools.Serialization.CrossModel var metadataFile = new MetadataFile(); var machines = obj.Read(Data.Models.Metadata.MetadataFile.MachineKey); - if (machines != null && machines.Length > 0) + if (machines is not null && machines.Length > 0) metadataFile.Set = Array.ConvertAll(machines, ConvertMachineFromInternalModel); return metadataFile; @@ -35,13 +35,13 @@ namespace SabreTools.Serialization.CrossModel var rowItems = new List(); var roms = item.Read(Data.Models.Metadata.Machine.RomKey); - if (roms != null) + if (roms is not null) { rowItems.AddRange(Array.ConvertAll(roms, ConvertFromInternalModel)); } var disks = item.Read(Data.Models.Metadata.Machine.DiskKey); - if (disks != null) + if (disks is not null) rowItems.AddRange(Array.ConvertAll(disks, ConvertFromInternalModel)); set.Row = [.. rowItems]; diff --git a/SabreTools.Serialization/CrossModel/Listrom.Serializer.cs b/SabreTools.Serialization/CrossModel/Listrom.Serializer.cs index 85bba7dc..bf02b157 100644 --- a/SabreTools.Serialization/CrossModel/Listrom.Serializer.cs +++ b/SabreTools.Serialization/CrossModel/Listrom.Serializer.cs @@ -17,7 +17,7 @@ namespace SabreTools.Serialization.CrossModel [Data.Models.Metadata.MetadataFile.HeaderKey] = ConvertHeaderToInternalModel(), }; - if (obj?.Set != null && obj.Set.Length > 0) + if (obj?.Set is not null && obj.Set.Length > 0) { metadataFile[Data.Models.Metadata.MetadataFile.MachineKey] = Array.ConvertAll(obj.Set, ConvertMachineToInternalModel); @@ -54,7 +54,7 @@ namespace SabreTools.Serialization.CrossModel machine[Data.Models.Metadata.Machine.NameKey] = item.Driver; } - if (item.Row != null && item.Row.Length > 0) + if (item.Row is not null && item.Row.Length > 0) { var disks = new List(); var roms = new List(); diff --git a/SabreTools.Serialization/CrossModel/Listxml.Deserializer.cs b/SabreTools.Serialization/CrossModel/Listxml.Deserializer.cs index 84e0a5fe..af9978f6 100644 --- a/SabreTools.Serialization/CrossModel/Listxml.Deserializer.cs +++ b/SabreTools.Serialization/CrossModel/Listxml.Deserializer.cs @@ -12,10 +12,10 @@ namespace SabreTools.Serialization.CrossModel return null; var header = obj.Read(Data.Models.Metadata.MetadataFile.HeaderKey); - var mame = header != null ? ConvertMameFromInternalModel(header) : new Mame(); + var mame = header is not null ? ConvertMameFromInternalModel(header) : new Mame(); var machines = obj.Read(Data.Models.Metadata.MetadataFile.MachineKey); - if (machines != null && machines.Length > 0) + if (machines is not null && machines.Length > 0) mame.Game = Array.ConvertAll(machines, ConvertMachineFromInternalModel); return mame; @@ -59,83 +59,83 @@ namespace SabreTools.Serialization.CrossModel }; var biosSets = item.Read(Data.Models.Metadata.Machine.BiosSetKey); - if (biosSets != null && biosSets.Length > 0) + if (biosSets is not null && biosSets.Length > 0) machine.BiosSet = Array.ConvertAll(biosSets, ConvertFromInternalModel); var roms = item.Read(Data.Models.Metadata.Machine.RomKey); - if (roms != null && roms.Length > 0) + if (roms is not null && roms.Length > 0) machine.Rom = Array.ConvertAll(roms, ConvertFromInternalModel); var disks = item.Read(Data.Models.Metadata.Machine.DiskKey); - if (disks != null && disks.Length > 0) + if (disks is not null && disks.Length > 0) machine.Disk = Array.ConvertAll(disks, ConvertFromInternalModel); var deviceRefs = item.Read(Data.Models.Metadata.Machine.DeviceRefKey); - if (deviceRefs != null && deviceRefs.Length > 0) + if (deviceRefs is not null && deviceRefs.Length > 0) machine.DeviceRef = Array.ConvertAll(deviceRefs, ConvertFromInternalModel); var samples = item.Read(Data.Models.Metadata.Machine.SampleKey); - if (samples != null && samples.Length > 0) + if (samples is not null && samples.Length > 0) machine.Sample = Array.ConvertAll(samples, ConvertFromInternalModel); var chips = item.Read(Data.Models.Metadata.Machine.ChipKey); - if (chips != null && chips.Length > 0) + if (chips is not null && chips.Length > 0) machine.Chip = Array.ConvertAll(chips, ConvertFromInternalModel); var displays = item.Read(Data.Models.Metadata.Machine.DisplayKey); - if (displays != null && displays.Length > 0) + if (displays is not null && displays.Length > 0) machine.Display = Array.ConvertAll(displays, ConvertFromInternalModel); var videos = item.Read(Data.Models.Metadata.Machine.VideoKey); - if (videos != null && videos.Length > 0) + if (videos is not null && videos.Length > 0) machine.Video = Array.ConvertAll(videos, ConvertFromInternalModel); var sound = item.Read(Data.Models.Metadata.Machine.SoundKey); - if (sound != null) + if (sound is not null) machine.Sound = ConvertFromInternalModel(sound); var input = item.Read(Data.Models.Metadata.Machine.InputKey); - if (input != null) + if (input is not null) machine.Input = ConvertFromInternalModel(input); var dipSwitches = item.Read(Data.Models.Metadata.Machine.DipSwitchKey); - if (dipSwitches != null && dipSwitches.Length > 0) + if (dipSwitches is not null && dipSwitches.Length > 0) machine.DipSwitch = Array.ConvertAll(dipSwitches, ConvertFromInternalModel); var configurations = item.Read(Data.Models.Metadata.Machine.ConfigurationKey); - if (configurations != null && configurations.Length > 0) + if (configurations is not null && configurations.Length > 0) machine.Configuration = Array.ConvertAll(configurations, ConvertFromInternalModel); var ports = item.Read(Data.Models.Metadata.Machine.PortKey); - if (ports != null && ports.Length > 0) + if (ports is not null && ports.Length > 0) machine.Port = Array.ConvertAll(ports, ConvertFromInternalModel); var adjusters = item.Read(Data.Models.Metadata.Machine.AdjusterKey); - if (adjusters != null && adjusters.Length > 0) + if (adjusters is not null && adjusters.Length > 0) machine.Adjuster = Array.ConvertAll(adjusters, ConvertFromInternalModel); var driver = item.Read(Data.Models.Metadata.Machine.DriverKey); - if (driver != null) + if (driver is not null) machine.Driver = ConvertFromInternalModel(driver); var features = item.Read(Data.Models.Metadata.Machine.FeatureKey); - if (features != null && features.Length > 0) + if (features is not null && features.Length > 0) machine.Feature = Array.ConvertAll(features, ConvertFromInternalModel); var devices = item.Read(Data.Models.Metadata.Machine.DeviceKey); - if (devices != null && devices.Length > 0) + if (devices is not null && devices.Length > 0) machine.Device = Array.ConvertAll(devices, ConvertFromInternalModel); var slots = item.Read(Data.Models.Metadata.Machine.SlotKey); - if (slots != null && slots.Length > 0) + if (slots is not null && slots.Length > 0) machine.Slot = Array.ConvertAll(slots, ConvertFromInternalModel); var softwareLists = item.Read(Data.Models.Metadata.Machine.SoftwareListKey); - if (softwareLists != null && softwareLists.Length > 0) + if (softwareLists is not null && softwareLists.Length > 0) machine.SoftwareList = Array.ConvertAll(softwareLists, ConvertFromInternalModel); var ramOptions = item.Read(Data.Models.Metadata.Machine.RamOptionKey); - if (ramOptions != null && ramOptions.Length > 0) + if (ramOptions is not null && ramOptions.Length > 0) machine.RamOption = Array.ConvertAll(ramOptions, ConvertFromInternalModel); return machine; @@ -153,7 +153,7 @@ namespace SabreTools.Serialization.CrossModel }; var condition = item.Read(Data.Models.Metadata.Adjuster.ConditionKey); - if (condition != null) + if (condition is not null) adjuster.Condition = ConvertFromInternalModel(condition); return adjuster; @@ -229,15 +229,15 @@ namespace SabreTools.Serialization.CrossModel }; var condition = item.Read(Data.Models.Metadata.Configuration.ConditionKey); - if (condition != null) + if (condition is not null) configuration.Condition = ConvertFromInternalModel(condition); var confLocations = item.Read(Data.Models.Metadata.Configuration.ConfLocationKey); - if (confLocations != null && confLocations.Length > 0) + if (confLocations is not null && confLocations.Length > 0) configuration.ConfLocation = Array.ConvertAll(confLocations, ConvertFromInternalModel); var confSettings = item.Read(Data.Models.Metadata.Configuration.ConfSettingKey); - if (confSettings != null && confSettings.Length > 0) + if (confSettings is not null && confSettings.Length > 0) configuration.ConfSetting = Array.ConvertAll(confSettings, ConvertFromInternalModel); return configuration; @@ -270,7 +270,7 @@ namespace SabreTools.Serialization.CrossModel }; var condition = item.Read(Data.Models.Metadata.ConfSetting.ConditionKey); - if (condition != null) + if (condition is not null) confSetting.Condition = ConvertFromInternalModel(condition); return confSetting; @@ -314,11 +314,11 @@ namespace SabreTools.Serialization.CrossModel }; var instance = item.Read(Data.Models.Metadata.Device.InstanceKey); - if (instance != null) + if (instance is not null) device.Instance = ConvertFromInternalModel(instance); var extensions = item.Read(Data.Models.Metadata.Device.ExtensionKey); - if (extensions != null && extensions.Length > 0) + if (extensions is not null && extensions.Length > 0) device.Extension = Array.ConvertAll(extensions, ConvertFromInternalModel); return device; @@ -363,15 +363,15 @@ namespace SabreTools.Serialization.CrossModel }; var condition = item.Read(Data.Models.Metadata.DipSwitch.ConditionKey); - if (condition != null) + if (condition is not null) dipSwitch.Condition = ConvertFromInternalModel(condition); var dipLocations = item.Read(Data.Models.Metadata.DipSwitch.DipLocationKey); - if (dipLocations != null && dipLocations.Length > 0) + if (dipLocations is not null && dipLocations.Length > 0) dipSwitch.DipLocation = Array.ConvertAll(dipLocations, ConvertFromInternalModel); var dipValues = item.Read(Data.Models.Metadata.DipSwitch.DipValueKey); - if (dipValues != null && dipValues.Length > 0) + if (dipValues is not null && dipValues.Length > 0) dipSwitch.DipValue = Array.ConvertAll(dipValues, ConvertFromInternalModel); return dipSwitch; @@ -390,7 +390,7 @@ namespace SabreTools.Serialization.CrossModel }; var condition = item.Read(Data.Models.Metadata.DipValue.ConditionKey); - if (condition != null) + if (condition is not null) dipValue.Condition = ConvertFromInternalModel(condition); return dipValue; @@ -504,11 +504,11 @@ namespace SabreTools.Serialization.CrossModel }; var controlAttr = item.ReadString(Data.Models.Metadata.Input.ControlKey); - if (controlAttr != null) + if (controlAttr is not null) input.ControlAttr = controlAttr; var controls = item.Read(Data.Models.Metadata.Input.ControlKey); - if (controls != null && controls.Length > 0) + if (controls is not null && controls.Length > 0) input.Control = Array.ConvertAll(controls, ConvertFromInternalModel); return input; @@ -538,7 +538,7 @@ namespace SabreTools.Serialization.CrossModel }; var analogs = item.Read(Data.Models.Metadata.Port.AnalogKey); - if (analogs != null && analogs.Length > 0) + if (analogs is not null && analogs.Length > 0) port.Analog = Array.ConvertAll(analogs, ConvertFromInternalModel); return port; @@ -604,7 +604,7 @@ namespace SabreTools.Serialization.CrossModel }; var slotOptions = item.Read(Data.Models.Metadata.Slot.SlotOptionKey); - if (slotOptions != null && slotOptions.Length > 0) + if (slotOptions is not null && slotOptions.Length > 0) slot.SlotOption = Array.ConvertAll(slotOptions, ConvertFromInternalModel); return slot; diff --git a/SabreTools.Serialization/CrossModel/Listxml.Serializer.cs b/SabreTools.Serialization/CrossModel/Listxml.Serializer.cs index fbbabc8a..d4173c4f 100644 --- a/SabreTools.Serialization/CrossModel/Listxml.Serializer.cs +++ b/SabreTools.Serialization/CrossModel/Listxml.Serializer.cs @@ -16,7 +16,7 @@ namespace SabreTools.Serialization.CrossModel [Data.Models.Metadata.MetadataFile.HeaderKey] = ConvertHeaderToInternalModel(item), }; - if (item?.Game != null && item.Game.Length > 0) + if (item?.Game is not null && item.Game.Length > 0) { metadataFile[Data.Models.Metadata.MetadataFile.MachineKey] = Array.ConvertAll(item.Game, ConvertMachineToInternalModel); @@ -61,112 +61,112 @@ namespace SabreTools.Serialization.CrossModel [Data.Models.Metadata.Machine.HistoryKey] = item.History, }; - if (item.BiosSet != null && item.BiosSet.Length > 0) + if (item.BiosSet is not null && item.BiosSet.Length > 0) { machine[Data.Models.Metadata.Machine.BiosSetKey] = Array.ConvertAll(item.BiosSet, ConvertToInternalModel); } - if (item.Rom != null && item.Rom.Length > 0) + if (item.Rom is not null && item.Rom.Length > 0) { machine[Data.Models.Metadata.Machine.RomKey] = Array.ConvertAll(item.Rom, ConvertToInternalModel); } - if (item.Disk != null && item.Disk.Length > 0) + if (item.Disk is not null && item.Disk.Length > 0) { machine[Data.Models.Metadata.Machine.DiskKey] = Array.ConvertAll(item.Disk, ConvertToInternalModel); } - if (item.DeviceRef != null && item.DeviceRef.Length > 0) + if (item.DeviceRef is not null && item.DeviceRef.Length > 0) { machine[Data.Models.Metadata.Machine.DeviceRefKey] = Array.ConvertAll(item.DeviceRef, ConvertToInternalModel); } - if (item.Sample != null && item.Sample.Length > 0) + if (item.Sample is not null && item.Sample.Length > 0) { machine[Data.Models.Metadata.Machine.SampleKey] = Array.ConvertAll(item.Sample, ConvertToInternalModel); } - if (item.Chip != null && item.Chip.Length > 0) + if (item.Chip is not null && item.Chip.Length > 0) { machine[Data.Models.Metadata.Machine.ChipKey] = Array.ConvertAll(item.Chip, ConvertToInternalModel); } - if (item.Display != null && item.Display.Length > 0) + if (item.Display is not null && item.Display.Length > 0) { machine[Data.Models.Metadata.Machine.DisplayKey] = Array.ConvertAll(item.Display, ConvertToInternalModel); } - if (item.Video != null && item.Video.Length > 0) + if (item.Video is not null && item.Video.Length > 0) { machine[Data.Models.Metadata.Machine.VideoKey] = Array.ConvertAll(item.Video, ConvertToInternalModel); } - if (item.Sound != null) + if (item.Sound is not null) machine[Data.Models.Metadata.Machine.SoundKey] = ConvertToInternalModel(item.Sound); - if (item.Input != null) + if (item.Input is not null) machine[Data.Models.Metadata.Machine.InputKey] = ConvertToInternalModel(item.Input); - if (item.DipSwitch != null && item.DipSwitch.Length > 0) + if (item.DipSwitch is not null && item.DipSwitch.Length > 0) { machine[Data.Models.Metadata.Machine.DipSwitchKey] = Array.ConvertAll(item.DipSwitch, ConvertToInternalModel); } - if (item.Configuration != null && item.Configuration.Length > 0) + if (item.Configuration is not null && item.Configuration.Length > 0) { machine[Data.Models.Metadata.Machine.ConfigurationKey] = Array.ConvertAll(item.Configuration, ConvertToInternalModel); } - if (item.Port != null && item.Port.Length > 0) + if (item.Port is not null && item.Port.Length > 0) { machine[Data.Models.Metadata.Machine.PortKey] = Array.ConvertAll(item.Port, ConvertToInternalModel); } - if (item.Adjuster != null && item.Adjuster.Length > 0) + if (item.Adjuster is not null && item.Adjuster.Length > 0) { machine[Data.Models.Metadata.Machine.AdjusterKey] = Array.ConvertAll(item.Adjuster, ConvertToInternalModel); } - if (item.Driver != null) + if (item.Driver is not null) machine[Data.Models.Metadata.Machine.DriverKey] = ConvertToInternalModel(item.Driver); - if (item.Feature != null && item.Feature.Length > 0) + if (item.Feature is not null && item.Feature.Length > 0) { machine[Data.Models.Metadata.Machine.FeatureKey] = Array.ConvertAll(item.Feature, ConvertToInternalModel); } - if (item.Device != null && item.Device.Length > 0) + if (item.Device is not null && item.Device.Length > 0) { machine[Data.Models.Metadata.Machine.DeviceKey] = Array.ConvertAll(item.Device, ConvertToInternalModel); } - if (item.Slot != null && item.Slot.Length > 0) + if (item.Slot is not null && item.Slot.Length > 0) { machine[Data.Models.Metadata.Machine.SlotKey] = Array.ConvertAll(item.Slot, ConvertToInternalModel); } - if (item.SoftwareList != null && item.SoftwareList.Length > 0) + if (item.SoftwareList is not null && item.SoftwareList.Length > 0) { machine[Data.Models.Metadata.Machine.SoftwareListKey] = Array.ConvertAll(item.SoftwareList, ConvertToInternalModel); } - if (item.RamOption != null && item.RamOption.Length > 0) + if (item.RamOption is not null && item.RamOption.Length > 0) { machine[Data.Models.Metadata.Machine.RamOptionKey] = Array.ConvertAll(item.RamOption, ConvertToInternalModel); @@ -186,7 +186,7 @@ namespace SabreTools.Serialization.CrossModel [Data.Models.Metadata.Adjuster.DefaultKey] = item.Default, }; - if (item.Condition != null) + if (item.Condition is not null) adjuster[Data.Models.Metadata.Adjuster.ConditionKey] = ConvertToInternalModel(item.Condition); return adjuster; @@ -261,16 +261,16 @@ namespace SabreTools.Serialization.CrossModel [Data.Models.Metadata.Configuration.MaskKey] = item.Mask, }; - if (item.Condition != null) + if (item.Condition is not null) configuration[Data.Models.Metadata.Configuration.ConditionKey] = ConvertToInternalModel(item.Condition); - if (item.ConfLocation != null && item.ConfLocation.Length > 0) + if (item.ConfLocation is not null && item.ConfLocation.Length > 0) { configuration[Data.Models.Metadata.Configuration.ConfLocationKey] = Array.ConvertAll(item.ConfLocation, ConvertToInternalModel); } - if (item.ConfSetting != null && item.ConfSetting.Length > 0) + if (item.ConfSetting is not null && item.ConfSetting.Length > 0) { configuration[Data.Models.Metadata.Configuration.ConfSettingKey] = Array.ConvertAll(item.ConfSetting, ConvertToInternalModel); @@ -305,7 +305,7 @@ namespace SabreTools.Serialization.CrossModel [Data.Models.Metadata.ConfSetting.DefaultKey] = item.Default, }; - if (item.Condition != null) + if (item.Condition is not null) confSetting[Data.Models.Metadata.ConfSetting.ConditionKey] = ConvertToInternalModel(item.Condition); return confSetting; @@ -348,10 +348,10 @@ namespace SabreTools.Serialization.CrossModel [Data.Models.Metadata.Device.InterfaceKey] = item.Interface, }; - if (item.Instance != null) + if (item.Instance is not null) device[Data.Models.Metadata.Device.InstanceKey] = ConvertToInternalModel(item.Instance); - if (item.Extension != null && item.Extension.Length > 0) + if (item.Extension is not null && item.Extension.Length > 0) { device[Data.Models.Metadata.Device.ExtensionKey] = Array.ConvertAll(item.Extension, ConvertToInternalModel); @@ -398,16 +398,16 @@ namespace SabreTools.Serialization.CrossModel [Data.Models.Metadata.DipSwitch.MaskKey] = item.Mask, }; - if (item.Condition != null) + if (item.Condition is not null) dipSwitch[Data.Models.Metadata.DipSwitch.ConditionKey] = ConvertToInternalModel(item.Condition); - if (item.DipLocation != null && item.DipLocation.Length > 0) + if (item.DipLocation is not null && item.DipLocation.Length > 0) { dipSwitch[Data.Models.Metadata.DipSwitch.DipLocationKey] = Array.ConvertAll(item.DipLocation, ConvertToInternalModel); } - if (item.DipValue != null && item.DipValue.Length > 0) + if (item.DipValue is not null && item.DipValue.Length > 0) { dipSwitch[Data.Models.Metadata.DipSwitch.DipValueKey] = Array.ConvertAll(item.DipValue, ConvertToInternalModel); @@ -428,7 +428,7 @@ namespace SabreTools.Serialization.CrossModel [Data.Models.Metadata.DipValue.DefaultKey] = item.Default, }; - if (item.Condition != null) + if (item.Condition is not null) dipValue[Data.Models.Metadata.DipValue.ConditionKey] = ConvertToInternalModel(item.Condition); return dipValue; @@ -542,7 +542,7 @@ namespace SabreTools.Serialization.CrossModel [Data.Models.Metadata.Input.CoinsKey] = item.Coins, }; - if (item.Control != null && item.Control.Length > 0) + if (item.Control is not null && item.Control.Length > 0) { input[Data.Models.Metadata.Input.ControlKey] = Array.ConvertAll(item.Control, ConvertToInternalModel); @@ -574,7 +574,7 @@ namespace SabreTools.Serialization.CrossModel [Data.Models.Metadata.Port.TagKey] = item.Tag, }; - if (item.Analog != null && item.Analog.Length > 0) + if (item.Analog is not null && item.Analog.Length > 0) { port[Data.Models.Metadata.Port.AnalogKey] = Array.ConvertAll(item.Analog, ConvertToInternalModel); @@ -642,7 +642,7 @@ namespace SabreTools.Serialization.CrossModel [Data.Models.Metadata.Slot.NameKey] = item.Name, }; - if (item.SlotOption != null && item.SlotOption.Length > 0) + if (item.SlotOption is not null && item.SlotOption.Length > 0) { slot[Data.Models.Metadata.Slot.SlotOptionKey] = Array.ConvertAll(item.SlotOption, ConvertToInternalModel); diff --git a/SabreTools.Serialization/CrossModel/Logiqx.Deserializer.cs b/SabreTools.Serialization/CrossModel/Logiqx.Deserializer.cs index 89519e0e..296b24c6 100644 --- a/SabreTools.Serialization/CrossModel/Logiqx.Deserializer.cs +++ b/SabreTools.Serialization/CrossModel/Logiqx.Deserializer.cs @@ -18,7 +18,7 @@ namespace SabreTools.Serialization.CrossModel var datafile = new Datafile(); var header = obj.Read(Data.Models.Metadata.MetadataFile.HeaderKey); - if (header != null) + if (header is not null) { datafile.Build = header.ReadString(Data.Models.Metadata.Header.BuildKey); datafile.Debug = header.ReadString(Data.Models.Metadata.Header.DebugKey); @@ -27,7 +27,7 @@ namespace SabreTools.Serialization.CrossModel } var machines = obj.Read(Data.Models.Metadata.MetadataFile.MachineKey); - if (machines != null && machines.Length > 0) + if (machines is not null && machines.Length > 0) datafile.Game = Array.ConvertAll(machines, m => ConvertMachineFromInternalModel(m, game)); return datafile; @@ -60,19 +60,19 @@ namespace SabreTools.Serialization.CrossModel string? forceNodump = item.ReadString(Data.Models.Metadata.Header.ForceNodumpKey); string? forceUnpacking = item.ReadString(Data.Models.Metadata.Header.ForcePackingKey); - if (headerVal != null - || forceMerging != null - || forceNodump != null - || forceUnpacking != null) + if (headerVal is not null + || forceMerging is not null + || forceNodump is not null + || forceUnpacking is not null) { header.ClrMamePro = new Data.Models.Logiqx.ClrMamePro(); - if (headerVal != null) + if (headerVal is not null) header.ClrMamePro.Header = headerVal; - if (forceMerging != null) + if (forceMerging is not null) header.ClrMamePro.ForceMerging = forceMerging; - if (forceNodump != null) + if (forceNodump is not null) header.ClrMamePro.ForceNodump = forceNodump; - if (forceUnpacking != null) + if (forceUnpacking is not null) header.ClrMamePro.ForcePacking = forceUnpacking; } @@ -84,28 +84,28 @@ namespace SabreTools.Serialization.CrossModel string? lockBiosMode = item.ReadString(Data.Models.Metadata.Header.LockBiosModeKey); string? lockSampleMode = item.ReadString(Data.Models.Metadata.Header.LockSampleModeKey); - if (plugin != null - || romMode != null - || biosMode != null - || sampleMode != null - || lockRomMode != null - || lockBiosMode != null - || lockSampleMode != null) + if (plugin is not null + || romMode is not null + || biosMode is not null + || sampleMode is not null + || lockRomMode is not null + || lockBiosMode is not null + || lockSampleMode is not null) { header.RomCenter = new Data.Models.Logiqx.RomCenter(); - if (plugin != null) + if (plugin is not null) header.RomCenter.Plugin = plugin; - if (romMode != null) + if (romMode is not null) header.RomCenter.RomMode = romMode; - if (biosMode != null) + if (biosMode is not null) header.RomCenter.BiosMode = biosMode; - if (sampleMode != null) + if (sampleMode is not null) header.RomCenter.SampleMode = sampleMode; - if (lockRomMode != null) + if (lockRomMode is not null) header.RomCenter.LockRomMode = lockRomMode; - if (lockBiosMode != null) + if (lockBiosMode is not null) header.RomCenter.LockBiosMode = lockBiosMode; - if (lockSampleMode != null) + if (lockSampleMode is not null) header.RomCenter.LockSampleMode = lockSampleMode; } @@ -140,47 +140,47 @@ namespace SabreTools.Serialization.CrossModel gameBase.Category = item.ReadStringArray(Data.Models.Metadata.Machine.CategoryKey); var trurip = item.Read(Data.Models.Metadata.Machine.TruripKey); - if (trurip != null) + if (trurip is not null) gameBase.Trurip = trurip; var releases = item.Read(Data.Models.Metadata.Machine.ReleaseKey); - if (releases != null && releases.Length > 0) + if (releases is not null && releases.Length > 0) gameBase.Release = Array.ConvertAll(releases, ConvertFromInternalModel); var biosSets = item.Read(Data.Models.Metadata.Machine.BiosSetKey); - if (biosSets != null && biosSets.Length > 0) + if (biosSets is not null && biosSets.Length > 0) gameBase.BiosSet = Array.ConvertAll(biosSets, ConvertFromInternalModel); var roms = item.Read(Data.Models.Metadata.Machine.RomKey); - if (roms != null && roms.Length > 0) + if (roms is not null && roms.Length > 0) gameBase.Rom = Array.ConvertAll(roms, ConvertFromInternalModel); var disks = item.Read(Data.Models.Metadata.Machine.DiskKey); - if (disks != null && disks.Length > 0) + if (disks is not null && disks.Length > 0) gameBase.Disk = Array.ConvertAll(disks, ConvertFromInternalModel); var medias = item.Read(Data.Models.Metadata.Machine.MediaKey); - if (medias != null && medias.Length > 0) + if (medias is not null && medias.Length > 0) gameBase.Media = Array.ConvertAll(medias, ConvertFromInternalModel); var deviceRefs = item.Read(Data.Models.Metadata.Machine.DeviceRefKey); - if (deviceRefs != null && deviceRefs.Length > 0) + if (deviceRefs is not null && deviceRefs.Length > 0) gameBase.DeviceRef = Array.ConvertAll(deviceRefs, ConvertFromInternalModel); var samples = item.Read(Data.Models.Metadata.Machine.SampleKey); - if (samples != null && samples.Length > 0) + if (samples is not null && samples.Length > 0) gameBase.Sample = Array.ConvertAll(samples, ConvertFromInternalModel); var archives = item.Read(Data.Models.Metadata.Machine.ArchiveKey); - if (archives != null && archives.Length > 0) + if (archives is not null && archives.Length > 0) gameBase.Archive = Array.ConvertAll(archives, ConvertFromInternalModel); var driver = item.Read(Data.Models.Metadata.Machine.DriverKey); - if (driver != null) + if (driver is not null) gameBase.Driver = ConvertFromInternalModel(driver); var softwareLists = item.Read(Data.Models.Metadata.Machine.SoftwareListKey); - if (softwareLists != null && softwareLists.Length > 0) + if (softwareLists is not null && softwareLists.Length > 0) gameBase.SoftwareList = Array.ConvertAll(softwareLists, ConvertFromInternalModel); return gameBase; diff --git a/SabreTools.Serialization/CrossModel/Logiqx.Serializer.cs b/SabreTools.Serialization/CrossModel/Logiqx.Serializer.cs index 76a3aa56..316c3d77 100644 --- a/SabreTools.Serialization/CrossModel/Logiqx.Serializer.cs +++ b/SabreTools.Serialization/CrossModel/Logiqx.Serializer.cs @@ -18,7 +18,7 @@ namespace SabreTools.Serialization.CrossModel var machines = new List(); - if (item.Game != null && item.Game.Length > 0) + if (item.Game is not null && item.Game.Length > 0) machines.AddRange(Array.ConvertAll(item.Game, g => ConvertMachineToInternalModel(g))); foreach (var dir in item.Dir ?? []) @@ -37,7 +37,7 @@ namespace SabreTools.Serialization.CrossModel /// private static Data.Models.Metadata.Header ConvertHeaderToInternalModel(Datafile item) { - var header = item.Header != null ? ConvertHeaderToInternalModel(item.Header) : []; + var header = item.Header is not null ? ConvertHeaderToInternalModel(item.Header) : []; header[Data.Models.Metadata.Header.BuildKey] = item.Build; header[Data.Models.Metadata.Header.DebugKey] = item.Debug; @@ -68,7 +68,7 @@ namespace SabreTools.Serialization.CrossModel [Data.Models.Metadata.Header.TypeKey] = item.Type, }; - if (item.ClrMamePro != null) + if (item.ClrMamePro is not null) { header[Data.Models.Metadata.Header.HeaderKey] = item.ClrMamePro.Header; header[Data.Models.Metadata.Header.ForceMergingKey] = item.ClrMamePro.ForceMerging; @@ -76,7 +76,7 @@ namespace SabreTools.Serialization.CrossModel header[Data.Models.Metadata.Header.ForcePackingKey] = item.ClrMamePro.ForcePacking; } - if (item.RomCenter != null) + if (item.RomCenter is not null) { header[Data.Models.Metadata.Header.PluginKey] = item.RomCenter.Plugin; header[Data.Models.Metadata.Header.RomModeKey] = item.RomCenter.RomMode; @@ -97,12 +97,12 @@ namespace SabreTools.Serialization.CrossModel { // Get the directory name string? dirName = item.Name; - if (parent != null) + if (parent is not null) dirName = $"{parent}\\{item.Name}"; // Handle machine items Data.Models.Metadata.Machine[] machines = []; - if (item.Game != null && item.Game.Length > 0) + if (item.Game is not null && item.Game.Length > 0) machines = Array.ConvertAll(item.Game, g => ConvertMachineToInternalModel(g, dirName)); // Handle dir items @@ -121,7 +121,7 @@ namespace SabreTools.Serialization.CrossModel private static Data.Models.Metadata.Machine ConvertMachineToInternalModel(GameBase item, string? dir = null) { string? machineName = item.Name; - if (machineName != null && dir != null) + if (machineName is not null && dir is not null) machineName = $"{dir}\\{machineName}"; var machine = new Data.Models.Metadata.Machine @@ -148,34 +148,34 @@ namespace SabreTools.Serialization.CrossModel [Data.Models.Metadata.Machine.TruripKey] = item.Trurip, }; - if (item.Release != null && item.Release.Length > 0) + if (item.Release is not null && item.Release.Length > 0) machine[Data.Models.Metadata.Machine.ReleaseKey] = Array.ConvertAll(item.Release, ConvertToInternalModel); - if (item.BiosSet != null && item.BiosSet.Length > 0) + if (item.BiosSet is not null && item.BiosSet.Length > 0) machine[Data.Models.Metadata.Machine.BiosSetKey] = Array.ConvertAll(item.BiosSet, ConvertToInternalModel); - if (item.Rom != null && item.Rom.Length > 0) + if (item.Rom is not null && item.Rom.Length > 0) machine[Data.Models.Metadata.Machine.RomKey] = Array.ConvertAll(item.Rom, ConvertToInternalModel); - if (item.Disk != null && item.Disk.Length > 0) + if (item.Disk is not null && item.Disk.Length > 0) machine[Data.Models.Metadata.Machine.DiskKey] = Array.ConvertAll(item.Disk, ConvertToInternalModel); - if (item.Media != null && item.Media.Length > 0) + if (item.Media is not null && item.Media.Length > 0) machine[Data.Models.Metadata.Machine.MediaKey] = Array.ConvertAll(item.Media, ConvertToInternalModel); - if (item.DeviceRef != null && item.DeviceRef.Length > 0) + if (item.DeviceRef is not null && item.DeviceRef.Length > 0) machine[Data.Models.Metadata.Machine.DeviceRefKey] = Array.ConvertAll(item.DeviceRef, ConvertToInternalModel); - if (item.Sample != null && item.Sample.Length > 0) + if (item.Sample is not null && item.Sample.Length > 0) machine[Data.Models.Metadata.Machine.SampleKey] = Array.ConvertAll(item.Sample, ConvertToInternalModel); - if (item.Archive != null && item.Archive.Length > 0) + if (item.Archive is not null && item.Archive.Length > 0) machine[Data.Models.Metadata.Machine.ArchiveKey] = Array.ConvertAll(item.Archive, ConvertToInternalModel); - if (item.Driver != null) + if (item.Driver is not null) machine[Data.Models.Metadata.Machine.DriverKey] = ConvertToInternalModel(item.Driver); - if (item.SoftwareList != null && item.SoftwareList.Length > 0) + if (item.SoftwareList is not null && item.SoftwareList.Length > 0) machine[Data.Models.Metadata.Machine.SoftwareListKey] = Array.ConvertAll(item.SoftwareList, ConvertToInternalModel); return machine; diff --git a/SabreTools.Serialization/CrossModel/M1.Deserializer.cs b/SabreTools.Serialization/CrossModel/M1.Deserializer.cs index 28a2985c..fed470ee 100644 --- a/SabreTools.Serialization/CrossModel/M1.Deserializer.cs +++ b/SabreTools.Serialization/CrossModel/M1.Deserializer.cs @@ -11,10 +11,10 @@ namespace SabreTools.Serialization.CrossModel return null; var header = obj.Read(Data.Models.Metadata.MetadataFile.HeaderKey); - var m1 = header != null ? ConvertM1FromInternalModel(header) : new Data.Models.Listxml.M1(); + var m1 = header is not null ? ConvertM1FromInternalModel(header) : new Data.Models.Listxml.M1(); var machines = obj.Read(Data.Models.Metadata.MetadataFile.MachineKey); - if (machines != null && machines.Length > 0) + if (machines is not null && machines.Length > 0) m1.Game = Array.ConvertAll(machines, Listxml.ConvertMachineFromInternalModel); return m1; diff --git a/SabreTools.Serialization/CrossModel/M1.Serializer.cs b/SabreTools.Serialization/CrossModel/M1.Serializer.cs index 07ae6e0c..fb9bd468 100644 --- a/SabreTools.Serialization/CrossModel/M1.Serializer.cs +++ b/SabreTools.Serialization/CrossModel/M1.Serializer.cs @@ -15,7 +15,7 @@ namespace SabreTools.Serialization.CrossModel [Data.Models.Metadata.MetadataFile.HeaderKey] = ConvertHeaderToInternalModel(item), }; - if (item?.Game != null && item.Game.Length > 0) + if (item?.Game is not null && item.Game.Length > 0) { metadataFile[Data.Models.Metadata.MetadataFile.MachineKey] = Array.ConvertAll(item.Game, Listxml.ConvertMachineToInternalModel); diff --git a/SabreTools.Serialization/CrossModel/Mess.Deserializer.cs b/SabreTools.Serialization/CrossModel/Mess.Deserializer.cs index 437501fc..faf51440 100644 --- a/SabreTools.Serialization/CrossModel/Mess.Deserializer.cs +++ b/SabreTools.Serialization/CrossModel/Mess.Deserializer.cs @@ -11,10 +11,10 @@ namespace SabreTools.Serialization.CrossModel return null; var header = obj.Read(Data.Models.Metadata.MetadataFile.HeaderKey); - var m1 = header != null ? ConvertMessFromInternalModel(header) : new Data.Models.Listxml.Mess(); + var m1 = header is not null ? ConvertMessFromInternalModel(header) : new Data.Models.Listxml.Mess(); var machines = obj.Read(Data.Models.Metadata.MetadataFile.MachineKey); - if (machines != null && machines.Length > 0) + if (machines is not null && machines.Length > 0) m1.Game = Array.ConvertAll(machines, Listxml.ConvertMachineFromInternalModel); return m1; diff --git a/SabreTools.Serialization/CrossModel/Mess.Serializer.cs b/SabreTools.Serialization/CrossModel/Mess.Serializer.cs index b930ddd3..b35d23a6 100644 --- a/SabreTools.Serialization/CrossModel/Mess.Serializer.cs +++ b/SabreTools.Serialization/CrossModel/Mess.Serializer.cs @@ -15,7 +15,7 @@ namespace SabreTools.Serialization.CrossModel [Data.Models.Metadata.MetadataFile.HeaderKey] = ConvertHeaderToInternalModel(item), }; - if (item?.Game != null && item.Game.Length > 0) + if (item?.Game is not null && item.Game.Length > 0) { metadataFile[Data.Models.Metadata.MetadataFile.MachineKey] = Array.ConvertAll(item.Game, Listxml.ConvertMachineToInternalModel); diff --git a/SabreTools.Serialization/CrossModel/OfflineList.Deserializer.cs b/SabreTools.Serialization/CrossModel/OfflineList.Deserializer.cs index 4e8ab90d..02e1b261 100644 --- a/SabreTools.Serialization/CrossModel/OfflineList.Deserializer.cs +++ b/SabreTools.Serialization/CrossModel/OfflineList.Deserializer.cs @@ -12,10 +12,10 @@ namespace SabreTools.Serialization.CrossModel return null; var header = obj.Read(Data.Models.Metadata.MetadataFile.HeaderKey); - var dat = header != null ? ConvertHeaderFromInternalModel(header) : new Dat(); + var dat = header is not null ? ConvertHeaderFromInternalModel(header) : new Dat(); var machines = obj.Read(Data.Models.Metadata.MetadataFile.MachineKey); - if (machines != null && machines.Length > 0) + if (machines is not null && machines.Length > 0) { dat.Games = new Games { @@ -97,7 +97,7 @@ namespace SabreTools.Serialization.CrossModel }; var roms = item.Read(Data.Models.Metadata.Machine.RomKey); - if (roms != null && roms.Length > 0) + if (roms is not null && roms.Length > 0) { var romSizes = Array.ConvertAll(roms, r => r.ReadLong(Data.Models.Metadata.Rom.SizeKey) ?? -1); game.RomSize = Array.Find(romSizes, s => s > -1).ToString(); diff --git a/SabreTools.Serialization/CrossModel/OfflineList.Serializer.cs b/SabreTools.Serialization/CrossModel/OfflineList.Serializer.cs index a2067d9f..1b3f1139 100644 --- a/SabreTools.Serialization/CrossModel/OfflineList.Serializer.cs +++ b/SabreTools.Serialization/CrossModel/OfflineList.Serializer.cs @@ -16,7 +16,7 @@ namespace SabreTools.Serialization.CrossModel [Data.Models.Metadata.MetadataFile.HeaderKey] = ConvertHeaderToInternalModel(item), }; - if (item?.Games?.Game != null && item.Games.Game.Length > 0) + if (item?.Games?.Game is not null && item.Games.Game.Length > 0) { metadataFile[Data.Models.Metadata.MetadataFile.MachineKey] = Array.ConvertAll(item.Games.Game, ConvertMachineToInternalModel); @@ -35,7 +35,7 @@ namespace SabreTools.Serialization.CrossModel [Data.Models.Metadata.Header.SchemaLocationKey] = item.NoNamespaceSchemaLocation, }; - if (item.Configuration != null) + if (item.Configuration is not null) { header[Data.Models.Metadata.Header.NameKey] = item.Configuration.DatName; header[Data.Models.Metadata.Header.ImFolderKey] = item.Configuration.ImFolder; @@ -50,7 +50,7 @@ namespace SabreTools.Serialization.CrossModel header[Data.Models.Metadata.Header.RomTitleKey] = item.Configuration.RomTitle; } - if (item.GUI != null) + if (item.GUI is not null) { header[Data.Models.Metadata.Header.ImagesKey] = item.GUI.Images; } @@ -79,7 +79,7 @@ namespace SabreTools.Serialization.CrossModel [Data.Models.Metadata.Machine.DuplicateIDKey] = item.DuplicateID, }; - if (item.Files?.RomCRC != null && item.Files.RomCRC.Length > 0) + if (item.Files?.RomCRC is not null && item.Files.RomCRC.Length > 0) { machine[Data.Models.Metadata.Machine.RomKey] = Array.ConvertAll(item.Files.RomCRC, romCRC => diff --git a/SabreTools.Serialization/CrossModel/OpenMSX.Deserializer.cs b/SabreTools.Serialization/CrossModel/OpenMSX.Deserializer.cs index 5e8cd73e..adcea623 100644 --- a/SabreTools.Serialization/CrossModel/OpenMSX.Deserializer.cs +++ b/SabreTools.Serialization/CrossModel/OpenMSX.Deserializer.cs @@ -12,10 +12,10 @@ namespace SabreTools.Serialization.CrossModel return null; var header = obj.Read(Data.Models.Metadata.MetadataFile.HeaderKey); - var softwareDb = header != null ? ConvertHeaderFromInternalModel(header) : new SoftwareDb(); + var softwareDb = header is not null ? ConvertHeaderFromInternalModel(header) : new SoftwareDb(); var machines = obj.Read(Data.Models.Metadata.MetadataFile.MachineKey); - if (machines != null && machines.Length > 0) + if (machines is not null && machines.Length > 0) softwareDb.Software = Array.ConvertAll(machines, ConvertMachineFromInternalModel); return softwareDb; @@ -49,7 +49,7 @@ namespace SabreTools.Serialization.CrossModel }; var dumps = item.Read(Data.Models.Metadata.Machine.DumpKey); - if (dumps != null && dumps.Length > 0) + if (dumps is not null && dumps.Length > 0) game.Dump = Array.ConvertAll(dumps, ConvertFromInternalModel); return game; @@ -63,19 +63,19 @@ namespace SabreTools.Serialization.CrossModel var dump = new Dump(); var original = item.Read(Data.Models.Metadata.Dump.OriginalKey); - if (original != null) + if (original is not null) dump.Original = ConvertFromInternalModel(original); var rom = item.Read(Data.Models.Metadata.Dump.RomKey); - if (rom != null) + if (rom is not null) dump.Rom = ConvertRomFromInternalModel(rom); var megaRom = item.Read(Data.Models.Metadata.Dump.MegaRomKey); - if (megaRom != null) + if (megaRom is not null) dump.Rom = ConvertMegaRomFromInternalModel(megaRom); var sccPlusCart = item.Read(Data.Models.Metadata.Dump.SCCPlusCartKey); - if (sccPlusCart != null) + if (sccPlusCart is not null) dump.Rom = ConvertSCCPlusCartFromInternalModel(sccPlusCart); return dump; diff --git a/SabreTools.Serialization/CrossModel/OpenMSX.Serializer.cs b/SabreTools.Serialization/CrossModel/OpenMSX.Serializer.cs index 02f71a1e..2fb72638 100644 --- a/SabreTools.Serialization/CrossModel/OpenMSX.Serializer.cs +++ b/SabreTools.Serialization/CrossModel/OpenMSX.Serializer.cs @@ -16,7 +16,7 @@ namespace SabreTools.Serialization.CrossModel [Data.Models.Metadata.MetadataFile.HeaderKey] = ConvertHeaderToInternalModel(item), }; - if (item?.Software != null && item.Software.Length > 0) + if (item?.Software is not null && item.Software.Length > 0) { metadataFile[Data.Models.Metadata.MetadataFile.MachineKey] = Array.ConvertAll(item.Software, ConvertMachineToInternalModel); @@ -52,7 +52,7 @@ namespace SabreTools.Serialization.CrossModel [Data.Models.Metadata.Machine.CountryKey] = item.Country, }; - if (item.Dump != null && item.Dump.Length > 0) + if (item.Dump is not null && item.Dump.Length > 0) { machine[Data.Models.Metadata.Machine.DumpKey] = Array.ConvertAll(item.Dump, ConvertToInternalModel); @@ -68,10 +68,10 @@ namespace SabreTools.Serialization.CrossModel { var dump = new Data.Models.Metadata.Dump(); - if (item.Original != null) + if (item.Original is not null) dump[Data.Models.Metadata.Dump.OriginalKey] = ConvertToInternalModel(item.Original); - if (item.Rom != null) + if (item.Rom is not null) { switch (item.Rom) { diff --git a/SabreTools.Serialization/CrossModel/RomCenter.Deserializer.cs b/SabreTools.Serialization/CrossModel/RomCenter.Deserializer.cs index 50b21c54..afd41443 100644 --- a/SabreTools.Serialization/CrossModel/RomCenter.Deserializer.cs +++ b/SabreTools.Serialization/CrossModel/RomCenter.Deserializer.cs @@ -13,7 +13,7 @@ namespace SabreTools.Serialization.CrossModel return null; var header = obj.Read(Data.Models.Metadata.MetadataFile.HeaderKey); - var metadataFile = header != null ? ConvertHeaderFromInternalModel(header) : new MetadataFile(); + var metadataFile = header is not null ? ConvertHeaderFromInternalModel(header) : new MetadataFile(); var machines = obj.Read(Data.Models.Metadata.MetadataFile.MachineKey); var items = new List(); diff --git a/SabreTools.Serialization/CrossModel/RomCenter.Serializer.cs b/SabreTools.Serialization/CrossModel/RomCenter.Serializer.cs index d190ee43..214a66be 100644 --- a/SabreTools.Serialization/CrossModel/RomCenter.Serializer.cs +++ b/SabreTools.Serialization/CrossModel/RomCenter.Serializer.cs @@ -16,7 +16,7 @@ namespace SabreTools.Serialization.CrossModel [Data.Models.Metadata.MetadataFile.HeaderKey] = ConvertHeaderToInternalModel(obj), }; - if (obj?.Games?.Rom != null && obj.Games.Rom.Length > 0) + if (obj?.Games?.Rom is not null && obj.Games.Rom.Length > 0) { metadataFile[Data.Models.Metadata.MetadataFile.MachineKey] = Array.ConvertAll(obj.Games.Rom, ConvertMachineToInternalModel); @@ -32,7 +32,7 @@ namespace SabreTools.Serialization.CrossModel { var header = new Data.Models.Metadata.Header(); - if (item.Credits != null) + if (item.Credits is not null) { header[Data.Models.Metadata.Header.AuthorKey] = item.Credits.Author; header[Data.Models.Metadata.Header.VersionKey] = item.Credits.Version; @@ -43,7 +43,7 @@ namespace SabreTools.Serialization.CrossModel header[Data.Models.Metadata.Header.CommentKey] = item.Credits.Comment; } - if (item.Dat != null) + if (item.Dat is not null) { header[Data.Models.Metadata.Header.DatVersionKey] = item.Dat.Version; header[Data.Models.Metadata.Header.PluginKey] = item.Dat.Plugin; @@ -54,7 +54,7 @@ namespace SabreTools.Serialization.CrossModel header[Data.Models.Metadata.Header.ForceMergingKey] = "merge"; } - if (item.Emulator != null) + if (item.Emulator is not null) { header[Data.Models.Metadata.Header.RefNameKey] = item.Emulator.RefName; header[Data.Models.Metadata.Header.EmulatorVersionKey] = item.Emulator.Version; diff --git a/SabreTools.Serialization/CrossModel/SeparatedValue.Deserializer.cs b/SabreTools.Serialization/CrossModel/SeparatedValue.Deserializer.cs index 5cfdfce6..e6404c6b 100644 --- a/SabreTools.Serialization/CrossModel/SeparatedValue.Deserializer.cs +++ b/SabreTools.Serialization/CrossModel/SeparatedValue.Deserializer.cs @@ -13,7 +13,7 @@ namespace SabreTools.Serialization.CrossModel return null; var header = obj.Read(Data.Models.Metadata.MetadataFile.HeaderKey); - var metadataFile = header != null ? ConvertHeaderFromInternalModel(header) : new MetadataFile(); + var metadataFile = header is not null ? ConvertHeaderFromInternalModel(header) : new MetadataFile(); var machines = obj.Read(Data.Models.Metadata.MetadataFile.MachineKey); var items = new List(); @@ -46,21 +46,21 @@ namespace SabreTools.Serialization.CrossModel var rowItems = new List(); var roms = item.Read(Data.Models.Metadata.Machine.RomKey); - if (roms != null && roms.Length > 0) + if (roms is not null && roms.Length > 0) { rowItems.AddRange( Array.ConvertAll(roms, r => ConvertFromInternalModel(r, item, header))); } var disks = item.Read(Data.Models.Metadata.Machine.DiskKey); - if (disks != null && disks.Length > 0) + if (disks is not null && disks.Length > 0) { rowItems.AddRange( Array.ConvertAll(disks, d => ConvertFromInternalModel(d, item, header))); } var media = item.Read(Data.Models.Metadata.Machine.MediaKey); - if (media != null && media.Length > 0) + if (media is not null && media.Length > 0) { rowItems.AddRange( Array.ConvertAll(media, m => ConvertFromInternalModel(m, item, header))); diff --git a/SabreTools.Serialization/CrossModel/SeparatedValue.Serializer.cs b/SabreTools.Serialization/CrossModel/SeparatedValue.Serializer.cs index d315bbb5..95fab946 100644 --- a/SabreTools.Serialization/CrossModel/SeparatedValue.Serializer.cs +++ b/SabreTools.Serialization/CrossModel/SeparatedValue.Serializer.cs @@ -16,7 +16,7 @@ namespace SabreTools.Serialization.CrossModel [Data.Models.Metadata.MetadataFile.HeaderKey] = ConvertHeaderToInternalModel(obj), }; - if (obj?.Row != null && obj.Row.Length > 0) + if (obj?.Row is not null && obj.Row.Length > 0) { metadataFile[Data.Models.Metadata.MetadataFile.MachineKey] = Array.ConvertAll(obj.Row, ConvertMachineToInternalModel); @@ -35,7 +35,7 @@ namespace SabreTools.Serialization.CrossModel [Data.Models.Metadata.Header.HeaderKey] = item.Header, }; - if (item.Row != null && item.Row.Length > 0) + if (item.Row is not null && item.Row.Length > 0) { var first = item.Row[0]; header["FILENAME"] = first.FileName; // TODO: Make this an actual key to retrieve on an item -- OriginalFilename diff --git a/SabreTools.Serialization/CrossModel/SoftwareList.Deserializer.cs b/SabreTools.Serialization/CrossModel/SoftwareList.Deserializer.cs index f6833038..28b116b3 100644 --- a/SabreTools.Serialization/CrossModel/SoftwareList.Deserializer.cs +++ b/SabreTools.Serialization/CrossModel/SoftwareList.Deserializer.cs @@ -12,10 +12,10 @@ namespace SabreTools.Serialization.CrossModel return null; var header = obj.Read(Data.Models.Metadata.MetadataFile.HeaderKey); - var metadataFile = header != null ? ConvertHeaderFromInternalModel(header) : new Data.Models.SoftwareList.SoftwareList(); + var metadataFile = header is not null ? ConvertHeaderFromInternalModel(header) : new Data.Models.SoftwareList.SoftwareList(); var machines = obj.Read(Data.Models.Metadata.MetadataFile.MachineKey); - if (machines != null && machines.Length > 0) + if (machines is not null && machines.Length > 0) metadataFile.Software = Array.ConvertAll(machines, ConvertMachineFromInternalModel); return metadataFile; @@ -52,15 +52,15 @@ namespace SabreTools.Serialization.CrossModel }; var infos = item.Read(Data.Models.Metadata.Machine.InfoKey); - if (infos != null && infos.Length > 0) + if (infos is not null && infos.Length > 0) software.Info = Array.ConvertAll(infos, ConvertFromInternalModel); var sharedFeats = item.Read(Data.Models.Metadata.Machine.SharedFeatKey); - if (sharedFeats != null && sharedFeats.Length > 0) + if (sharedFeats is not null && sharedFeats.Length > 0) software.SharedFeat = Array.ConvertAll(sharedFeats, ConvertFromInternalModel); var parts = item.Read(Data.Models.Metadata.Machine.PartKey); - if (parts != null && parts.Length > 0) + if (parts is not null && parts.Length > 0) software.Part = Array.ConvertAll(parts, ConvertFromInternalModel); return software; @@ -80,7 +80,7 @@ namespace SabreTools.Serialization.CrossModel }; var roms = item.Read(Data.Models.Metadata.DataArea.RomKey); - if (roms != null && roms.Length > 0) + if (roms is not null && roms.Length > 0) dataArea.Rom = Array.ConvertAll(roms, ConvertFromInternalModel); return dataArea; @@ -99,7 +99,7 @@ namespace SabreTools.Serialization.CrossModel }; var dipValues = item.Read(Data.Models.Metadata.DipSwitch.DipValueKey); - if (dipValues != null && dipValues.Length > 0) + if (dipValues is not null && dipValues.Length > 0) dipSwitch.DipValue = Array.ConvertAll(dipValues, ConvertFromInternalModel); return dipSwitch; @@ -146,7 +146,7 @@ namespace SabreTools.Serialization.CrossModel }; var disks = item.Read(Data.Models.Metadata.DiskArea.DiskKey); - if (disks != null && disks.Length > 0) + if (disks is not null && disks.Length > 0) diskArea.Disk = Array.ConvertAll(disks, ConvertFromInternalModel); return diskArea; @@ -190,19 +190,19 @@ namespace SabreTools.Serialization.CrossModel }; var features = item.Read(Data.Models.Metadata.Part.FeatureKey); - if (features != null && features.Length > 0) + if (features is not null && features.Length > 0) part.Feature = Array.ConvertAll(features, ConvertFromInternalModel); var dataAreas = item.Read(Data.Models.Metadata.Part.DataAreaKey); - if (dataAreas != null && dataAreas.Length > 0) + if (dataAreas is not null && dataAreas.Length > 0) part.DataArea = Array.ConvertAll(dataAreas, ConvertFromInternalModel); var diskAreas = item.Read(Data.Models.Metadata.Part.DiskAreaKey); - if (diskAreas != null && diskAreas.Length > 0) + if (diskAreas is not null && diskAreas.Length > 0) part.DiskArea = Array.ConvertAll(diskAreas, ConvertFromInternalModel); var dipSwitches = item.Read(Data.Models.Metadata.Part.DipSwitchKey); - if (dipSwitches != null && dipSwitches.Length > 0) + if (dipSwitches is not null && dipSwitches.Length > 0) part.DipSwitch = Array.ConvertAll(dipSwitches, ConvertFromInternalModel); return part; diff --git a/SabreTools.Serialization/CrossModel/SoftwareList.Serializer.cs b/SabreTools.Serialization/CrossModel/SoftwareList.Serializer.cs index fe26471f..d9f2c7aa 100644 --- a/SabreTools.Serialization/CrossModel/SoftwareList.Serializer.cs +++ b/SabreTools.Serialization/CrossModel/SoftwareList.Serializer.cs @@ -16,7 +16,7 @@ namespace SabreTools.Serialization.CrossModel [Data.Models.Metadata.MetadataFile.HeaderKey] = ConvertHeaderToInternalModel(item), }; - if (item?.Software != null && item.Software.Length > 0) + if (item?.Software is not null && item.Software.Length > 0) { metadataFile[Data.Models.Metadata.MetadataFile.MachineKey] = Array.ConvertAll(item.Software, ConvertMachineToInternalModel); @@ -55,13 +55,13 @@ namespace SabreTools.Serialization.CrossModel [Data.Models.Metadata.Machine.NotesKey] = item.Notes, }; - if (item.Info != null && item.Info.Length > 0) + if (item.Info is not null && item.Info.Length > 0) machine[Data.Models.Metadata.Machine.InfoKey] = Array.ConvertAll(item.Info, ConvertToInternalModel); - if (item.SharedFeat != null && item.SharedFeat.Length > 0) + if (item.SharedFeat is not null && item.SharedFeat.Length > 0) machine[Data.Models.Metadata.Machine.SharedFeatKey] = Array.ConvertAll(item.SharedFeat, ConvertToInternalModel); - if (item.Part != null && item.Part.Length > 0) + if (item.Part is not null && item.Part.Length > 0) machine[Data.Models.Metadata.Machine.PartKey] = Array.ConvertAll(item.Part, ConvertToInternalModel); return machine; @@ -80,7 +80,7 @@ namespace SabreTools.Serialization.CrossModel [Data.Models.Metadata.DataArea.EndiannessKey] = item.Endianness, }; - if (item.Rom != null && item.Rom.Length > 0) + if (item.Rom is not null && item.Rom.Length > 0) dataArea[Data.Models.Metadata.DataArea.RomKey] = Array.ConvertAll(item.Rom, ConvertToInternalModel); return dataArea; @@ -98,7 +98,7 @@ namespace SabreTools.Serialization.CrossModel [Data.Models.Metadata.DipSwitch.MaskKey] = item.Mask, }; - if (item.DipValue != null && item.DipValue.Length > 0) + if (item.DipValue is not null && item.DipValue.Length > 0) dipSwitch[Data.Models.Metadata.DipSwitch.DipValueKey] = Array.ConvertAll(item.DipValue, ConvertToInternalModel); return dipSwitch; @@ -144,7 +144,7 @@ namespace SabreTools.Serialization.CrossModel [Data.Models.Metadata.DiskArea.NameKey] = item.Name, }; - if (item.Disk != null && item.Disk.Length > 0) + if (item.Disk is not null && item.Disk.Length > 0) diskArea[Data.Models.Metadata.DiskArea.DiskKey] = Array.ConvertAll(item.Disk, ConvertToInternalModel); return diskArea; @@ -187,16 +187,16 @@ namespace SabreTools.Serialization.CrossModel [Data.Models.Metadata.Part.InterfaceKey] = item.Interface, }; - if (item.Feature != null && item.Feature.Length > 0) + if (item.Feature is not null && item.Feature.Length > 0) part[Data.Models.Metadata.Part.FeatureKey] = Array.ConvertAll(item.Feature, ConvertToInternalModel); - if (item.DataArea != null && item.DataArea.Length > 0) + if (item.DataArea is not null && item.DataArea.Length > 0) part[Data.Models.Metadata.Part.DataAreaKey] = Array.ConvertAll(item.DataArea, ConvertToInternalModel); - if (item.DiskArea != null && item.DiskArea.Length > 0) + if (item.DiskArea is not null && item.DiskArea.Length > 0) part[Data.Models.Metadata.Part.DiskAreaKey] = Array.ConvertAll(item.DiskArea, ConvertToInternalModel); - if (item.DipSwitch != null && item.DipSwitch.Length > 0) + if (item.DipSwitch is not null && item.DipSwitch.Length > 0) part[Data.Models.Metadata.Part.DipSwitchKey] = Array.ConvertAll(item.DipSwitch, ConvertToInternalModel); return part; diff --git a/SabreTools.Serialization/Extensions/PortableExecutable.cs b/SabreTools.Serialization/Extensions/PortableExecutable.cs index 7bd3fe26..6d4493ee 100644 --- a/SabreTools.Serialization/Extensions/PortableExecutable.cs +++ b/SabreTools.Serialization/Extensions/PortableExecutable.cs @@ -30,7 +30,7 @@ namespace SabreTools.Data.Extensions // If the RVA matches a section start exactly, use that var matchingSection = Array.Find(sections, s => s.VirtualAddress == rva); - if (matchingSection != null) + if (matchingSection is not null) return rva - matchingSection.VirtualAddress + matchingSection.PointerToRawData; // Loop through all of the sections @@ -1009,7 +1009,7 @@ namespace SabreTools.Data.Extensions while (offset < entry.Data.Length) { string? stringValue = entry.Data.ReadPrefixedUnicodeString(ref offset); - if (stringValue != null) + if (stringValue is not null) { stringValue = stringValue.Replace("\n", "\\n").Replace("\r", newValue: "\\r"); stringTable[stringIndex++] = stringValue; diff --git a/SabreTools.Serialization/Extensions/StringBuilderExtensions.cs b/SabreTools.Serialization/Extensions/StringBuilderExtensions.cs index df7f33ea..95196f56 100644 --- a/SabreTools.Serialization/Extensions/StringBuilderExtensions.cs +++ b/SabreTools.Serialization/Extensions/StringBuilderExtensions.cs @@ -281,7 +281,7 @@ namespace SabreTools.Data.Extensions public static StringBuilder AppendLine(this StringBuilder sb, char[]? value, string prefixString) { string valueString = "[NULL]"; - if (value != null) + if (value is not null) { var valueArr = Array.ConvertAll(value, c => c.ToString()); valueString = string.Join(", ", valueArr); @@ -299,7 +299,7 @@ namespace SabreTools.Data.Extensions public static StringBuilder AppendLine(this StringBuilder sb, short[]? value, string prefixString) { string valueString = "[NULL]"; - if (value != null) + if (value is not null) { var valueArr = Array.ConvertAll(value, s => s.ToString()); valueString = string.Join(", ", valueArr); @@ -317,7 +317,7 @@ namespace SabreTools.Data.Extensions public static StringBuilder AppendLine(this StringBuilder sb, ushort[]? value, string prefixString) { string valueString = "[NULL]"; - if (value != null) + if (value is not null) { var valueArr = Array.ConvertAll(value, u => u.ToString()); valueString = string.Join(", ", valueArr); @@ -335,7 +335,7 @@ namespace SabreTools.Data.Extensions public static StringBuilder AppendLine(this StringBuilder sb, int[]? value, string prefixString) { string valueString = "[NULL]"; - if (value != null) + if (value is not null) { var valueArr = Array.ConvertAll(value, i => i.ToString()); valueString = string.Join(", ", valueArr); @@ -353,7 +353,7 @@ namespace SabreTools.Data.Extensions public static StringBuilder AppendLine(this StringBuilder sb, uint[]? value, string prefixString) { string valueString = "[NULL]"; - if (value != null) + if (value is not null) { var valueArr = Array.ConvertAll(value, u => u.ToString()); valueString = string.Join(", ", valueArr); @@ -371,7 +371,7 @@ namespace SabreTools.Data.Extensions public static StringBuilder AppendLine(this StringBuilder sb, float[]? value, string prefixString) { string valueString = "[NULL]"; - if (value != null) + if (value is not null) { var valueArr = Array.ConvertAll(value, u => u.ToString()); valueString = string.Join(", ", valueArr); @@ -389,7 +389,7 @@ namespace SabreTools.Data.Extensions public static StringBuilder AppendLine(this StringBuilder sb, long[]? value, string prefixString) { string valueString = "[NULL]"; - if (value != null) + if (value is not null) { var valueArr = Array.ConvertAll(value, l => l.ToString()); valueString = string.Join(", ", valueArr); @@ -407,7 +407,7 @@ namespace SabreTools.Data.Extensions public static StringBuilder AppendLine(this StringBuilder sb, ulong[]? value, string prefixString) { string valueString = "[NULL]"; - if (value != null) + if (value is not null) { var valueArr = Array.ConvertAll(value, u => u.ToString()); valueString = string.Join(", ", valueArr); @@ -425,7 +425,7 @@ namespace SabreTools.Data.Extensions public static StringBuilder AppendLine(this StringBuilder sb, double[]? value, string prefixString) { string valueString = "[NULL]"; - if (value != null) + if (value is not null) { var valueArr = Array.ConvertAll(value, u => u.ToString()); valueString = string.Join(", ", valueArr); @@ -443,7 +443,7 @@ namespace SabreTools.Data.Extensions public static StringBuilder AppendLine(this StringBuilder sb, Guid[]? value, string prefixString) { string valueString = "[NULL]"; - if (value != null) + if (value is not null) { var valueArr = Array.ConvertAll(value, g => g.ToString()); valueString = string.Join(", ", valueArr); diff --git a/SabreTools.Serialization/Models/Metadata/DictionaryBase.cs b/SabreTools.Serialization/Models/Metadata/DictionaryBase.cs index 233d3743..2b486f50 100644 --- a/SabreTools.Serialization/Models/Metadata/DictionaryBase.cs +++ b/SabreTools.Serialization/Models/Metadata/DictionaryBase.cs @@ -35,7 +35,7 @@ namespace SabreTools.Data.Models.Metadata return null; bool? asBool = Read(key); - if (asBool != null) + if (asBool is not null) return asBool; string? asString = Read(key); @@ -56,11 +56,11 @@ namespace SabreTools.Data.Models.Metadata return null; double? asDouble = Read(key); - if (asDouble != null) + if (asDouble is not null) return asDouble; string? asString = Read(key); - if (asString != null && double.TryParse(asString, out double asStringDouble)) + if (asString is not null && double.TryParse(asString, out double asStringDouble)) return asStringDouble; return null; @@ -76,11 +76,11 @@ namespace SabreTools.Data.Models.Metadata return null; long? asLong = Read(key); - if (asLong != null) + if (asLong is not null) return asLong; string? asString = Read(key); - if (asString != null && long.TryParse(asString, out long asStringLong)) + if (asString is not null && long.TryParse(asString, out long asStringLong)) return asStringLong; return null; @@ -95,11 +95,11 @@ namespace SabreTools.Data.Models.Metadata return null; string? asString = Read(key); - if (asString != null) + if (asString is not null) return asString; string[]? asArray = Read(key); - if (asArray != null) + if (asArray is not null) #if NETFRAMEWORK || NETSTANDARD2_0 return string.Join(",", asArray); #else @@ -121,15 +121,15 @@ namespace SabreTools.Data.Models.Metadata return null; string[]? asArray = Read(key); - if (asArray != null) + if (asArray is not null) return asArray; string? asString = Read(key); - if (asString != null) + if (asString is not null) return [asString]; asString = this[key]!.ToString(); - if (asString != null) + if (asString is not null) return [asString]; return null; diff --git a/SabreTools.Serialization/Readers/AbstractSyntaxNotationOne.cs b/SabreTools.Serialization/Readers/AbstractSyntaxNotationOne.cs index 54c47c91..f73e71d2 100644 --- a/SabreTools.Serialization/Readers/AbstractSyntaxNotationOne.cs +++ b/SabreTools.Serialization/Readers/AbstractSyntaxNotationOne.cs @@ -81,7 +81,7 @@ namespace SabreTools.Serialization.Readers while (data.Position < currentIndex + (long)obj.Length) { var value = ParseTypeLengthValue(data); - if (value != null) + if (value is not null) valueList.Add(value); } diff --git a/SabreTools.Serialization/Readers/BSP.cs b/SabreTools.Serialization/Readers/BSP.cs index a3a15341..44d8f702 100644 --- a/SabreTools.Serialization/Readers/BSP.cs +++ b/SabreTools.Serialization/Readers/BSP.cs @@ -68,7 +68,7 @@ namespace SabreTools.Serialization.Readers break; case LumpType.LUMP_VISIBILITY: var visiblityLump = ParseVisibilityLump(data, lumpEntry.Offset, lumpEntry.Length); - if (visiblityLump != null) + if (visiblityLump is not null) file.VisibilityLump = visiblityLump; break; diff --git a/SabreTools.Serialization/Readers/CFB.cs b/SabreTools.Serialization/Readers/CFB.cs index 5d4d9403..fc6172a5 100644 --- a/SabreTools.Serialization/Readers/CFB.cs +++ b/SabreTools.Serialization/Readers/CFB.cs @@ -54,7 +54,7 @@ namespace SabreTools.Serialization.Readers var difatSectors = new List(); // Add the sectors from the header - if (fileHeader.DIFAT != null) + if (fileHeader.DIFAT is not null) difatSectors.AddRange(fileHeader.DIFAT); // Loop through and add the DIFAT sectors diff --git a/SabreTools.Serialization/Readers/ClrMamePro.cs b/SabreTools.Serialization/Readers/ClrMamePro.cs index 9ea63df7..7bd071fa 100644 --- a/SabreTools.Serialization/Readers/ClrMamePro.cs +++ b/SabreTools.Serialization/Readers/ClrMamePro.cs @@ -116,7 +116,7 @@ namespace SabreTools.Serialization.Readers case "machine": case "resource": case "set": - if (game != null) + if (game is not null) { game.Release = [.. releases]; game.BiosSet = [.. biosSets]; @@ -298,7 +298,7 @@ namespace SabreTools.Serialization.Readers { case "source": string? source = reader.Standalone?.Value; - if (source != null) + if (source is not null) sources.Add(source); break; @@ -310,7 +310,7 @@ namespace SabreTools.Serialization.Readers || reader.TopLevel == "machine" || reader.TopLevel == "resource" || reader.TopLevel == "set") - && game != null + && game is not null && reader.RowType == CmpRowType.Internal) { // Create the block @@ -318,67 +318,67 @@ namespace SabreTools.Serialization.Readers { case "release": var release = CreateRelease(reader); - if (release != null) + if (release is not null) releases.Add(release); break; case "biosset": var biosSet = CreateBiosSet(reader); - if (biosSet != null) + if (biosSet is not null) biosSets.Add(biosSet); break; case "rom": var rom = CreateRom(reader); - if (rom != null) + if (rom is not null) roms.Add(rom); break; case "disk": var disk = CreateDisk(reader); - if (disk != null) + if (disk is not null) disks.Add(disk); break; case "media": var media = CreateMedia(reader); - if (media != null) + if (media is not null) medias.Add(media); break; case "sample": var sample = CreateSample(reader); - if (sample != null) + if (sample is not null) samples.Add(sample); break; case "archive": var archive = CreateArchive(reader); - if (archive != null) + if (archive is not null) archives.Add(archive); break; case "chip": var chip = CreateChip(reader); - if (chip != null) + if (chip is not null) chips.Add(chip); break; case "video": var video = CreateVideo(reader); - if (video != null) + if (video is not null) videos.Add(video); break; case "sound": var sound = CreateSound(reader); - if (sound != null) + if (sound is not null) game.Sound = sound; break; case "input": var input = CreateInput(reader); - if (input != null) + if (input is not null) game.Input = input; break; case "dipswitch": var dipSwitch = CreateDipSwitch(reader); - if (dipSwitch != null) + if (dipSwitch is not null) dipSwitches.Add(dipSwitch); break; case "driver": var driver = CreateDriver(reader); - if (driver != null) + if (driver is not null) game.Driver = driver; break; default: diff --git a/SabreTools.Serialization/Readers/DosCenter.cs b/SabreTools.Serialization/Readers/DosCenter.cs index ca79fe13..1dd2134d 100644 --- a/SabreTools.Serialization/Readers/DosCenter.cs +++ b/SabreTools.Serialization/Readers/DosCenter.cs @@ -44,7 +44,7 @@ namespace SabreTools.Serialization.Readers switch (lastTopLevel) { case "game": - if (game != null) + if (game is not null) { game.File = [.. files]; games.Add(game); @@ -127,7 +127,7 @@ namespace SabreTools.Serialization.Readers // Create the file and add to the list var file = CreateFile(reader); - if (file != null) + if (file is not null) files.Add(file); } } diff --git a/SabreTools.Serialization/Readers/ISO9660.cs b/SabreTools.Serialization/Readers/ISO9660.cs index bc9e4fa5..7bf5cd09 100644 --- a/SabreTools.Serialization/Readers/ISO9660.cs +++ b/SabreTools.Serialization/Readers/ISO9660.cs @@ -473,7 +473,7 @@ namespace SabreTools.Serialization.Readers } // If no valid path tables were found, don't add the table group - if (groupL.PathTableL != null || groupL.OptionalPathTableL != null || groupL.PathTableM != null || groupL.OptionalPathTableM != null) + if (groupL.PathTableL is not null || groupL.OptionalPathTableL is not null || groupL.PathTableM is not null || groupL.OptionalPathTableM is not null) groups.Add(groupL); // If the both-endian path table size value is consistent, return the single path table group @@ -504,7 +504,7 @@ namespace SabreTools.Serialization.Readers } // If no valid path tables were found, don't add the table group - if (groupB.PathTableL != null || groupB.OptionalPathTableL != null || groupB.PathTableM != null || groupB.OptionalPathTableM != null) + if (groupB.PathTableL is not null || groupB.OptionalPathTableL is not null || groupB.PathTableM is not null || groupB.OptionalPathTableM is not null) groups.Add(groupB); return groups; @@ -743,7 +743,7 @@ namespace SabreTools.Serialization.Readers if (dr.ExtendedAttributeRecordLength > 0) { var ear = ParseExtendedAttributeRecord(data); - if (ear != null) + if (ear is not null) { fileExtent.ExtendedAttributeRecord = ear; } @@ -759,7 +759,7 @@ namespace SabreTools.Serialization.Readers if (!bigEndian && dr.ExtentLocation.IsValid) { var bigEndianDir = ParseDirectory(data, sectorLength, blockLength, dr, true); - if (bigEndianDir != null) + if (bigEndianDir is not null) { // Add new directories to dictionary foreach (var kvp in bigEndianDir) diff --git a/SabreTools.Serialization/Readers/InstallShieldCabinet.cs b/SabreTools.Serialization/Readers/InstallShieldCabinet.cs index 71cf0b05..3b06800e 100644 --- a/SabreTools.Serialization/Readers/InstallShieldCabinet.cs +++ b/SabreTools.Serialization/Readers/InstallShieldCabinet.cs @@ -113,7 +113,7 @@ namespace SabreTools.Serialization.Readers // Create and add the file descriptor string? directoryName = ParseDirectoryName(data, majorVersion); - if (directoryName != null) + if (directoryName is not null) cabinet.DirectoryNames[i] = directoryName; } diff --git a/SabreTools.Serialization/Readers/LinearExecutable.cs b/SabreTools.Serialization/Readers/LinearExecutable.cs index 07fa4d76..f2377631 100644 --- a/SabreTools.Serialization/Readers/LinearExecutable.cs +++ b/SabreTools.Serialization/Readers/LinearExecutable.cs @@ -184,7 +184,7 @@ namespace SabreTools.Serialization.Readers while (true) { var bundle = ParseEntryTableBundle(data); - if (bundle != null) + if (bundle is not null) entryTable.Add(bundle); // If we have a 0-length entry diff --git a/SabreTools.Serialization/Readers/Listrom.cs b/SabreTools.Serialization/Readers/Listrom.cs index 7fc45f7c..e91f29cd 100644 --- a/SabreTools.Serialization/Readers/Listrom.cs +++ b/SabreTools.Serialization/Readers/Listrom.cs @@ -32,7 +32,7 @@ namespace SabreTools.Serialization.Readers if (string.IsNullOrEmpty(line)) { // If we have a set to process - if (set != null) + if (set is not null) { set.Row = [.. rows]; sets.Add(set); @@ -225,12 +225,12 @@ namespace SabreTools.Serialization.Readers break; } - if (row != null) + if (row is not null) rows.Add(row); } // If we have a set to process - if (set != null) + if (set is not null) { set.Row = [.. rows]; sets.Add(set); diff --git a/SabreTools.Serialization/Readers/MoPaQ.cs b/SabreTools.Serialization/Readers/MoPaQ.cs index ae76838c..58df5092 100644 --- a/SabreTools.Serialization/Readers/MoPaQ.cs +++ b/SabreTools.Serialization/Readers/MoPaQ.cs @@ -64,7 +64,7 @@ namespace SabreTools.Serialization.Readers // Set the hash table, if possible var hashTable = ParseHashTable(data, initialOffset, archive.ArchiveHeader, decrypter); - if (hashTable != null) + if (hashTable is not null) archive.HashTable = hashTable; #endregion @@ -73,7 +73,7 @@ namespace SabreTools.Serialization.Readers // Set the block table, if possible var blockTable = ParseBlockTable(data, initialOffset, archive.ArchiveHeader, decrypter); - if (blockTable != null) + if (blockTable is not null) archive.BlockTable = blockTable; #endregion @@ -82,7 +82,7 @@ namespace SabreTools.Serialization.Readers // Set the hi-block table, if possible var hiBlockTable = ParseHiBlockTable(data, initialOffset, archive.ArchiveHeader); - if (hiBlockTable != null) + if (hiBlockTable is not null) archive.HiBlockTable = hiBlockTable; #endregion @@ -91,7 +91,7 @@ namespace SabreTools.Serialization.Readers // Set the BET table, if possible var betTable = ParseBetTable(data, initialOffset, archive.ArchiveHeader, decrypter); - if (betTable != null) + if (betTable is not null) archive.BetTable = betTable; #endregion @@ -100,7 +100,7 @@ namespace SabreTools.Serialization.Readers // Set the HET table, if possible var hetTable = ParseHetTable(data, initialOffset, archive.ArchiveHeader, decrypter); - if (hetTable != null) + if (hetTable is not null) archive.HetTable = hetTable; #endregion diff --git a/SabreTools.Serialization/Readers/N3DS.cs b/SabreTools.Serialization/Readers/N3DS.cs index e0c368ca..e13d5e35 100644 --- a/SabreTools.Serialization/Readers/N3DS.cs +++ b/SabreTools.Serialization/Readers/N3DS.cs @@ -52,7 +52,7 @@ namespace SabreTools.Serialization.Readers // Cache the media unit size for further use long mediaUnitSize = 0; - if (header.PartitionFlags != null) + if (header.PartitionFlags is not null) mediaUnitSize = (uint)(0x200 * Math.Pow(2, header.PartitionFlags[(int)NCSDFlags.MediaUnitSize])); #region Partitions diff --git a/SabreTools.Serialization/Readers/PKZIP.cs b/SabreTools.Serialization/Readers/PKZIP.cs index 2790e478..6f304d79 100644 --- a/SabreTools.Serialization/Readers/PKZIP.cs +++ b/SabreTools.Serialization/Readers/PKZIP.cs @@ -418,7 +418,7 @@ namespace SabreTools.Serialization.Readers obj.LocalFileHeader = localFileHeader; ulong compressedSize = localFileHeader.CompressedSize; - if (localFileHeader.ExtraFields != null) + if (localFileHeader.ExtraFields is not null) { foreach (var field in localFileHeader.ExtraFields) { @@ -660,7 +660,7 @@ namespace SabreTools.Serialization.Readers _ => ParseUnknownExtraField(data, ref offset), }; - if (field != null) + if (field is not null) fields.Add(field); } @@ -751,7 +751,7 @@ namespace SabreTools.Serialization.Readers _ => ParseUnknownExtraField(data, ref offset), }; - if (field != null) + if (field is not null) fields.Add(field); } diff --git a/SabreTools.Serialization/Readers/PlayJAudio.cs b/SabreTools.Serialization/Readers/PlayJAudio.cs index b718249a..5a6bb21f 100644 --- a/SabreTools.Serialization/Readers/PlayJAudio.cs +++ b/SabreTools.Serialization/Readers/PlayJAudio.cs @@ -74,7 +74,7 @@ namespace SabreTools.Serialization.Readers uint? unknownOffset2 = (audioHeader as AudioHeaderV1)?.UnknownOffset2; // If we have an unknown value 2 offset - if (unknownOffset2 != null && unknownOffset2 > 0) + if (unknownOffset2 is not null && unknownOffset2 > 0) { // Get the unknown value 2 offset long offset = initialOffset + unknownOffset2.Value; @@ -96,7 +96,7 @@ namespace SabreTools.Serialization.Readers uint? unknownOffset3 = (audioHeader as AudioHeaderV1)?.UnknownOffset3; // If we have an unknown block 3 offset - if (unknownOffset3 != null && unknownOffset3 > 0) + if (unknownOffset3 is not null && unknownOffset3 > 0) { // Get the unknown block 3 offset long offset = initialOffset + unknownOffset3.Value; diff --git a/SabreTools.Serialization/Readers/PortableExecutable.cs b/SabreTools.Serialization/Readers/PortableExecutable.cs index 53ea882a..479cbe54 100644 --- a/SabreTools.Serialization/Readers/PortableExecutable.cs +++ b/SabreTools.Serialization/Readers/PortableExecutable.cs @@ -81,7 +81,7 @@ namespace SabreTools.Serialization.Readers optionalHeader = ParseOptionalHeader(data, fileHeader.SizeOfOptionalHeader); // Set the optional header - if (optionalHeader != null) + if (optionalHeader is not null) pex.OptionalHeader = optionalHeader; } @@ -132,7 +132,7 @@ namespace SabreTools.Serialization.Readers #region Export Table // Should also be in a '.edata' section - if (optionalHeader.ExportTable != null) + if (optionalHeader.ExportTable is not null) { offset = initialOffset + optionalHeader.ExportTable.VirtualAddress.ConvertVirtualAddress(pex.SectionTable); @@ -153,7 +153,7 @@ namespace SabreTools.Serialization.Readers pex.ExportDirectoryTable = exportDirectoryTable; // If the export table was parsed, read the remaining pieces - if (exportDirectoryTable != null) + if (exportDirectoryTable is not null) { // Name offset = initialOffset + exportDirectoryTable.NameRVA.ConvertVirtualAddress(pex.SectionTable); @@ -194,7 +194,7 @@ namespace SabreTools.Serialization.Readers } // Name table - if (exportDirectoryTable.NumberOfNamePointers != 0 && pex.NamePointerTable?.Pointers != null) + if (exportDirectoryTable.NumberOfNamePointers != 0 && pex.NamePointerTable?.Pointers is not null) pex.ExportNameTable = ParseExportNameTable(data, initialOffset, pex.NamePointerTable.Pointers, pex.SectionTable); } } @@ -205,7 +205,7 @@ namespace SabreTools.Serialization.Readers #region Import Table // Should also be in a '.idata' section - if (optionalHeader.ImportTable != null) + if (optionalHeader.ImportTable is not null) { offset = initialOffset + optionalHeader.ImportTable.VirtualAddress.ConvertVirtualAddress(pex.SectionTable); @@ -225,7 +225,7 @@ namespace SabreTools.Serialization.Readers pex.ImportDirectoryTable = importDirectoryTable; // If the export table was parsed, read the remaining pieces - if (pex.ImportDirectoryTable != null) + if (pex.ImportDirectoryTable is not null) { // Names for (int i = 0; i < importDirectoryTable.Length; i++) @@ -252,7 +252,7 @@ namespace SabreTools.Serialization.Readers } // If an error was not encountered, read the remaining tables - if (pex.ImportDirectoryTable != null) + if (pex.ImportDirectoryTable is not null) { pex.ImportLookupTables = ParseImportLookupTables(data, initialOffset, @@ -275,7 +275,7 @@ namespace SabreTools.Serialization.Readers } // TODO: Figure out how to use this in lieu of the current ParseImportAddressTables - if (optionalHeader.ImportAddressTable != null) + if (optionalHeader.ImportAddressTable is not null) { offset = initialOffset + optionalHeader.ImportAddressTable.VirtualAddress.ConvertVirtualAddress(pex.SectionTable); @@ -297,7 +297,7 @@ namespace SabreTools.Serialization.Readers #region Resource Directory Table // Should also be in a '.rsrc' section - if (optionalHeader.ResourceTable != null) + if (optionalHeader.ResourceTable is not null) { offset = initialOffset + optionalHeader.ResourceTable.VirtualAddress.ConvertVirtualAddress(pex.SectionTable); @@ -331,7 +331,7 @@ namespace SabreTools.Serialization.Readers #region Hidden Resources // If we have not used up the full size, parse the remaining chunk as a single resource - if (pex.ResourceDirectoryTable?.Entries != null + if (pex.ResourceDirectoryTable?.Entries is not null && tableOffset < tableSize && (offset + tableOffset) != endOfSectionData) { @@ -368,7 +368,7 @@ namespace SabreTools.Serialization.Readers #region Certificate Table - if (optionalHeader.CertificateTable != null) + if (optionalHeader.CertificateTable is not null) { // The Certificate Table entry points to a table of attribute certificates. These // certificates are not loaded into memory as part of the image. As such, the first @@ -392,7 +392,7 @@ namespace SabreTools.Serialization.Readers #region Base Relocation Table // Should also be in a '.reloc' section - if (optionalHeader.BaseRelocationTable != null) + if (optionalHeader.BaseRelocationTable is not null) { offset = initialOffset + optionalHeader.BaseRelocationTable.VirtualAddress.ConvertVirtualAddress(pex.SectionTable); @@ -414,7 +414,7 @@ namespace SabreTools.Serialization.Readers #region Debug Table // Should also be in a '.debug' section - if (optionalHeader.Debug != null) + if (optionalHeader.Debug is not null) { offset = initialOffset + optionalHeader.Debug.VirtualAddress.ConvertVirtualAddress(pex.SectionTable); @@ -442,7 +442,7 @@ namespace SabreTools.Serialization.Readers #region Delay-Load Directory Table - if (optionalHeader.DelayImportDescriptor != null) + if (optionalHeader.DelayImportDescriptor is not null) { offset = initialOffset + optionalHeader.DelayImportDescriptor.VirtualAddress.ConvertVirtualAddress(pex.SectionTable); @@ -1018,7 +1018,7 @@ namespace SabreTools.Serialization.Readers obj.Hint = data.ReadUInt16LittleEndian(); string? name = data.ReadNullTerminatedAnsiString(); - if (name != null) + if (name is not null) obj.Name = name; return obj; @@ -1451,7 +1451,7 @@ namespace SabreTools.Serialization.Readers foreach (var entry in table.Entries) { // Handle directory entries directly - if (entry.DataEntry != null && entry.DataEntry.Size > 0) + if (entry.DataEntry is not null && entry.DataEntry.Size > 0) { // Convert the data RVA to an offset long nextOffset = entry.DataEntry.DataRVA.ConvertVirtualAddress(sections); @@ -1469,13 +1469,13 @@ namespace SabreTools.Serialization.Readers else if (nextOffset + entry.DataEntry.Size <= data.Length) { byte[]? entryData = data.ReadFrom(nextOffset + initialOffset, (int)entry.DataEntry.Size, retainPosition: true); - if (entryData != null) + if (entryData is not null) entry.DataEntry.Data = entryData; } } // Handle subdirectories by recursion - else if (entry.Subdirectory != null) + else if (entry.Subdirectory is not null) { ParseResourceData(data, initialOffset, @@ -1720,13 +1720,13 @@ namespace SabreTools.Serialization.Readers nextSymbolType = 3; } else if (obj.StorageClass == StorageClass.IMAGE_SYM_CLASS_FILE - && shortName != null) + && shortName is not null) { // Symbol name should be ".file" nextSymbolType = 4; } else if (obj.StorageClass == StorageClass.IMAGE_SYM_CLASS_STATIC - && shortName != null) + && shortName is not null) { // Should have the name of a section (like ".text") nextSymbolType = 5; diff --git a/SabreTools.Serialization/Readers/RomCenter.cs b/SabreTools.Serialization/Readers/RomCenter.cs index e93470ca..773180f4 100644 --- a/SabreTools.Serialization/Readers/RomCenter.cs +++ b/SabreTools.Serialization/Readers/RomCenter.cs @@ -161,7 +161,7 @@ namespace SabreTools.Serialization.Readers } // Add extra pieces and return - if (dat.Games != null && roms.Count > 0) + if (dat.Games is not null && roms.Count > 0) { dat.Games.Rom = [.. roms]; return dat; diff --git a/SabreTools.Serialization/Readers/VBSP.cs b/SabreTools.Serialization/Readers/VBSP.cs index 41cb1a72..9f0d2a99 100644 --- a/SabreTools.Serialization/Readers/VBSP.cs +++ b/SabreTools.Serialization/Readers/VBSP.cs @@ -357,7 +357,7 @@ namespace SabreTools.Serialization.Readers while (data.Position < offset + length) { var plane = data.ReadType(); - if (plane != null) + if (plane is not null) planes.Add(plane); } @@ -375,7 +375,7 @@ namespace SabreTools.Serialization.Readers while (data.Position < offset + length) { var texdata = data.ReadType(); - if (texdata != null) + if (texdata is not null) texdatas.Add(texdata); } @@ -436,7 +436,7 @@ namespace SabreTools.Serialization.Readers while (data.Position < offset + length) { var node = data.ReadType(); - if (node != null) + if (node is not null) nodes.Add(node); } @@ -454,7 +454,7 @@ namespace SabreTools.Serialization.Readers while (data.Position < offset + length) { var texinfo = data.ReadType(); - if (texinfo != null) + if (texinfo is not null) texinfos.Add(texinfo); } @@ -472,7 +472,7 @@ namespace SabreTools.Serialization.Readers while (data.Position < offset + length) { var face = data.ReadType(); - if (face != null) + if (face is not null) faces.Add(face); } @@ -490,7 +490,7 @@ namespace SabreTools.Serialization.Readers while (data.Position < offset + length) { var model = ParsePhysModel(data); - if (model != null) + if (model is not null) models.Add(model); } @@ -514,7 +514,7 @@ namespace SabreTools.Serialization.Readers for (int i = 0; i < model.Solids.Length; i++) { var solid = ParsePhysSolid(data); - if (solid != null) + if (solid is not null) model.Solids[i] = solid; } @@ -569,7 +569,7 @@ namespace SabreTools.Serialization.Readers for (int i = 0; i < lump.Count; i++) { var occluderData = data.ReadType(); - if (occluderData != null) + if (occluderData is not null) lump.Data[i] = occluderData; } lump.PolyDataCount = data.ReadInt32LittleEndian(); @@ -577,7 +577,7 @@ namespace SabreTools.Serialization.Readers for (int i = 0; i < lump.Count; i++) { var polyData = data.ReadType(); - if (polyData != null) + if (polyData is not null) lump.PolyData[i] = polyData; } lump.VertexIndexCount = data.ReadInt32LittleEndian(); @@ -601,7 +601,7 @@ namespace SabreTools.Serialization.Readers while (data.Position < offset + length) { var leaf = ParseVbspLeaf(data, version); - if (leaf != null) + if (leaf is not null) leaves.Add(leaf); } @@ -671,7 +671,7 @@ namespace SabreTools.Serialization.Readers while (data.Position < offset + length) { var edge = data.ReadType(); - if (edge != null) + if (edge is not null) edges.Add(edge); } @@ -705,7 +705,7 @@ namespace SabreTools.Serialization.Readers while (data.Position < offset + length) { var model = data.ReadType(); - if (model != null) + if (model is not null) models.Add(model); } @@ -723,7 +723,7 @@ namespace SabreTools.Serialization.Readers while (data.Position < offset + length) { var worldLight = data.ReadType(); - if (worldLight != null) + if (worldLight is not null) worldLights.Add(worldLight); } @@ -773,7 +773,7 @@ namespace SabreTools.Serialization.Readers while (data.Position < offset + length) { var brush = data.ReadType(); - if (brush != null) + if (brush is not null) brushes.Add(brush); } @@ -791,7 +791,7 @@ namespace SabreTools.Serialization.Readers while (data.Position < offset + length) { var brushside = data.ReadType(); - if (brushside != null) + if (brushside is not null) brushsides.Add(brushside); } @@ -809,7 +809,7 @@ namespace SabreTools.Serialization.Readers while (data.Position < offset + length) { var dispInfo = data.ReadType(); - if (dispInfo != null) + if (dispInfo is not null) dispInfos.Add(dispInfo); } @@ -827,7 +827,7 @@ namespace SabreTools.Serialization.Readers while (data.Position < offset + length) { var vert = data.ReadType(); - if (vert != null) + if (vert is not null) verts.Add(vert); } @@ -848,7 +848,7 @@ namespace SabreTools.Serialization.Readers for (int i = 0; i < lump.LumpCount; i++) { var dir = data.ReadType(); - if (dir != null) + if (dir is not null) lump.Directories[i] = dir; } @@ -866,7 +866,7 @@ namespace SabreTools.Serialization.Readers while (data.Position < offset + length) { var cubemap = data.ReadType(); - if (cubemap != null) + if (cubemap is not null) cubemaps.Add(cubemap); } @@ -898,7 +898,7 @@ namespace SabreTools.Serialization.Readers while (data.Position < offset + length) { var str = data.ReadNullTerminatedAnsiString(); - if (str != null) + if (str is not null) strings.Add(str); } @@ -932,7 +932,7 @@ namespace SabreTools.Serialization.Readers while (data.Position < offset + length) { var overlay = data.ReadType(); - if (overlay != null) + if (overlay is not null) overlays.Add(overlay); } @@ -950,7 +950,7 @@ namespace SabreTools.Serialization.Readers while (data.Position < offset + length) { var tri = data.ReadType(); - if (tri != null) + if (tri is not null) tris.Add(tri); } @@ -968,7 +968,7 @@ namespace SabreTools.Serialization.Readers while (data.Position < offset + length) { var index = data.ReadType(); - if (index != null) + if (index is not null) indicies.Add(index); } @@ -986,7 +986,7 @@ namespace SabreTools.Serialization.Readers while (data.Position < offset + length) { var lighting = data.ReadType(); - if (lighting != null) + if (lighting is not null) lightings.Add(lighting); } diff --git a/SabreTools.Serialization/Readers/VPK.cs b/SabreTools.Serialization/Readers/VPK.cs index 7b8bf42e..04b8160d 100644 --- a/SabreTools.Serialization/Readers/VPK.cs +++ b/SabreTools.Serialization/Readers/VPK.cs @@ -55,7 +55,7 @@ namespace SabreTools.Serialization.Readers #region Archive Hashes if (header?.Version == 2 - && file.ExtendedHeader != null + && file.ExtendedHeader is not null && file.ExtendedHeader.ArchiveMD5SectionSize > 0 && data.Position + file.ExtendedHeader.ArchiveMD5SectionSize <= data.Length) { diff --git a/SabreTools.Serialization/Readers/WAD3.cs b/SabreTools.Serialization/Readers/WAD3.cs index 869e7020..6c763fc8 100644 --- a/SabreTools.Serialization/Readers/WAD3.cs +++ b/SabreTools.Serialization/Readers/WAD3.cs @@ -78,7 +78,7 @@ namespace SabreTools.Serialization.Readers // Try to parse the file entry var fileEntry = ParseFileEntry(data, dirEntry.Type); - if (fileEntry != null) + if (fileEntry is not null) file.FileEntries[i] = fileEntry; } diff --git a/SabreTools.Serialization/Readers/WiseOverlayHeader.cs b/SabreTools.Serialization/Readers/WiseOverlayHeader.cs index 6bc104c1..07b58365 100644 --- a/SabreTools.Serialization/Readers/WiseOverlayHeader.cs +++ b/SabreTools.Serialization/Readers/WiseOverlayHeader.cs @@ -23,7 +23,7 @@ namespace SabreTools.Serialization.Readers var overlayHeader = ParseOverlayHeader(data); // DllName - if (overlayHeader.DllName != null && overlayHeader.DllName.IndexOfAny(Path.GetInvalidFileNameChars()) > 0) + if (overlayHeader.DllName is not null && overlayHeader.DllName.IndexOfAny(Path.GetInvalidFileNameChars()) > 0) return null; // WiseColors.dib diff --git a/SabreTools.Serialization/Readers/WiseScript.cs b/SabreTools.Serialization/Readers/WiseScript.cs index 94338cbf..e2b96bb3 100644 --- a/SabreTools.Serialization/Readers/WiseScript.cs +++ b/SabreTools.Serialization/Readers/WiseScript.cs @@ -69,9 +69,9 @@ namespace SabreTools.Serialization.Readers data.SeekIfPossible(current, SeekOrigin.Begin); // If the strings are valid - if ((ftpUrl != null && (ftpUrl.Length == 0 || ftpUrl.Split('.').Length > 2)) - && (logPath != null && (logPath.Length == 0 || logPath.StartsWith("%"))) - && (messageFont != null && (messageFont.Length == 0 || !IsTypicalControlCode(messageFont, strict: true))) + if ((ftpUrl is not null && (ftpUrl.Length == 0 || ftpUrl.Split('.').Length > 2)) + && (logPath is not null && (logPath.Length == 0 || logPath.StartsWith("%"))) + && (messageFont is not null && (messageFont.Length == 0 || !IsTypicalControlCode(messageFont, strict: true))) && !(ftpUrl.Length == 0 && logPath.Length == 0 && messageFont.Length == 0)) { // TODO: Figure out if this maps to existing fields @@ -92,9 +92,9 @@ namespace SabreTools.Serialization.Readers data.SeekIfPossible(current, SeekOrigin.Begin); // If the strings are valid - if ((ftpUrl != null && (ftpUrl.Length == 0 || ftpUrl.Split('.').Length > 2)) - && (logPath != null && (logPath.Length == 0 || logPath.StartsWith("%"))) - && (messageFont != null && (messageFont.Length == 0 || !IsTypicalControlCode(messageFont, strict: true))) + if ((ftpUrl is not null && (ftpUrl.Length == 0 || ftpUrl.Split('.').Length > 2)) + && (logPath is not null && (logPath.Length == 0 || logPath.StartsWith("%"))) + && (messageFont is not null && (messageFont.Length == 0 || !IsTypicalControlCode(messageFont, strict: true))) && !(ftpUrl.Length == 0 && logPath.Length == 0 && messageFont.Length == 0)) { header.Flags = data.ReadByteValue(); @@ -117,9 +117,9 @@ namespace SabreTools.Serialization.Readers data.SeekIfPossible(current, SeekOrigin.Begin); // If the strings are valid - if ((ftpUrl != null && (ftpUrl.Length == 0 || ftpUrl.Split('.').Length > 2)) - && (logPath != null && (logPath.Length == 0 || logPath.StartsWith("%"))) - && (messageFont != null && (messageFont.Length == 0 || !IsTypicalControlCode(messageFont, strict: true))) + if ((ftpUrl is not null && (ftpUrl.Length == 0 || ftpUrl.Split('.').Length > 2)) + && (logPath is not null && (logPath.Length == 0 || logPath.StartsWith("%"))) + && (messageFont is not null && (messageFont.Length == 0 || !IsTypicalControlCode(messageFont, strict: true))) && !(ftpUrl.Length == 0 && logPath.Length == 0 && messageFont.Length == 0)) { header.Flags = data.ReadByteValue(); @@ -174,7 +174,7 @@ namespace SabreTools.Serialization.Readers // Try to read the next block as an install file call var maybeInstall = ParseInstallFile(data, header.LanguageCount); - if (maybeInstall != null + if (maybeInstall is not null && (maybeInstall.DeflateEnd - maybeInstall.DeflateStart) < data.Length && (maybeInstall.DeflateEnd - maybeInstall.DeflateStart) < maybeInstall.InflatedSize) { @@ -583,9 +583,9 @@ namespace SabreTools.Serialization.Readers obj.ValueName = data.ReadNullTerminatedAnsiString(); // If the delete pattern is found - if (obj.UnknownFsllib != null && obj.UnknownFsllib.Length > 0 - && obj.Key != null && obj.Key.Length == 0 - && obj.NewValue != null && obj.NewValue.Length == 0) + if (obj.UnknownFsllib is not null && obj.UnknownFsllib.Length > 0 + && obj.Key is not null && obj.Key.Length == 0 + && obj.NewValue is not null && obj.NewValue.Length == 0) { data.SeekIfPossible(-(obj.ValueName?.Length ?? 0) - 1, SeekOrigin.Current); obj.ValueName = obj.NewValue; @@ -596,7 +596,7 @@ namespace SabreTools.Serialization.Readers } // If the last value is a control - else if (obj.ValueName != null && IsTypicalControlCode(obj.ValueName, strict: true)) + else if (obj.ValueName is not null && IsTypicalControlCode(obj.ValueName, strict: true)) { data.SeekIfPossible(-obj.ValueName.Length - 1, SeekOrigin.Current); obj.ValueName = obj.NewValue; diff --git a/SabreTools.Serialization/Wrappers/AACSMediaKeyBlock.cs b/SabreTools.Serialization/Wrappers/AACSMediaKeyBlock.cs index d5f99a1b..340f881f 100644 --- a/SabreTools.Serialization/Wrappers/AACSMediaKeyBlock.cs +++ b/SabreTools.Serialization/Wrappers/AACSMediaKeyBlock.cs @@ -28,7 +28,7 @@ namespace SabreTools.Serialization.Wrappers get { // Use the cached value, if it exists - if (field != null) + if (field is not null) return field; // Find the type and version record, if possible diff --git a/SabreTools.Serialization/Wrappers/BFPK.Extraction.cs b/SabreTools.Serialization/Wrappers/BFPK.Extraction.cs index 1701fa39..dbdda6dd 100644 --- a/SabreTools.Serialization/Wrappers/BFPK.Extraction.cs +++ b/SabreTools.Serialization/Wrappers/BFPK.Extraction.cs @@ -70,7 +70,7 @@ namespace SabreTools.Serialization.Wrappers // Ensure the full output directory exists filename = Path.Combine(outputDirectory, filename); var directoryName = Path.GetDirectoryName(filename); - if (directoryName != null && !Directory.Exists(directoryName)) + if (directoryName is not null && !Directory.Exists(directoryName)) Directory.CreateDirectory(directoryName); // Try to write the data diff --git a/SabreTools.Serialization/Wrappers/BSP.Extraction.cs b/SabreTools.Serialization/Wrappers/BSP.Extraction.cs index f786787c..79a4a107 100644 --- a/SabreTools.Serialization/Wrappers/BSP.Extraction.cs +++ b/SabreTools.Serialization/Wrappers/BSP.Extraction.cs @@ -71,7 +71,7 @@ namespace SabreTools.Serialization.Wrappers // Ensure the full output directory exists filename = Path.Combine(outputDirectory, filename); var directoryName = Path.GetDirectoryName(filename); - if (directoryName != null && !Directory.Exists(directoryName)) + if (directoryName is not null && !Directory.Exists(directoryName)) Directory.CreateDirectory(directoryName); // Try to write the data diff --git a/SabreTools.Serialization/Wrappers/BZip2.Extraction.cs b/SabreTools.Serialization/Wrappers/BZip2.Extraction.cs index 718f5c8f..2a26077b 100644 --- a/SabreTools.Serialization/Wrappers/BZip2.Extraction.cs +++ b/SabreTools.Serialization/Wrappers/BZip2.Extraction.cs @@ -32,7 +32,7 @@ namespace SabreTools.Serialization.Wrappers // Ensure the full output directory exists filename = Path.Combine(outputDirectory, filename); var directoryName = Path.GetDirectoryName(filename); - if (directoryName != null && !Directory.Exists(directoryName)) + if (directoryName is not null && !Directory.Exists(directoryName)) Directory.CreateDirectory(directoryName); // Extract the file diff --git a/SabreTools.Serialization/Wrappers/CFB.Extraction.cs b/SabreTools.Serialization/Wrappers/CFB.Extraction.cs index f2f92639..25e284de 100644 --- a/SabreTools.Serialization/Wrappers/CFB.Extraction.cs +++ b/SabreTools.Serialization/Wrappers/CFB.Extraction.cs @@ -82,7 +82,7 @@ namespace SabreTools.Serialization.Wrappers // Ensure the full output directory exists filename = Path.Combine(outputDirectory, filename); var directoryName = Path.GetDirectoryName(filename); - if (directoryName != null && !Directory.Exists(directoryName)) + if (directoryName is not null && !Directory.Exists(directoryName)) Directory.CreateDirectory(directoryName); // Try to write the data diff --git a/SabreTools.Serialization/Wrappers/CFB.Printing.cs b/SabreTools.Serialization/Wrappers/CFB.Printing.cs index a81ad28b..7164f671 100644 --- a/SabreTools.Serialization/Wrappers/CFB.Printing.cs +++ b/SabreTools.Serialization/Wrappers/CFB.Printing.cs @@ -99,7 +99,7 @@ namespace SabreTools.Serialization.Wrappers builder.AppendLine($" Directory Entry {i}"); builder.AppendLine(entry.Name?.TrimEnd('\0'), " Name"); - if (entry.Name != null) + if (entry.Name is not null) builder.AppendLine(Encoding.UTF8.GetBytes(entry.Name), " Name (bytes)"); builder.AppendLine(entry.NameLength, " Name length"); builder.AppendLine($" Object type: {entry.ObjectType} (0x{entry.ObjectType:X})"); diff --git a/SabreTools.Serialization/Wrappers/CFB.cs b/SabreTools.Serialization/Wrappers/CFB.cs index c3068068..02bda399 100644 --- a/SabreTools.Serialization/Wrappers/CFB.cs +++ b/SabreTools.Serialization/Wrappers/CFB.cs @@ -37,7 +37,7 @@ namespace SabreTools.Serialization.Wrappers get { // Use the cached value, if it exists - if (field != null) + if (field is not null) return field; // If there are no directory entries diff --git a/SabreTools.Serialization/Wrappers/GCF.Extraction.cs b/SabreTools.Serialization/Wrappers/GCF.Extraction.cs index ef6b746c..87528f67 100644 --- a/SabreTools.Serialization/Wrappers/GCF.Extraction.cs +++ b/SabreTools.Serialization/Wrappers/GCF.Extraction.cs @@ -79,7 +79,7 @@ namespace SabreTools.Serialization.Wrappers // Ensure the full output directory exists filename = Path.Combine(outputDirectory, filename); var directoryName = Path.GetDirectoryName(filename); - if (directoryName != null && !Directory.Exists(directoryName)) + if (directoryName is not null && !Directory.Exists(directoryName)) Directory.CreateDirectory(directoryName); // Try to write the data diff --git a/SabreTools.Serialization/Wrappers/GCF.cs b/SabreTools.Serialization/Wrappers/GCF.cs index f4a2f8c7..6fb33346 100644 --- a/SabreTools.Serialization/Wrappers/GCF.cs +++ b/SabreTools.Serialization/Wrappers/GCF.cs @@ -26,7 +26,7 @@ namespace SabreTools.Serialization.Wrappers get { // Use the cached value, if it exists - if (field != null) + if (field is not null) return field; // Otherwise, build the data block set @@ -50,7 +50,7 @@ namespace SabreTools.Serialization.Wrappers get { // Use the cached value, if it exists - if (field != null) + if (field is not null) return field; // Otherwise, scan and build the files diff --git a/SabreTools.Serialization/Wrappers/GZip.Extraction.cs b/SabreTools.Serialization/Wrappers/GZip.Extraction.cs index bab21d8d..78896253 100644 --- a/SabreTools.Serialization/Wrappers/GZip.Extraction.cs +++ b/SabreTools.Serialization/Wrappers/GZip.Extraction.cs @@ -37,7 +37,7 @@ namespace SabreTools.Serialization.Wrappers // Ensure directory separators are consistent string filename = Header.OriginalFileName - ?? (Filename != null ? Path.GetFileName(Filename).Replace(".gz", string.Empty) : null) + ?? (Filename is not null ? Path.GetFileName(Filename).Replace(".gz", string.Empty) : null) ?? $"extracted_file"; if (Path.DirectorySeparatorChar == '\\') @@ -48,7 +48,7 @@ namespace SabreTools.Serialization.Wrappers // Ensure the full output directory exists filename = Path.Combine(outputDirectory, filename); var directoryName = Path.GetDirectoryName(filename); - if (directoryName != null && !Directory.Exists(directoryName)) + if (directoryName is not null && !Directory.Exists(directoryName)) Directory.CreateDirectory(directoryName); // Open the source as a DEFLATE stream diff --git a/SabreTools.Serialization/Wrappers/GZip.cs b/SabreTools.Serialization/Wrappers/GZip.cs index b44d3191..e7cdda88 100644 --- a/SabreTools.Serialization/Wrappers/GZip.cs +++ b/SabreTools.Serialization/Wrappers/GZip.cs @@ -28,7 +28,7 @@ namespace SabreTools.Serialization.Wrappers return null; // Use the cached value, if it exists - if (field != null) + if (field is not null) return field; // CRC-32 is the second packed field @@ -51,7 +51,7 @@ namespace SabreTools.Serialization.Wrappers return null; // Use the cached value, if it exists - if (field != null) + if (field is not null) return field; // MD5 is the first packed field @@ -108,11 +108,11 @@ namespace SabreTools.Serialization.Wrappers // Add extra lengths field += Header.ExtraLength; - if (Header.OriginalFileName != null) + if (Header.OriginalFileName is not null) field += Header.OriginalFileName.Length + 1; - if (Header.FileComment != null) + if (Header.FileComment is not null) field += Header.FileComment.Length + 1; - if (Header.CRC16 != null) + if (Header.CRC16 is not null) field += 2; return field; diff --git a/SabreTools.Serialization/Wrappers/ISO9660.Extraction.cs b/SabreTools.Serialization/Wrappers/ISO9660.Extraction.cs index 7a150ba9..98273e4c 100644 --- a/SabreTools.Serialization/Wrappers/ISO9660.Extraction.cs +++ b/SabreTools.Serialization/Wrappers/ISO9660.Extraction.cs @@ -161,7 +161,7 @@ namespace SabreTools.Serialization.Wrappers // Ensure the full output directory exists var filepath = Path.Combine(outputDirectory, filename); var directoryName = Path.GetDirectoryName(filepath); - if (directoryName != null && !Directory.Exists(directoryName)) + if (directoryName is not null && !Directory.Exists(directoryName)) Directory.CreateDirectory(directoryName); bool multiExtent = false; diff --git a/SabreTools.Serialization/Wrappers/ISO9660.Printing.cs b/SabreTools.Serialization/Wrappers/ISO9660.Printing.cs index 2c2b96ed..b84417ff 100644 --- a/SabreTools.Serialization/Wrappers/ISO9660.Printing.cs +++ b/SabreTools.Serialization/Wrappers/ISO9660.Printing.cs @@ -135,7 +135,7 @@ namespace SabreTools.Serialization.Wrappers builder.AppendLine(encoding.GetString(vd.VolumeIdentifier), " Volume Identifier"); - if (vd.Unused8Bytes != null && Array.TrueForAll(vd.Unused8Bytes, b => b == 0)) + if (vd.Unused8Bytes is not null && Array.TrueForAll(vd.Unused8Bytes, b => b == 0)) builder.AppendLine("Zeroed", " Unused 8 Bytes"); else builder.AppendLine(vd.Unused8Bytes, " Unused 8 Bytes"); @@ -144,7 +144,7 @@ namespace SabreTools.Serialization.Wrappers if (vd is PrimaryVolumeDescriptor pvd2) { - if (pvd2.Unused32Bytes != null && Array.TrueForAll(pvd2.Unused32Bytes, b => b == 0)) + if (pvd2.Unused32Bytes is not null && Array.TrueForAll(pvd2.Unused32Bytes, b => b == 0)) builder.AppendLine("Zeroed", " Unused 32 Bytes"); else builder.AppendLine(pvd2.Unused32Bytes, " Unused 32 Bytes"); @@ -268,7 +268,7 @@ namespace SabreTools.Serialization.Wrappers for (int tableNum = 0; tableNum < ptgs.Length; tableNum++) { - if (ptgs[tableNum].PathTableL != null) + if (ptgs[tableNum].PathTableL is not null) { builder.AppendLine($" Type-L Path Table {tableNum}:"); builder.AppendLine(" -------------------------"); @@ -279,7 +279,7 @@ namespace SabreTools.Serialization.Wrappers builder.AppendLine($" No Type-L Path Table {tableNum}:"); builder.AppendLine(); } - if (ptgs[tableNum].OptionalPathTableL != null) + if (ptgs[tableNum].OptionalPathTableL is not null) { builder.AppendLine($" Optional Type-L Path Table {tableNum}:"); builder.AppendLine(" -------------------------"); @@ -290,7 +290,7 @@ namespace SabreTools.Serialization.Wrappers builder.AppendLine($" No Optional Type-L Path Table {tableNum}:"); builder.AppendLine(); } - if (ptgs[tableNum].PathTableM != null) + if (ptgs[tableNum].PathTableM is not null) { builder.AppendLine($" Type-M Path Table {tableNum}:"); builder.AppendLine(" -------------------------"); @@ -301,7 +301,7 @@ namespace SabreTools.Serialization.Wrappers builder.AppendLine($" No Type-M Path Table {tableNum}:"); builder.AppendLine(); } - if (ptgs[tableNum].OptionalPathTableM != null) + if (ptgs[tableNum].OptionalPathTableM is not null) { builder.AppendLine($" Optional Type-M Path Table {tableNum}:"); builder.AppendLine(" -------------------------"); @@ -333,7 +333,7 @@ namespace SabreTools.Serialization.Wrappers builder.AppendLine(records[recordNum].ExtendedAttributeRecordLength, " Extended Attribute Record Length"); builder.AppendLine(records[recordNum].ExtentLocation, " Extent Location"); builder.AppendLine(records[recordNum].DirectoryIdentifier, " Directory Identifier"); - if (records[recordNum].PaddingField != null) + if (records[recordNum].PaddingField is not null) builder.AppendLine(records[recordNum].PaddingField, " Padding Field"); } diff --git a/SabreTools.Serialization/Wrappers/InstallShieldArchiveV3.Extraction.cs b/SabreTools.Serialization/Wrappers/InstallShieldArchiveV3.Extraction.cs index 2e04d847..5a5bde3d 100644 --- a/SabreTools.Serialization/Wrappers/InstallShieldArchiveV3.Extraction.cs +++ b/SabreTools.Serialization/Wrappers/InstallShieldArchiveV3.Extraction.cs @@ -102,7 +102,7 @@ namespace SabreTools.Serialization.Wrappers // Ensure the full output directory exists filename = Path.Combine(outputDirectory, filename); var directoryName = Path.GetDirectoryName(filename); - if (directoryName != null && !System.IO.Directory.Exists(directoryName)) + if (directoryName is not null && !System.IO.Directory.Exists(directoryName)) System.IO.Directory.CreateDirectory(directoryName); // Try to write the data diff --git a/SabreTools.Serialization/Wrappers/InstallShieldArchiveV3.cs b/SabreTools.Serialization/Wrappers/InstallShieldArchiveV3.cs index 4c315ff7..f1e786a3 100644 --- a/SabreTools.Serialization/Wrappers/InstallShieldArchiveV3.cs +++ b/SabreTools.Serialization/Wrappers/InstallShieldArchiveV3.cs @@ -39,7 +39,7 @@ namespace SabreTools.Serialization.Wrappers get { // Return the prebuilt map - if (field != null) + if (field is not null) return field; // Build the file map @@ -67,7 +67,7 @@ namespace SabreTools.Serialization.Wrappers get { // Return the prebuilt map - if (field != null) + if (field is not null) return field; // Build the file map diff --git a/SabreTools.Serialization/Wrappers/InstallShieldCabinet.Extraction.cs b/SabreTools.Serialization/Wrappers/InstallShieldCabinet.Extraction.cs index 18b6ab2d..17fcefc0 100644 --- a/SabreTools.Serialization/Wrappers/InstallShieldCabinet.Extraction.cs +++ b/SabreTools.Serialization/Wrappers/InstallShieldCabinet.Extraction.cs @@ -78,7 +78,7 @@ namespace SabreTools.Serialization.Wrappers for (ushort i = 1; iterate; i++) { var file = OpenFileForReading(pattern, i, HEADER_SUFFIX); - if (file != null) + if (file is not null) iterate = false; else file = OpenFileForReading(pattern, i, CABINET_SUFFIX); @@ -91,7 +91,7 @@ namespace SabreTools.Serialization.Wrappers break; current.VolumeID = i; - if (previous != null) + if (previous is not null) { previous.Next = current; current.Prev = previous; @@ -161,7 +161,7 @@ namespace SabreTools.Serialization.Wrappers return pattern; string? directory = Path.GetDirectoryName(Path.GetFullPath(filename)); - if (directory != null) + if (directory is not null) pattern = Path.Combine(directory, Path.GetFileNameWithoutExtension(filename)); else pattern = Path.GetFileNameWithoutExtension(filename); @@ -204,7 +204,7 @@ namespace SabreTools.Serialization.Wrappers { // Open the full set if possible var cabinet = this; - if (Filename != null) + if (Filename is not null) { // Get the name of the first cabinet file or header string pattern = CreateFilenamePattern(Filename)!; @@ -245,7 +245,7 @@ namespace SabreTools.Serialization.Wrappers // Ensure the full output directory exists filename = Path.Combine(outputDirectory, filename); var directoryName = Path.GetDirectoryName(filename); - if (directoryName != null && !Directory.Exists(directoryName)) + if (directoryName is not null && !Directory.Exists(directoryName)) Directory.CreateDirectory(directoryName); cabinet.FileSave(i, filename, includeDebug); diff --git a/SabreTools.Serialization/Wrappers/InstallShieldCabinet.cs b/SabreTools.Serialization/Wrappers/InstallShieldCabinet.cs index c35286f0..3657d15c 100644 --- a/SabreTools.Serialization/Wrappers/InstallShieldCabinet.cs +++ b/SabreTools.Serialization/Wrappers/InstallShieldCabinet.cs @@ -183,7 +183,7 @@ namespace SabreTools.Serialization.Wrappers public uint GetDirectoryIndexFromFile(int index) { FileDescriptor? descriptor = GetFileDescriptor(index); - if (descriptor != null) + if (descriptor is not null) return descriptor.DirectoryIndex; else return uint.MaxValue; @@ -223,7 +223,7 @@ namespace SabreTools.Serialization.Wrappers public ulong GetExpandedFileSize(int index) { FileDescriptor? descriptor = GetFileDescriptor(index); - if (descriptor != null) + if (descriptor is not null) return descriptor.ExpandedSize; else return 0; diff --git a/SabreTools.Serialization/Wrappers/InstallShieldExecutable.Extraction.cs b/SabreTools.Serialization/Wrappers/InstallShieldExecutable.Extraction.cs index 10982cfc..bd2625f9 100644 --- a/SabreTools.Serialization/Wrappers/InstallShieldExecutable.Extraction.cs +++ b/SabreTools.Serialization/Wrappers/InstallShieldExecutable.Extraction.cs @@ -34,7 +34,7 @@ namespace SabreTools.Serialization.Wrappers // Ensure the full output directory exists filename = Path.Combine(outputDirectory, filename); var directoryName = Path.GetDirectoryName(filename); - if (directoryName != null && !Directory.Exists(directoryName)) + if (directoryName is not null && !Directory.Exists(directoryName)) Directory.CreateDirectory(directoryName); // Write the output file diff --git a/SabreTools.Serialization/Wrappers/LZKWAJ.Extraction.cs b/SabreTools.Serialization/Wrappers/LZKWAJ.Extraction.cs index f452737b..ef118f6a 100644 --- a/SabreTools.Serialization/Wrappers/LZKWAJ.Extraction.cs +++ b/SabreTools.Serialization/Wrappers/LZKWAJ.Extraction.cs @@ -30,7 +30,7 @@ namespace SabreTools.Serialization.Wrappers // Create the full output path string filename = FileName ?? "tempfile"; - if (FileExtension != null) + if (FileExtension is not null) filename += $".{FileExtension}"; // Ensure directory separators are consistent @@ -42,7 +42,7 @@ namespace SabreTools.Serialization.Wrappers // Ensure the full output directory exists filename = Path.Combine(outputDirectory, filename); var directoryName = Path.GetDirectoryName(filename); - if (directoryName != null && !Directory.Exists(directoryName)) + if (directoryName is not null && !Directory.Exists(directoryName)) Directory.CreateDirectory(directoryName); // Try to write the data diff --git a/SabreTools.Serialization/Wrappers/LZQBasic.Extraction.cs b/SabreTools.Serialization/Wrappers/LZQBasic.Extraction.cs index f9e1c392..af76f1ea 100644 --- a/SabreTools.Serialization/Wrappers/LZQBasic.Extraction.cs +++ b/SabreTools.Serialization/Wrappers/LZQBasic.Extraction.cs @@ -38,7 +38,7 @@ namespace SabreTools.Serialization.Wrappers // Ensure the full output directory exists filename = Path.Combine(outputDirectory, filename); var directoryName = Path.GetDirectoryName(filename); - if (directoryName != null && !Directory.Exists(directoryName)) + if (directoryName is not null && !Directory.Exists(directoryName)) Directory.CreateDirectory(directoryName); // Try to write the data diff --git a/SabreTools.Serialization/Wrappers/LZSZDD.Extraction.cs b/SabreTools.Serialization/Wrappers/LZSZDD.Extraction.cs index 9205e6e5..2c3c737e 100644 --- a/SabreTools.Serialization/Wrappers/LZSZDD.Extraction.cs +++ b/SabreTools.Serialization/Wrappers/LZSZDD.Extraction.cs @@ -15,7 +15,7 @@ namespace SabreTools.Serialization.Wrappers public bool Extract(string filename, string outputDirectory, bool includeDebug) { // Ensure the filename - if (filename.Length == 0 && Filename != null) + if (filename.Length == 0 && Filename is not null) filename = Filename; // Get the length of the compressed data @@ -49,7 +49,7 @@ namespace SabreTools.Serialization.Wrappers // Ensure the full output directory exists filename = Path.Combine(outputDirectory, filename); var directoryName = Path.GetDirectoryName(filename); - if (directoryName != null && !Directory.Exists(directoryName)) + if (directoryName is not null && !Directory.Exists(directoryName)) Directory.CreateDirectory(directoryName); // Try to write the data diff --git a/SabreTools.Serialization/Wrappers/LinearExecutable.cs b/SabreTools.Serialization/Wrappers/LinearExecutable.cs index abe8de63..58c09c48 100644 --- a/SabreTools.Serialization/Wrappers/LinearExecutable.cs +++ b/SabreTools.Serialization/Wrappers/LinearExecutable.cs @@ -38,7 +38,7 @@ namespace SabreTools.Serialization.Wrappers lock (_stubExecutableDataLock) { // If we already have cached data, just use that immediately - if (field != null) + if (field is not null) return field; // Populate the raw stub executable data based on the source diff --git a/SabreTools.Serialization/Wrappers/MicrosoftCabinet.Extraction.cs b/SabreTools.Serialization/Wrappers/MicrosoftCabinet.Extraction.cs index 48d750c4..50cee365 100644 --- a/SabreTools.Serialization/Wrappers/MicrosoftCabinet.Extraction.cs +++ b/SabreTools.Serialization/Wrappers/MicrosoftCabinet.Extraction.cs @@ -51,7 +51,7 @@ namespace SabreTools.Serialization.Wrappers return null; // Seek to the first part of the cabinet set - while (current.CabinetPrev != null) + while (current.CabinetPrev is not null) { // Attempt to open the previous cabinet var prev = current.OpenPrevious(filename, includeDebug); @@ -66,7 +66,7 @@ namespace SabreTools.Serialization.Wrappers var start = current; // Read in the cabinet parts sequentially - while (current.CabinetNext != null) + while (current.CabinetNext is not null) { // If the current and next filenames match if (Path.GetFileName(filename) == current.CabinetNext) @@ -108,7 +108,7 @@ namespace SabreTools.Serialization.Wrappers // Get the full next path string? folder = Path.GetDirectoryName(filename); - if (folder != null) + if (folder is not null) next = Path.Combine(folder, next); // Open and return the next cabinet @@ -145,7 +145,7 @@ namespace SabreTools.Serialization.Wrappers // Get the full next path string? folder = Path.GetDirectoryName(filename); - if (folder != null) + if (folder is not null) prev = Path.Combine(folder, prev); // Open and return the previous cabinet @@ -172,7 +172,7 @@ namespace SabreTools.Serialization.Wrappers if (includeDebug) Console.WriteLine("WARNING: LZX and Quantum compression schemes are not supported so some files may be skipped!"); MicrosoftCabinet? cabinet; - if (Filename != null) + if (Filename is not null) { // Open the full set if possible cabinet = OpenSet(Filename, includeDebug); @@ -378,7 +378,7 @@ namespace SabreTools.Serialization.Wrappers // Ensure the full output directory exists filename = Path.Combine(outputDirectory, filename); var directoryName = Path.GetDirectoryName(filename); - if (directoryName != null && !Directory.Exists(directoryName)) + if (directoryName is not null && !Directory.Exists(directoryName)) Directory.CreateDirectory(directoryName); // Open the output file for writing diff --git a/SabreTools.Serialization/Wrappers/MicrosoftCabinet.cs b/SabreTools.Serialization/Wrappers/MicrosoftCabinet.cs index fcad17db..5aa4967b 100644 --- a/SabreTools.Serialization/Wrappers/MicrosoftCabinet.cs +++ b/SabreTools.Serialization/Wrappers/MicrosoftCabinet.cs @@ -278,7 +278,7 @@ namespace SabreTools.Serialization.Wrappers Prev = OpenPrevious(filename, includeDebug); // Get all files from Prev - if (Prev?.Header != null && Prev.Folders != null) + if (Prev?.Header is not null && Prev.Folders is not null) { int prevFolderIndex = Prev.FolderCount - 1; prevFiles = Prev.GetSpannedFiles(filename, prevFolderIndex, includeDebug, skipNext: true) ?? []; @@ -294,7 +294,7 @@ namespace SabreTools.Serialization.Wrappers Next = OpenNext(filename); // Get all files from Prev - if (Next?.Header != null && Next.Folders != null) + if (Next?.Header is not null && Next.Folders is not null) { var nextFolder = Next.Folders[0]; nextFiles = Next.GetSpannedFiles(filename, 0, includeDebug, skipPrev: true) ?? []; diff --git a/SabreTools.Serialization/Wrappers/MoPaQ.Extraction.cs b/SabreTools.Serialization/Wrappers/MoPaQ.Extraction.cs index e4d0a236..c36cd77a 100644 --- a/SabreTools.Serialization/Wrappers/MoPaQ.Extraction.cs +++ b/SabreTools.Serialization/Wrappers/MoPaQ.Extraction.cs @@ -52,7 +52,7 @@ namespace SabreTools.Serialization.Wrappers // Ensure the full output directory exists filename = Path.Combine(outputDirectory, filename); var directoryName = Path.GetDirectoryName(filename); - if (directoryName != null && !Directory.Exists(directoryName)) + if (directoryName is not null && !Directory.Exists(directoryName)) Directory.CreateDirectory(directoryName); // Try to write the data diff --git a/SabreTools.Serialization/Wrappers/NewExecutable.Extraction.cs b/SabreTools.Serialization/Wrappers/NewExecutable.Extraction.cs index 70c9a71f..b41f6c2d 100644 --- a/SabreTools.Serialization/Wrappers/NewExecutable.Extraction.cs +++ b/SabreTools.Serialization/Wrappers/NewExecutable.Extraction.cs @@ -150,12 +150,12 @@ namespace SabreTools.Serialization.Wrappers // Create the temp filename string tempFile = $"embedded_overlay.{extension}"; - if (Filename != null) + if (Filename is not null) tempFile = $"{Path.GetFileName(Filename)}-{tempFile}"; tempFile = Path.Combine(outputDirectory, tempFile); var directoryName = Path.GetDirectoryName(tempFile); - if (directoryName != null && !Directory.Exists(directoryName)) + if (directoryName is not null && !Directory.Exists(directoryName)) Directory.CreateDirectory(directoryName); // Write the resource data to a temp file @@ -208,10 +208,10 @@ namespace SabreTools.Serialization.Wrappers { // Get the source data for reading Stream source = _dataSource; - if (Filename != null) + if (Filename is not null) { // Try to open a multipart file - if (WiseOverlayHeader.OpenFile(Filename, includeDebug, out var temp) && temp != null) + if (WiseOverlayHeader.OpenFile(Filename, includeDebug, out var temp) && temp is not null) source = temp; } @@ -262,7 +262,7 @@ namespace SabreTools.Serialization.Wrappers // Get the source directory string? sourceDirectory = null; - if (Filename != null) + if (Filename is not null) sourceDirectory = Path.GetDirectoryName(Path.GetFullPath(Filename)); // Process the state machine diff --git a/SabreTools.Serialization/Wrappers/NewExecutable.cs b/SabreTools.Serialization/Wrappers/NewExecutable.cs index b7fc97ed..a1558024 100644 --- a/SabreTools.Serialization/Wrappers/NewExecutable.cs +++ b/SabreTools.Serialization/Wrappers/NewExecutable.cs @@ -117,7 +117,7 @@ namespace SabreTools.Serialization.Wrappers lock (_overlayDataLock) { // Use the cached data if possible - if (field != null) + if (field is not null) return field; // Get the available source length, if possible @@ -211,7 +211,7 @@ namespace SabreTools.Serialization.Wrappers lock (_overlayStringsLock) { // Use the cached data if possible - if (field != null) + if (field is not null) return field; // Get the available source length, if possible @@ -259,7 +259,7 @@ namespace SabreTools.Serialization.Wrappers lock (_stubExecutableDataLock) { // If we already have cached data, just use that immediately - if (field != null) + if (field is not null) return field; // Populate the raw stub executable data based on the source @@ -398,7 +398,7 @@ namespace SabreTools.Serialization.Wrappers // Attempt to get the overlay header _dataSource.SeekIfPossible(overlayOffset, SeekOrigin.Begin); var header = WiseOverlayHeader.Create(_dataSource); - if (header != null) + if (header is not null) return overlayOffset; // Align and loop to see if it can be found @@ -409,7 +409,7 @@ namespace SabreTools.Serialization.Wrappers { _dataSource.SeekIfPossible(overlayOffset, SeekOrigin.Begin); header = WiseOverlayHeader.Create(_dataSource); - if (header != null) + if (header is not null) return overlayOffset; overlayOffset += 0x10; diff --git a/SabreTools.Serialization/Wrappers/Nitro.Encryption.cs b/SabreTools.Serialization/Wrappers/Nitro.Encryption.cs index bec0458c..dbc9681d 100644 --- a/SabreTools.Serialization/Wrappers/Nitro.Encryption.cs +++ b/SabreTools.Serialization/Wrappers/Nitro.Encryption.cs @@ -31,7 +31,7 @@ namespace SabreTools.Serialization.Wrappers else { bool? isDecrypted = CheckIfDecrypted(out string? message); - if (message != null) + if (message is not null) Console.WriteLine(message); if (isDecrypted is null) @@ -149,7 +149,7 @@ namespace SabreTools.Serialization.Wrappers else { bool? isDecrypted = CheckIfDecrypted(out string? message); - if (message != null) + if (message is not null) Console.WriteLine(message); if (isDecrypted is null) diff --git a/SabreTools.Serialization/Wrappers/PAK.Extraction.cs b/SabreTools.Serialization/Wrappers/PAK.Extraction.cs index de744eed..62799044 100644 --- a/SabreTools.Serialization/Wrappers/PAK.Extraction.cs +++ b/SabreTools.Serialization/Wrappers/PAK.Extraction.cs @@ -59,7 +59,7 @@ namespace SabreTools.Serialization.Wrappers // Ensure the full output directory exists filename = Path.Combine(outputDirectory, filename); var directoryName = Path.GetDirectoryName(filename); - if (directoryName != null && !Directory.Exists(directoryName)) + if (directoryName is not null && !Directory.Exists(directoryName)) Directory.CreateDirectory(directoryName); // Try to write the data diff --git a/SabreTools.Serialization/Wrappers/PFF.Extraction.cs b/SabreTools.Serialization/Wrappers/PFF.Extraction.cs index cca581d4..d6c8241a 100644 --- a/SabreTools.Serialization/Wrappers/PFF.Extraction.cs +++ b/SabreTools.Serialization/Wrappers/PFF.Extraction.cs @@ -60,7 +60,7 @@ namespace SabreTools.Serialization.Wrappers // Ensure the full output directory exists filename = Path.Combine(outputDirectory, filename); var directoryName = Path.GetDirectoryName(filename); - if (directoryName != null && !Directory.Exists(directoryName)) + if (directoryName is not null && !Directory.Exists(directoryName)) Directory.CreateDirectory(directoryName); // Create the output file diff --git a/SabreTools.Serialization/Wrappers/PKZIP.Extraction.cs b/SabreTools.Serialization/Wrappers/PKZIP.Extraction.cs index 281486f6..d2af25f0 100644 --- a/SabreTools.Serialization/Wrappers/PKZIP.Extraction.cs +++ b/SabreTools.Serialization/Wrappers/PKZIP.Extraction.cs @@ -77,7 +77,7 @@ namespace SabreTools.Serialization.Wrappers // Ensure the full output directory exists filename = Path.Combine(outputDirectory, filename); var directoryName = Path.GetDirectoryName(filename); - if (directoryName != null && !Directory.Exists(directoryName)) + if (directoryName is not null && !Directory.Exists(directoryName)) Directory.CreateDirectory(directoryName); entry.WriteToFile(filename); @@ -156,7 +156,7 @@ namespace SabreTools.Serialization.Wrappers for (int i = 1; ; i++) { string nextPart = nextPartFunc(i); - if (directory != null) + if (directory is not null) nextPart = Path.Combine(directory, nextPart); if (!File.Exists(nextPart)) diff --git a/SabreTools.Serialization/Wrappers/PortableExecutable.Extraction.cs b/SabreTools.Serialization/Wrappers/PortableExecutable.Extraction.cs index 38872369..d503478a 100644 --- a/SabreTools.Serialization/Wrappers/PortableExecutable.Extraction.cs +++ b/SabreTools.Serialization/Wrappers/PortableExecutable.Extraction.cs @@ -89,7 +89,7 @@ namespace SabreTools.Serialization.Wrappers // Ensure the full output directory exists filename = Path.Combine(outputDirectory, filename); var directoryName = Path.GetDirectoryName(filename); - if (directoryName != null && !Directory.Exists(directoryName)) + if (directoryName is not null && !Directory.Exists(directoryName)) Directory.CreateDirectory(directoryName); // Write the output file @@ -144,7 +144,7 @@ namespace SabreTools.Serialization.Wrappers string tempFile = string.IsNullOrEmpty(Filename) ? "temp.sxe" : $"{Path.GetFileNameWithoutExtension(Filename)}.sxe"; tempFile = Path.Combine(outputDirectory, tempFile); var directoryName = Path.GetDirectoryName(tempFile); - if (directoryName != null && !Directory.Exists(directoryName)) + if (directoryName is not null && !Directory.Exists(directoryName)) Directory.CreateDirectory(directoryName); // Write the file data to a temp file @@ -291,12 +291,12 @@ namespace SabreTools.Serialization.Wrappers // Create the temp filename string tempFile = $"embedded_overlay.{extension}"; - if (Filename != null) + if (Filename is not null) tempFile = $"{Path.GetFileName(Filename)}-{tempFile}"; tempFile = Path.Combine(outputDirectory, tempFile); var directoryName = Path.GetDirectoryName(tempFile); - if (directoryName != null && !Directory.Exists(directoryName)) + if (directoryName is not null && !Directory.Exists(directoryName)) Directory.CreateDirectory(directoryName); // Write the resource data to a temp file @@ -496,12 +496,12 @@ namespace SabreTools.Serialization.Wrappers { // Create the temp filename string tempFile = $"embedded_resource_{i++} ({resourceKey}).{extension}"; - if (Filename != null) + if (Filename is not null) tempFile = $"{Path.GetFileName(Filename)}-{tempFile}"; tempFile = Path.Combine(outputDirectory, tempFile); var directoryName = Path.GetDirectoryName(tempFile); - if (directoryName != null && !Directory.Exists(directoryName)) + if (directoryName is not null && !Directory.Exists(directoryName)) Directory.CreateDirectory(directoryName); // Write the resource data to a temp file @@ -607,7 +607,7 @@ namespace SabreTools.Serialization.Wrappers // Ensure the full output directory exists filename = Path.Combine(outputDirectory, filename); var directoryName = Path.GetDirectoryName(filename); - if (directoryName != null && !Directory.Exists(directoryName)) + if (directoryName is not null && !Directory.Exists(directoryName)) Directory.CreateDirectory(directoryName); // Write the output file @@ -635,10 +635,10 @@ namespace SabreTools.Serialization.Wrappers { // Get the source data for reading Stream source = _dataSource; - if (Filename != null) + if (Filename is not null) { // Try to open a multipart file - if (WiseOverlayHeader.OpenFile(Filename, includeDebug, out var temp) && temp != null) + if (WiseOverlayHeader.OpenFile(Filename, includeDebug, out var temp) && temp is not null) source = temp; } @@ -675,7 +675,7 @@ namespace SabreTools.Serialization.Wrappers // Get the source directory string? sourceDirectory = null; - if (Filename != null) + if (Filename is not null) sourceDirectory = Path.GetDirectoryName(Path.GetFullPath(Filename)); // Process the state machine diff --git a/SabreTools.Serialization/Wrappers/PortableExecutable.Printing.cs b/SabreTools.Serialization/Wrappers/PortableExecutable.Printing.cs index 49fdb9f2..3bbadbac 100644 --- a/SabreTools.Serialization/Wrappers/PortableExecutable.Printing.cs +++ b/SabreTools.Serialization/Wrappers/PortableExecutable.Printing.cs @@ -143,49 +143,49 @@ namespace SabreTools.Serialization.Wrappers builder.AppendLine(header.LoaderFlags, " Loader flags"); builder.AppendLine(header.NumberOfRvaAndSizes, " Number of data-directory entries"); - if (header.ExportTable != null) + if (header.ExportTable is not null) { builder.AppendLine(" Export Table (1)"); builder.AppendLine(header.ExportTable.VirtualAddress, " Virtual address"); builder.AppendLine(header.ExportTable.VirtualAddress.ConvertVirtualAddress(table), " Physical address"); builder.AppendLine(header.ExportTable.Size, " Size"); } - if (header.ImportTable != null) + if (header.ImportTable is not null) { builder.AppendLine(" Import Table (2)"); builder.AppendLine(header.ImportTable.VirtualAddress, " Virtual address"); builder.AppendLine(header.ImportTable.VirtualAddress.ConvertVirtualAddress(table), " Physical address"); builder.AppendLine(header.ImportTable.Size, " Size"); } - if (header.ResourceTable != null) + if (header.ResourceTable is not null) { builder.AppendLine(" Resource Table (3)"); builder.AppendLine(header.ResourceTable.VirtualAddress, " Virtual address"); builder.AppendLine(header.ResourceTable.VirtualAddress.ConvertVirtualAddress(table), " Physical address"); builder.AppendLine(header.ResourceTable.Size, " Size"); } - if (header.ExceptionTable != null) + if (header.ExceptionTable is not null) { builder.AppendLine(" Exception Table (4)"); builder.AppendLine(header.ExceptionTable.VirtualAddress, " Virtual address"); builder.AppendLine(header.ExceptionTable.VirtualAddress.ConvertVirtualAddress(table), " Physical address"); builder.AppendLine(header.ExceptionTable.Size, " Size"); } - if (header.CertificateTable != null) + if (header.CertificateTable is not null) { builder.AppendLine(" Certificate Table (5)"); builder.AppendLine(" Virtual address: N/A"); builder.AppendLine(header.CertificateTable.VirtualAddress, " Physical address"); builder.AppendLine(header.CertificateTable.Size, " Size"); } - if (header.BaseRelocationTable != null) + if (header.BaseRelocationTable is not null) { builder.AppendLine(" Base Relocation Table (6)"); builder.AppendLine(header.BaseRelocationTable.VirtualAddress, " Virtual address"); builder.AppendLine(header.BaseRelocationTable.VirtualAddress.ConvertVirtualAddress(table), " Physical address"); builder.AppendLine(header.BaseRelocationTable.Size, " Size"); } - if (header.Debug != null) + if (header.Debug is not null) { builder.AppendLine(" Debug Table (7)"); builder.AppendLine(header.Debug.VirtualAddress, " Virtual address"); @@ -199,49 +199,49 @@ namespace SabreTools.Serialization.Wrappers builder.AppendLine(" Physical address: 0 (0x00000000)"); builder.AppendLine(" Size: 0 (0x00000000)"); } - if (header.GlobalPtr != null) + if (header.GlobalPtr is not null) { builder.AppendLine(" Global Pointer Register (9)"); builder.AppendLine(header.GlobalPtr.VirtualAddress, " Virtual address"); builder.AppendLine(header.GlobalPtr.VirtualAddress.ConvertVirtualAddress(table), " Physical address"); builder.AppendLine(header.GlobalPtr.Size, " Size"); } - if (header.ThreadLocalStorageTable != null) + if (header.ThreadLocalStorageTable is not null) { builder.AppendLine(" Thread Local Storage (TLS) Table (10)"); builder.AppendLine(header.ThreadLocalStorageTable.VirtualAddress, " Virtual address"); builder.AppendLine(header.ThreadLocalStorageTable.VirtualAddress.ConvertVirtualAddress(table), " Physical address"); builder.AppendLine(header.ThreadLocalStorageTable.Size, " Size"); } - if (header.LoadConfigTable != null) + if (header.LoadConfigTable is not null) { builder.AppendLine(" Load Config Table (11)"); builder.AppendLine(header.LoadConfigTable.VirtualAddress, " Virtual address"); builder.AppendLine(header.LoadConfigTable.VirtualAddress.ConvertVirtualAddress(table), " Physical address"); builder.AppendLine(header.LoadConfigTable.Size, " Size"); } - if (header.BoundImport != null) + if (header.BoundImport is not null) { builder.AppendLine(" Bound Import Table (12)"); builder.AppendLine(header.BoundImport.VirtualAddress, " Virtual address"); builder.AppendLine(header.BoundImport.VirtualAddress.ConvertVirtualAddress(table), " Physical address"); builder.AppendLine(header.BoundImport.Size, " Size"); } - if (header.ImportAddressTable != null) + if (header.ImportAddressTable is not null) { builder.AppendLine(" Import Address Table (13)"); builder.AppendLine(header.ImportAddressTable.VirtualAddress, " Virtual address"); builder.AppendLine(header.ImportAddressTable.VirtualAddress.ConvertVirtualAddress(table), " Physical address"); builder.AppendLine(header.ImportAddressTable.Size, " Size"); } - if (header.DelayImportDescriptor != null) + if (header.DelayImportDescriptor is not null) { builder.AppendLine(" Delay Import Descriptor (14)"); builder.AppendLine(header.DelayImportDescriptor.VirtualAddress, " Virtual address"); builder.AppendLine(header.DelayImportDescriptor.VirtualAddress.ConvertVirtualAddress(table), " Physical address"); builder.AppendLine(header.DelayImportDescriptor.Size, " Size"); } - if (header.CLRRuntimeHeader != null) + if (header.CLRRuntimeHeader is not null) { builder.AppendLine(" CLR Runtime Header (15)"); builder.AppendLine(header.CLRRuntimeHeader.VirtualAddress, " Virtual address"); @@ -326,7 +326,7 @@ namespace SabreTools.Serialization.Wrappers private static void Print(StringBuilder builder, StandardRecord entry, int i) { builder.AppendLine($" Symbol Table Entry {i} (Standard Record)"); - if (entry.ShortName != null) + if (entry.ShortName is not null) { builder.AppendLine(entry.ShortName, " Short name", Encoding.ASCII); } @@ -891,7 +891,7 @@ namespace SabreTools.Serialization.Wrappers var entry = table.Entries[i]; var newTypes = new List(types ?? []); - if (entry.Name?.UnicodeString != null) + if (entry.Name?.UnicodeString is not null) newTypes.Add(Encoding.Unicode.GetString(entry.Name.UnicodeString)); else newTypes.Add(entry.IntegerID); @@ -916,9 +916,9 @@ namespace SabreTools.Serialization.Wrappers builder.AppendLine(entry.IntegerID, $"{padding}Integer ID"); } - if (entry.DataEntry != null) + if (entry.DataEntry is not null) Print(builder, entry.DataEntry, level: level + 1, types, sections); - else if (entry.Subdirectory != null) + else if (entry.Subdirectory is not null) Print(builder, entry.Subdirectory, level: level + 1, types, sections); } @@ -938,7 +938,7 @@ namespace SabreTools.Serialization.Wrappers builder.AppendLine(entry.Reserved, $"{padding}Reserved"); // TODO: Print out per-type data - if (types != null && types.Count > 0 && types[0] is uint resourceType) + if (types is not null && types.Count > 0 && types[0] is uint resourceType) { switch ((ResourceType)resourceType) { @@ -1010,7 +1010,7 @@ namespace SabreTools.Serialization.Wrappers break; } } - else if (types != null && types.Count > 0 && types[0] is string resourceString) + else if (types is not null && types.Count > 0 && types[0] is string resourceString) { PrintResourceUNKNOWN(entry, level, types[0], builder); } @@ -1123,7 +1123,7 @@ namespace SabreTools.Serialization.Wrappers return; } - if (dialogBox.DialogTemplate != null) + if (dialogBox.DialogTemplate is not null) { builder.AppendLine($"{padding}Style: {dialogBox.DialogTemplate.Style} (0x{dialogBox.DialogTemplate.Style:X})"); builder.AppendLine($"{padding}Extended style: {dialogBox.DialogTemplate.ExtendedStyle} (0x{dialogBox.DialogTemplate.ExtendedStyle:X})"); @@ -1172,13 +1172,13 @@ namespace SabreTools.Serialization.Wrappers builder.AppendLine(dialogItemTemplate.TitleResource, $"{padding} Title resource"); builder.AppendLine(dialogItemTemplate.TitleResourceOrdinal, $"{padding} Title resource ordinal"); builder.AppendLine(dialogItemTemplate.CreationDataSize, $"{padding} Creation data size"); - if (dialogItemTemplate.CreationData != null && dialogItemTemplate.CreationData.Length != 0) + if (dialogItemTemplate.CreationData is not null && dialogItemTemplate.CreationData.Length != 0) builder.AppendLine(dialogItemTemplate.CreationData, $"{padding} Creation data"); else builder.AppendLine($"{padding} Creation data: [EMPTY]"); } } - else if (dialogBox.ExtendedDialogTemplate != null) + else if (dialogBox.ExtendedDialogTemplate is not null) { builder.AppendLine(dialogBox.ExtendedDialogTemplate.Version, $"{padding}Version"); builder.AppendLine(dialogBox.ExtendedDialogTemplate.Signature, $"{padding}Signature"); @@ -1234,7 +1234,7 @@ namespace SabreTools.Serialization.Wrappers builder.AppendLine(dialogItemTemplate.TitleResource, $"{padding} Title resource"); builder.AppendLine(dialogItemTemplate.TitleResourceOrdinal, $"{padding} Title resource ordinal"); builder.AppendLine(dialogItemTemplate.CreationDataSize, $"{padding} Creation data size"); - if (dialogItemTemplate.CreationData != null && dialogItemTemplate.CreationData.Length != 0) + if (dialogItemTemplate.CreationData is not null && dialogItemTemplate.CreationData.Length != 0) builder.AppendLine(dialogItemTemplate.CreationData, $"{padding} Creation data"); else builder.AppendLine($"{padding} Creation data: [EMPTY]"); @@ -1348,13 +1348,13 @@ namespace SabreTools.Serialization.Wrappers { builder.AppendLine(magic, $"{padding}Data"); - //if (entry.Data != null) + //if (entry.Data is not null) // builder.AppendLine(entry.Data, $"{padding}Value (Byte Data)"); - //if (entry.Data != null) + //if (entry.Data is not null) // builder.AppendLine(Encoding.ASCII.GetString(entry.Data), $"{padding}Value (ASCII)"); - //if (entry.Data != null) + //if (entry.Data is not null) // builder.AppendLine(Encoding.UTF8.GetString(entry.Data), $"{padding}Value (UTF-8)"); - //if (entry.Data != null) + //if (entry.Data is not null) // builder.AppendLine(Encoding.Unicode.GetString(entry.Data), $"{padding}Value (Unicode)"); } } @@ -1453,7 +1453,7 @@ namespace SabreTools.Serialization.Wrappers builder.AppendLine(versionInfo.ValueLength, $"{padding}Value length"); builder.AppendLine($"{padding}Resource type: {versionInfo.ResourceType} (0x{versionInfo.ResourceType:X})"); builder.AppendLine(versionInfo.Key, $"{padding}Key"); - if (versionInfo.ValueLength != 0 && versionInfo.Value != null) + if (versionInfo.ValueLength != 0 && versionInfo.Value is not null) { builder.AppendLine(versionInfo.Value.Signature, $"{padding}[Fixed File Info] Signature"); builder.AppendLine(versionInfo.Value.StrucVersion, $"{padding}[Fixed File Info] Struct version"); @@ -1470,7 +1470,7 @@ namespace SabreTools.Serialization.Wrappers builder.AppendLine(versionInfo.Value.FileDateLS, $"{padding}[Fixed File Info] File date (LS)"); } - if (versionInfo.StringFileInfo != null) + if (versionInfo.StringFileInfo is not null) { builder.AppendLine(versionInfo.StringFileInfo.Length, $"{padding}[String File Info] Length"); builder.AppendLine(versionInfo.StringFileInfo.ValueLength, $"{padding}[String File Info] Value length"); @@ -1525,7 +1525,7 @@ namespace SabreTools.Serialization.Wrappers } } - if (versionInfo.VarFileInfo != null) + if (versionInfo.VarFileInfo is not null) { builder.AppendLine(versionInfo.VarFileInfo.Length, $"{padding}[Var File Info] Length"); builder.AppendLine(versionInfo.VarFileInfo.ValueLength, $"{padding}[Var File Info] Value length"); @@ -1593,11 +1593,11 @@ namespace SabreTools.Serialization.Wrappers string padding = new(' ', (level + 1) * 2); builder.AppendLine($"{padding}HTML resource found, not parsed yet"); - //if (entry.Data != null) + //if (entry.Data is not null) // builder.AppendLine(Encoding.ASCII.GetString(entry.Data), $"{padding}Value (ASCII)"); - //if (entry.Data != null) + //if (entry.Data is not null) // builder.AppendLine(Encoding.UTF8.GetString(entry.Data), $"{padding}Value (UTF-8)"); - //if (entry.Data != null) + //if (entry.Data is not null) // builder.AppendLine(Encoding.Unicode.GetString(entry.Data), $"{padding}Value (Unicode)"); } @@ -1614,7 +1614,7 @@ namespace SabreTools.Serialization.Wrappers } builder.AppendLine(assemblyManifest.ManifestVersion, $"{padding}Manifest version"); - if (assemblyManifest.AssemblyIdentities != null && assemblyManifest.AssemblyIdentities.Length > 0) + if (assemblyManifest.AssemblyIdentities is not null && assemblyManifest.AssemblyIdentities.Length > 0) { for (int i = 0; i < assemblyManifest.AssemblyIdentities.Length; i++) { @@ -1629,10 +1629,10 @@ namespace SabreTools.Serialization.Wrappers } } - if (assemblyManifest.Description != null) + if (assemblyManifest.Description is not null) builder.AppendLine(assemblyManifest.Description.Value, $"{padding}[Assembly Description] Value"); - if (assemblyManifest.COMInterfaceExternalProxyStub != null && assemblyManifest.COMInterfaceExternalProxyStub.Length > 0) + if (assemblyManifest.COMInterfaceExternalProxyStub is not null && assemblyManifest.COMInterfaceExternalProxyStub.Length > 0) { for (int i = 0; i < assemblyManifest.COMInterfaceExternalProxyStub.Length; i++) { @@ -1647,14 +1647,14 @@ namespace SabreTools.Serialization.Wrappers } } - if (assemblyManifest.Dependency != null && assemblyManifest.Dependency.Length > 0) + if (assemblyManifest.Dependency is not null && assemblyManifest.Dependency.Length > 0) { for (int i = 0; i < assemblyManifest.Dependency.Length; i++) { var dependency = assemblyManifest.Dependency[i]; - if (dependency?.DependentAssembly != null) + if (dependency?.DependentAssembly is not null) { - if (dependency.DependentAssembly.AssemblyIdentity != null) + if (dependency.DependentAssembly.AssemblyIdentity is not null) { builder.AppendLine(dependency.DependentAssembly.AssemblyIdentity.Name, $"{padding}[Dependency {i} Assembly Identity] Name"); builder.AppendLine(dependency.DependentAssembly.AssemblyIdentity.Version, $"{padding}[Dependency {i} Assembly Identity] Version"); @@ -1663,7 +1663,7 @@ namespace SabreTools.Serialization.Wrappers builder.AppendLine(dependency.DependentAssembly.AssemblyIdentity.PublicKeyToken, $"{padding}[Dependency {i} Assembly Identity] Public key token"); builder.AppendLine(dependency.DependentAssembly.AssemblyIdentity.Language, $"{padding}[Dependency {i} Assembly Identity] Language"); } - if (dependency.DependentAssembly.BindingRedirect != null && dependency.DependentAssembly.BindingRedirect.Length > 0) + if (dependency.DependentAssembly.BindingRedirect is not null && dependency.DependentAssembly.BindingRedirect.Length > 0) { for (int j = 0; j < dependency.DependentAssembly.BindingRedirect.Length; j++) { @@ -1675,12 +1675,12 @@ namespace SabreTools.Serialization.Wrappers } } - if (dependency != null) + if (dependency is not null) builder.AppendLine(dependency.Optional, $"{padding}[Dependency {i}] Optional"); } } - if (assemblyManifest.File != null && assemblyManifest.File.Length > 0) + if (assemblyManifest.File is not null && assemblyManifest.File.Length > 0) { for (int i = 0; i < assemblyManifest.File.Length; i++) { @@ -1696,7 +1696,7 @@ namespace SabreTools.Serialization.Wrappers builder.AppendLine(file.HashAlgorithm, $"{padding}[File {i}] Hash algorithm"); builder.AppendLine(file.Size, $"{padding}[File {i}] Size"); - if (file.COMClass != null && file.COMClass.Length > 0) + if (file.COMClass is not null && file.COMClass.Length > 0) { for (int j = 0; j < file.COMClass.Length; j++) { @@ -1708,7 +1708,7 @@ namespace SabreTools.Serialization.Wrappers builder.AppendLine(comClass.TLBID, $"{padding}[File {i} COM Class {j}] TLBID"); builder.AppendLine(comClass.Description, $"{padding}[File {i} COM Class {j}] Description"); - if (comClass.ProgIDs != null && comClass.ProgIDs.Length > 0) + if (comClass.ProgIDs is not null && comClass.ProgIDs.Length > 0) { for (int k = 0; k < comClass.ProgIDs.Length; k++) { @@ -1719,7 +1719,7 @@ namespace SabreTools.Serialization.Wrappers } } - if (file.COMInterfaceProxyStub != null && file.COMInterfaceProxyStub.Length > 0) + if (file.COMInterfaceProxyStub is not null && file.COMInterfaceProxyStub.Length > 0) { for (int j = 0; j < file.COMInterfaceProxyStub.Length; j++) { @@ -1734,7 +1734,7 @@ namespace SabreTools.Serialization.Wrappers } } - if (file.Typelib != null && file.Typelib.Length > 0) + if (file.Typelib is not null && file.Typelib.Length > 0) { for (int j = 0; j < file.Typelib.Length; j++) { @@ -1748,7 +1748,7 @@ namespace SabreTools.Serialization.Wrappers } } - if (file.WindowClass != null && file.WindowClass.Length > 0) + if (file.WindowClass is not null && file.WindowClass.Length > 0) { for (int j = 0; j < file.WindowClass.Length; j++) { @@ -1761,7 +1761,7 @@ namespace SabreTools.Serialization.Wrappers } } - if (assemblyManifest.EverythingElse != null && assemblyManifest.EverythingElse.Length > 0) + if (assemblyManifest.EverythingElse is not null && assemblyManifest.EverythingElse.Length > 0) { for (int i = 0; i < assemblyManifest.EverythingElse.Length; i++) { @@ -1832,13 +1832,13 @@ namespace SabreTools.Serialization.Wrappers { builder.AppendLine(magic, $"{padding}Data"); - //if (entry.Data != null) + //if (entry.Data is not null) // builder.AppendLine(entry.Data, $"{padding}Value (Byte Data)"); - //if (entry.Data != null) + //if (entry.Data is not null) // builder.AppendLine(Encoding.ASCII.GetString(entry.Data), $"{padding}Value (ASCII)"); - //if (entry.Data != null) + //if (entry.Data is not null) // builder.AppendLine(Encoding.UTF8.GetString(entry.Data), $"{padding}Value (UTF-8)"); - //if (entry.Data != null) + //if (entry.Data is not null) // builder.AppendLine(Encoding.Unicode.GetString(entry.Data), $"{padding}Value (Unicode)"); } } diff --git a/SabreTools.Serialization/Wrappers/PortableExecutable.cs b/SabreTools.Serialization/Wrappers/PortableExecutable.cs index 6a289d98..2b012f65 100644 --- a/SabreTools.Serialization/Wrappers/PortableExecutable.cs +++ b/SabreTools.Serialization/Wrappers/PortableExecutable.cs @@ -63,7 +63,7 @@ namespace SabreTools.Serialization.Wrappers lock (_entryPointDataLock) { // If we already have cached data, just use that immediately - if (field != null) + if (field is not null) return field; // If we have no entry point @@ -114,7 +114,7 @@ namespace SabreTools.Serialization.Wrappers lock (_headerPaddingDataLock) { // If we already have cached data, just use that immediately - if (field != null) + if (field is not null) return field; // TODO: Don't scan the known header data as well @@ -157,7 +157,7 @@ namespace SabreTools.Serialization.Wrappers lock (_headerPaddingStringsLock) { // If we already have cached data, just use that immediately - if (field != null) + if (field is not null) return field; // Get the header padding data, if possible @@ -197,7 +197,7 @@ namespace SabreTools.Serialization.Wrappers lock (_matroschkaPackageLock) { // Use the cached data if possible - if (field != null) + if (field is not null) return field; // Check to see if creation has already been attempted @@ -268,7 +268,7 @@ namespace SabreTools.Serialization.Wrappers lock (_installshieldExecutableLock) { // Use the cached data if possible - if (field != null) + if (field is not null) return field; // Check to see if creation has already been attempted @@ -334,7 +334,7 @@ namespace SabreTools.Serialization.Wrappers } // If we have certificate data, use that as the end - if (OptionalHeader.CertificateTable != null) + if (OptionalHeader.CertificateTable is not null) { long certificateTableAddress = OptionalHeader.CertificateTable.VirtualAddress; if (certificateTableAddress != 0 && certificateTableAddress < dataLength) @@ -372,7 +372,7 @@ namespace SabreTools.Serialization.Wrappers lock (_overlayDataLock) { // Use the cached data if possible - if (field != null) + if (field is not null) return field; // Get the available source length, if possible @@ -384,7 +384,7 @@ namespace SabreTools.Serialization.Wrappers } // If we have certificate data, use that as the end - if (OptionalHeader.CertificateTable != null) + if (OptionalHeader.CertificateTable is not null) { long certificateTableAddress = OptionalHeader.CertificateTable.VirtualAddress; if (certificateTableAddress != 0 && certificateTableAddress < dataLength) @@ -441,7 +441,7 @@ namespace SabreTools.Serialization.Wrappers } // If we have certificate data, use that as the end - if (OptionalHeader.CertificateTable != null) + if (OptionalHeader.CertificateTable is not null) { long certificateTableAddress = OptionalHeader.CertificateTable.VirtualAddress; if (certificateTableAddress != 0 && certificateTableAddress < dataLength) @@ -482,7 +482,7 @@ namespace SabreTools.Serialization.Wrappers lock (_overlayStringsLock) { // Use the cached data if possible - if (field != null) + if (field is not null) return field; // Get the overlay data, if possible @@ -513,7 +513,7 @@ namespace SabreTools.Serialization.Wrappers lock (_sectionNamesLock) { // Use the cached data if possible - if (field != null) + if (field is not null) return field; // Otherwise, build and return the cached array @@ -544,7 +544,7 @@ namespace SabreTools.Serialization.Wrappers lock (_sectionTableTrailerDataLock) { // If we already have cached data, just use that immediately - if (field != null) + if (field is not null) return field; // Get the offset from the end of the section table @@ -577,7 +577,7 @@ namespace SabreTools.Serialization.Wrappers lock (_stubExecutableDataLock) { // If we already have cached data, just use that immediately - if (field != null) + if (field is not null) return field; // Populate the raw stub executable data based on the source @@ -629,7 +629,7 @@ namespace SabreTools.Serialization.Wrappers lock (_wiseSectionHeaderLock) { // If we already have cached data, just use that immediately - if (field != null) + if (field is not null) return field; // If the header will not be found due to missing section data @@ -692,7 +692,7 @@ namespace SabreTools.Serialization.Wrappers get { // Use the cached data if possible - if (field != null) + if (field is not null) return field; field = GetVersionInfoString("BuildGuid"); @@ -708,7 +708,7 @@ namespace SabreTools.Serialization.Wrappers get { // Use the cached data if possible - if (field != null) + if (field is not null) return field; field = GetVersionInfoString("BuildSignature"); @@ -724,7 +724,7 @@ namespace SabreTools.Serialization.Wrappers get { // Use the cached data if possible - if (field != null) + if (field is not null) return field; field = GetVersionInfoString("Comments"); @@ -741,7 +741,7 @@ namespace SabreTools.Serialization.Wrappers get { // Use the cached data if possible - if (field != null) + if (field is not null) return field; field = GetVersionInfoString("CompanyName"); @@ -757,7 +757,7 @@ namespace SabreTools.Serialization.Wrappers get { // Use the cached data if possible - if (field != null) + if (field is not null) return field; field = GetVersionInfoString("DebugVersion"); @@ -775,7 +775,7 @@ namespace SabreTools.Serialization.Wrappers get { // Use the cached data if possible - if (field != null) + if (field is not null) return field; field = GetVersionInfoString("FileDescription"); @@ -792,7 +792,7 @@ namespace SabreTools.Serialization.Wrappers get { // Use the cached data if possible - if (field != null) + if (field is not null) return field; field = GetVersionInfoString("FileVersion"); @@ -810,7 +810,7 @@ namespace SabreTools.Serialization.Wrappers get { // Use the cached data if possible - if (field != null) + if (field is not null) return field; field = GetVersionInfoString("InternalName"); @@ -827,7 +827,7 @@ namespace SabreTools.Serialization.Wrappers get { // Use the cached data if possible - if (field != null) + if (field is not null) return field; field = GetVersionInfoString("LegalCopyright"); @@ -845,7 +845,7 @@ namespace SabreTools.Serialization.Wrappers get { // Use the cached data if possible - if (field != null) + if (field is not null) return field; field = GetVersionInfoString("LegalTrademarks"); @@ -864,7 +864,7 @@ namespace SabreTools.Serialization.Wrappers get { // Use the cached data if possible - if (field != null) + if (field is not null) return field; field = GetVersionInfoString("OriginalFilename"); @@ -882,7 +882,7 @@ namespace SabreTools.Serialization.Wrappers get { // Use the cached data if possible - if (field != null) + if (field is not null) return field; field = GetVersionInfoString("PrivateBuild"); @@ -898,7 +898,7 @@ namespace SabreTools.Serialization.Wrappers get { // Use the cached data if possible - if (field != null) + if (field is not null) return field; field = GetVersionInfoString("ProductGuid"); @@ -914,7 +914,7 @@ namespace SabreTools.Serialization.Wrappers get { // Use the cached data if possible - if (field != null) + if (field is not null) return field; field = GetVersionInfoString("ProductName"); @@ -931,7 +931,7 @@ namespace SabreTools.Serialization.Wrappers get { // Use the cached data if possible - if (field != null) + if (field is not null) return field; field = GetVersionInfoString("ProductVersion"); @@ -950,7 +950,7 @@ namespace SabreTools.Serialization.Wrappers get { // Use the cached data if possible - if (field != null) + if (field is not null) return field; field = GetVersionInfoString("SpecialBuild") ?? GetVersionInfoString("Special Build"); @@ -966,7 +966,7 @@ namespace SabreTools.Serialization.Wrappers get { // Use the cached data if possible - if (field != null) + if (field is not null) return field; field = GetVersionInfoString("TradeName"); @@ -1311,7 +1311,7 @@ namespace SabreTools.Serialization.Wrappers // Return the match if found match = Array.Find(st.Children, sd => key.Equals(sd.Key, StringComparison.OrdinalIgnoreCase)); - if (match != null) + if (match is not null) return match.Value?.TrimEnd('\0'); } @@ -1325,7 +1325,7 @@ namespace SabreTools.Serialization.Wrappers private AssemblyManifest? GetAssemblyManifest() { // Use the cached data if possible - if (_assemblyManifest != null) + if (_assemblyManifest is not null) return _assemblyManifest; // Cache the resource data for easier reading @@ -1485,7 +1485,7 @@ namespace SabreTools.Serialization.Wrappers if (signature == 0x3031424E) { var nb10ProgramDatabase = entryData.ParseNB10ProgramDatabase(ref offset); - if (nb10ProgramDatabase != null) + if (nb10ProgramDatabase is not null) { debugData[i] = nb10ProgramDatabase; continue; @@ -1496,7 +1496,7 @@ namespace SabreTools.Serialization.Wrappers else if (signature == 0x53445352) { var rsdsProgramDatabase = entryData.ParseRSDSProgramDatabase(ref offset); - if (rsdsProgramDatabase != null) + if (rsdsProgramDatabase is not null) { debugData[i] = rsdsProgramDatabase; continue; @@ -1565,15 +1565,15 @@ namespace SabreTools.Serialization.Wrappers if (resource is not DialogBoxResource dbr || dbr is null) continue; - if (dbr.DialogItemTemplates != null) + if (dbr.DialogItemTemplates is not null) { - var templates = Array.FindAll(dbr.DialogItemTemplates, dit => dit?.TitleResource != null); + var templates = Array.FindAll(dbr.DialogItemTemplates, dit => dit?.TitleResource is not null); if (Array.FindIndex(templates, dit => dit?.TitleResource?.Contains(title) == true) > -1) resources.Add(dbr); } - else if (dbr.ExtendedDialogItemTemplates != null) + else if (dbr.ExtendedDialogItemTemplates is not null) { - var templates = Array.FindAll(dbr.ExtendedDialogItemTemplates, edit => edit?.TitleResource != null); + var templates = Array.FindAll(dbr.ExtendedDialogItemTemplates, edit => edit?.TitleResource is not null); if (Array.FindIndex(templates, edit => edit?.TitleResource?.Contains(title) == true) > -1) resources.Add(dbr); } @@ -1718,7 +1718,7 @@ namespace SabreTools.Serialization.Wrappers { _dataSource.SeekIfPossible(overlayOffset, SeekOrigin.Begin); var header = WiseOverlayHeader.Create(_dataSource); - if (header != null) + if (header is not null) return overlayOffset; } @@ -1730,7 +1730,7 @@ namespace SabreTools.Serialization.Wrappers _dataSource.SeekIfPossible(sectionOffset, SeekOrigin.Begin); var header = WiseOverlayHeader.Create(_dataSource); - if (header != null) + if (header is not null) return sectionOffset; // Check after the resource table @@ -1741,7 +1741,7 @@ namespace SabreTools.Serialization.Wrappers _dataSource.SeekIfPossible(afterResourceOffset, SeekOrigin.Begin); header = WiseOverlayHeader.Create(_dataSource); - if (header != null) + if (header is not null) return afterResourceOffset; // Data following padding data @@ -1750,7 +1750,7 @@ namespace SabreTools.Serialization.Wrappers afterResourceOffset = _dataSource.Position; header = WiseOverlayHeader.Create(_dataSource); - if (header != null) + if (header is not null) return afterResourceOffset; } } @@ -1832,7 +1832,7 @@ namespace SabreTools.Serialization.Wrappers var entry = table.Entries[i]; var newTypes = new List(types ?? []); - if (entry.Name?.UnicodeString != null) + if (entry.Name?.UnicodeString is not null) newTypes.Add(Encoding.Unicode.GetString(entry.Name.UnicodeString)); else newTypes.Add(entry.IntegerID); @@ -1846,9 +1846,9 @@ namespace SabreTools.Serialization.Wrappers /// private void ParseResourceDirectoryEntry(Data.Models.PortableExecutable.Resource.DirectoryEntry entry, List types) { - if (entry.DataEntry != null) + if (entry.DataEntry is not null) ParseResourceDataEntry(entry.DataEntry, types); - else if (entry.Subdirectory != null) + else if (entry.Subdirectory is not null) ParseResourceDirectoryTable(entry.Subdirectory, types); } @@ -1870,7 +1870,7 @@ namespace SabreTools.Serialization.Wrappers object? value = entry.Data; // If we have a known resource type - if (types != null && types.Count > 0 && types[0] is uint resourceType) + if (types is not null && types.Count > 0 && types[0] is uint resourceType) { try { @@ -1954,7 +1954,7 @@ namespace SabreTools.Serialization.Wrappers } // If we have a custom resource type - else if (types != null && types.Count > 0 && types[0] is string) + else if (types is not null && types.Count > 0 && types[0] is string) { value = entry.Data; } @@ -2145,7 +2145,7 @@ namespace SabreTools.Serialization.Wrappers _sectionData ??= new byte[SectionNames.Length][]; // If we already have cached data, just use that immediately - if (_sectionData[index] != null && _sectionData[index].Length > 0) + if (_sectionData[index] is not null && _sectionData[index].Length > 0) return _sectionData[index]; // Populate the raw section data based on the source @@ -2219,7 +2219,7 @@ namespace SabreTools.Serialization.Wrappers _sectionStringData ??= new List?[SectionNames.Length]; // If we already have cached data, just use that immediately - if (_sectionStringData[index] != null) + if (_sectionStringData[index] is not null) return _sectionStringData[index]; // Get the section data, if possible @@ -2287,7 +2287,7 @@ namespace SabreTools.Serialization.Wrappers return null; // If we already have cached data, just use that immediately - if (_tableData[index] != null && _tableData[index].Length > 0) + if (_tableData[index] is not null && _tableData[index].Length > 0) return _tableData[index]; // Get the table from the optional header @@ -2322,7 +2322,7 @@ namespace SabreTools.Serialization.Wrappers return null; // If we already have cached data, just use that immediately - if (_tableStringData[index] != null) + if (_tableStringData[index] is not null) return _tableStringData[index]; // Get the table data, if possible diff --git a/SabreTools.Serialization/Wrappers/Quantum.Printing.cs b/SabreTools.Serialization/Wrappers/Quantum.Printing.cs index 83ed3302..334014b3 100644 --- a/SabreTools.Serialization/Wrappers/Quantum.Printing.cs +++ b/SabreTools.Serialization/Wrappers/Quantum.Printing.cs @@ -60,7 +60,7 @@ namespace SabreTools.Serialization.Wrappers builder.AppendLine(fileDescriptor.ExpandedFileSize, " Expanded file size"); builder.AppendLine(fileDescriptor.FileTime, " File time"); builder.AppendLine(fileDescriptor.FileDate, " File date"); - if (fileDescriptor.Unknown != null) + if (fileDescriptor.Unknown is not null) builder.AppendLine(fileDescriptor.Unknown.Value, " Unknown (Checksum?)"); } diff --git a/SabreTools.Serialization/Wrappers/RAR.Extraction.cs b/SabreTools.Serialization/Wrappers/RAR.Extraction.cs index 7d295aa0..0f5ef375 100644 --- a/SabreTools.Serialization/Wrappers/RAR.Extraction.cs +++ b/SabreTools.Serialization/Wrappers/RAR.Extraction.cs @@ -194,7 +194,7 @@ namespace SabreTools.Serialization.Wrappers for (int i = 1; ; i++) { string nextPart = nextPartFunc(i); - if (directory != null) + if (directory is not null) nextPart = Path.Combine(directory, nextPart); if (!File.Exists(nextPart)) @@ -247,7 +247,7 @@ namespace SabreTools.Serialization.Wrappers // Ensure the full output directory exists filename = Path.Combine(outDir, filename); var directoryName = Path.GetDirectoryName(filename); - if (directoryName != null && !Directory.Exists(directoryName)) + if (directoryName is not null && !Directory.Exists(directoryName)) Directory.CreateDirectory(directoryName); entry.WriteToFile(filename); diff --git a/SabreTools.Serialization/Wrappers/SGA.Extraction.cs b/SabreTools.Serialization/Wrappers/SGA.Extraction.cs index 741df1ad..862489ef 100644 --- a/SabreTools.Serialization/Wrappers/SGA.Extraction.cs +++ b/SabreTools.Serialization/Wrappers/SGA.Extraction.cs @@ -53,7 +53,7 @@ namespace SabreTools.Serialization.Wrappers // Get the parent directory string? folderName = GetParentName(index); - if (folderName != null) + if (folderName is not null) parentNames.Add(folderName); // TODO: Should the section name/alias be used in the path as well? @@ -127,7 +127,7 @@ namespace SabreTools.Serialization.Wrappers // Ensure the full output directory exists filename = Path.Combine(outputDirectory, filename); var directoryName = Path.GetDirectoryName(filename); - if (directoryName != null && !System.IO.Directory.Exists(directoryName)) + if (directoryName is not null && !System.IO.Directory.Exists(directoryName)) System.IO.Directory.CreateDirectory(directoryName); // Try to write the data diff --git a/SabreTools.Serialization/Wrappers/SGA.cs b/SabreTools.Serialization/Wrappers/SGA.cs index cb4ffdaa..343254ee 100644 --- a/SabreTools.Serialization/Wrappers/SGA.cs +++ b/SabreTools.Serialization/Wrappers/SGA.cs @@ -220,10 +220,10 @@ namespace SabreTools.Serialization.Wrappers // Get the folder Folder? folder = Directory switch { - Directory4 d4 => Array.Find(d4.Folders, f => f != null && index >= f.FileStartIndex && index <= f.FileEndIndex), - Directory5 d5 => Array.Find(d5.Folders, f => f != null && index >= f.FileStartIndex && index <= f.FileEndIndex), - Directory6 d6 => Array.Find(d6.Folders, f => f != null && index >= f.FileStartIndex && index <= f.FileEndIndex), - Directory7 d7 => Array.Find(d7.Folders, f => f != null && index >= f.FileStartIndex && index <= f.FileEndIndex), + Directory4 d4 => Array.Find(d4.Folders, f => f is not null && index >= f.FileStartIndex && index <= f.FileEndIndex), + Directory5 d5 => Array.Find(d5.Folders, f => f is not null && index >= f.FileStartIndex && index <= f.FileEndIndex), + Directory6 d6 => Array.Find(d6.Folders, f => f is not null && index >= f.FileStartIndex && index <= f.FileEndIndex), + Directory7 d7 => Array.Find(d7.Folders, f => f is not null && index >= f.FileStartIndex && index <= f.FileEndIndex), _ => default, }; diff --git a/SabreTools.Serialization/Wrappers/SecuROMMatroschkaPackage.Extraction.cs b/SabreTools.Serialization/Wrappers/SecuROMMatroschkaPackage.Extraction.cs index 9e44ab2d..53f22771 100644 --- a/SabreTools.Serialization/Wrappers/SecuROMMatroschkaPackage.Extraction.cs +++ b/SabreTools.Serialization/Wrappers/SecuROMMatroschkaPackage.Extraction.cs @@ -63,7 +63,7 @@ namespace SabreTools.Serialization.Wrappers // Ensure the full output directory exists filename = Path.Combine(outputDirectory, filename); var directoryName = Path.GetDirectoryName(filename); - if (directoryName != null && !Directory.Exists(directoryName)) + if (directoryName is not null && !Directory.Exists(directoryName)) Directory.CreateDirectory(directoryName); // Try to write the data diff --git a/SabreTools.Serialization/Wrappers/SevenZip.Extraction.cs b/SabreTools.Serialization/Wrappers/SevenZip.Extraction.cs index fdb129c0..5980f946 100644 --- a/SabreTools.Serialization/Wrappers/SevenZip.Extraction.cs +++ b/SabreTools.Serialization/Wrappers/SevenZip.Extraction.cs @@ -162,7 +162,7 @@ namespace SabreTools.Serialization.Wrappers for (int i = 1; ; i++) { string nextPart = nextPartFunc(i); - if (directory != null) + if (directory is not null) nextPart = Path.Combine(directory, nextPart); if (!File.Exists(nextPart)) @@ -215,7 +215,7 @@ namespace SabreTools.Serialization.Wrappers // Ensure the full output directory exists filename = Path.Combine(outputDirectory, filename); var directoryName = Path.GetDirectoryName(filename); - if (directoryName != null && !Directory.Exists(directoryName)) + if (directoryName is not null && !Directory.Exists(directoryName)) Directory.CreateDirectory(directoryName); entry.WriteToFile(filename); @@ -257,7 +257,7 @@ namespace SabreTools.Serialization.Wrappers // Ensure the full output directory exists filename = Path.Combine(outputDirectory, filename); var directoryName = Path.GetDirectoryName(filename); - if (directoryName != null && !Directory.Exists(directoryName)) + if (directoryName is not null && !Directory.Exists(directoryName)) Directory.CreateDirectory(directoryName); // Write to file diff --git a/SabreTools.Serialization/Wrappers/TapeArchive.Extraction.cs b/SabreTools.Serialization/Wrappers/TapeArchive.Extraction.cs index 3ee1af07..aaecf229 100644 --- a/SabreTools.Serialization/Wrappers/TapeArchive.Extraction.cs +++ b/SabreTools.Serialization/Wrappers/TapeArchive.Extraction.cs @@ -136,7 +136,7 @@ namespace SabreTools.Serialization.Wrappers // Ensure the full output directory exists filename = Path.Combine(outputDirectory, filename); var directoryName = Path.GetDirectoryName(filename); - if (directoryName != null && !Directory.Exists(directoryName)) + if (directoryName is not null && !Directory.Exists(directoryName)) Directory.CreateDirectory(directoryName); // Write the file diff --git a/SabreTools.Serialization/Wrappers/VBSP.Extraction.cs b/SabreTools.Serialization/Wrappers/VBSP.Extraction.cs index f401459d..5001d79d 100644 --- a/SabreTools.Serialization/Wrappers/VBSP.Extraction.cs +++ b/SabreTools.Serialization/Wrappers/VBSP.Extraction.cs @@ -71,7 +71,7 @@ namespace SabreTools.Serialization.Wrappers // Ensure the full output directory exists filename = Path.Combine(outputDirectory, filename); var directoryName = Path.GetDirectoryName(filename); - if (directoryName != null && !Directory.Exists(directoryName)) + if (directoryName is not null && !Directory.Exists(directoryName)) Directory.CreateDirectory(directoryName); // Try to write the data diff --git a/SabreTools.Serialization/Wrappers/VPK.Extraction.cs b/SabreTools.Serialization/Wrappers/VPK.Extraction.cs index 1262862e..c9b85936 100644 --- a/SabreTools.Serialization/Wrappers/VPK.Extraction.cs +++ b/SabreTools.Serialization/Wrappers/VPK.Extraction.cs @@ -96,7 +96,7 @@ namespace SabreTools.Serialization.Wrappers } // If we have preload data, prepend it - if (data != null && directoryItem.PreloadData != null) + if (data is not null && directoryItem.PreloadData is not null) data = [.. directoryItem.PreloadData, .. data]; } @@ -120,7 +120,7 @@ namespace SabreTools.Serialization.Wrappers // Ensure the full output directory exists filename = Path.Combine(outputDirectory, filename); var directoryName = Path.GetDirectoryName(filename); - if (directoryName != null && !Directory.Exists(directoryName)) + if (directoryName is not null && !Directory.Exists(directoryName)) Directory.CreateDirectory(directoryName); // Try to write the data diff --git a/SabreTools.Serialization/Wrappers/VPK.cs b/SabreTools.Serialization/Wrappers/VPK.cs index 40b2f427..b2f28c71 100644 --- a/SabreTools.Serialization/Wrappers/VPK.cs +++ b/SabreTools.Serialization/Wrappers/VPK.cs @@ -23,7 +23,7 @@ namespace SabreTools.Serialization.Wrappers get { // Use the cached value, if it exists - if (field != null) + if (field is not null) return field; // If we don't have a source filename diff --git a/SabreTools.Serialization/Wrappers/WAD3.Extraction.cs b/SabreTools.Serialization/Wrappers/WAD3.Extraction.cs index ff776133..35b45bf1 100644 --- a/SabreTools.Serialization/Wrappers/WAD3.Extraction.cs +++ b/SabreTools.Serialization/Wrappers/WAD3.Extraction.cs @@ -59,7 +59,7 @@ namespace SabreTools.Serialization.Wrappers // Ensure the full output directory exists filename = Path.Combine(outputDirectory, filename); var directoryName = Path.GetDirectoryName(filename); - if (directoryName != null && !Directory.Exists(directoryName)) + if (directoryName is not null && !Directory.Exists(directoryName)) Directory.CreateDirectory(directoryName); // Try to write the data diff --git a/SabreTools.Serialization/Wrappers/WiseOverlayHeader.Extraction.cs b/SabreTools.Serialization/Wrappers/WiseOverlayHeader.Extraction.cs index 527534e2..9fbaec0a 100644 --- a/SabreTools.Serialization/Wrappers/WiseOverlayHeader.Extraction.cs +++ b/SabreTools.Serialization/Wrappers/WiseOverlayHeader.Extraction.cs @@ -227,7 +227,7 @@ namespace SabreTools.Serialization.Wrappers // Strip the extension and rebuild string? directory = Path.GetDirectoryName(filename); filename = Path.GetFileNameWithoutExtension(filename); - if (directory != null) + if (directory is not null) filename = Path.Combine(directory, filename); } diff --git a/SabreTools.Serialization/Wrappers/WiseOverlayHeader.Printing.cs b/SabreTools.Serialization/Wrappers/WiseOverlayHeader.Printing.cs index 93321e2e..bb3eb77f 100644 --- a/SabreTools.Serialization/Wrappers/WiseOverlayHeader.Printing.cs +++ b/SabreTools.Serialization/Wrappers/WiseOverlayHeader.Printing.cs @@ -47,7 +47,7 @@ namespace SabreTools.Serialization.Wrappers builder.AppendLine(Model.DibDeflatedSize, "DIB deflated size"); builder.AppendLine(Model.DibInflatedSize, "DIB inflated size"); builder.AppendLine(Model.InstallScriptDeflatedSize, "Install script deflated size"); - if (Model.CharacterSet != null) + if (Model.CharacterSet is not null) builder.AppendLine($"Character set: {Model.CharacterSet} (0x{(uint)Model.CharacterSet:X8})"); else builder.AppendLine((uint?)null, $"Character set"); diff --git a/SabreTools.Serialization/Wrappers/WiseOverlayHeader.cs b/SabreTools.Serialization/Wrappers/WiseOverlayHeader.cs index 551fd346..ed328ce4 100644 --- a/SabreTools.Serialization/Wrappers/WiseOverlayHeader.cs +++ b/SabreTools.Serialization/Wrappers/WiseOverlayHeader.cs @@ -60,10 +60,10 @@ namespace SabreTools.Serialization.Wrappers field += 4; // DibDeflatedSize field += 4; // DibInflatedSize - if (Model.InstallScriptDeflatedSize != null) + if (Model.InstallScriptDeflatedSize is not null) field += 4; // InstallScriptDeflatedSize - if (Model.CharacterSet != null) + if (Model.CharacterSet is not null) field += 4; // CharacterSet field += 2; // Endianness diff --git a/SabreTools.Serialization/Wrappers/WiseScript.cs b/SabreTools.Serialization/Wrappers/WiseScript.cs index 7cd1bef8..9eccaee1 100644 --- a/SabreTools.Serialization/Wrappers/WiseScript.cs +++ b/SabreTools.Serialization/Wrappers/WiseScript.cs @@ -156,7 +156,7 @@ namespace SabreTools.Serialization.Wrappers // Initialize important loop information int normalFileCount = 0; Dictionary environment = []; - if (sourceDirectory != null) + if (sourceDirectory is not null) environment.Add("INST", sourceDirectory); // Loop through the state machine and process @@ -287,7 +287,7 @@ namespace SabreTools.Serialization.Wrappers // Sanity check string? newFileDirectory = Path.GetDirectoryName(newFilePath); - if (newFileDirectory != null && !Directory.Exists(newFileDirectory)) + if (newFileDirectory is not null && !Directory.Exists(newFileDirectory)) Directory.CreateDirectory(newFileDirectory); File.Copy(oldFilePath, newFilePath); @@ -312,7 +312,7 @@ namespace SabreTools.Serialization.Wrappers if (state.Data is not GetTemporaryFilename getTemporaryFilename) return false; - if (getTemporaryFilename.Variable != null) + if (getTemporaryFilename.Variable is not null) environment[getTemporaryFilename.Variable] = Guid.NewGuid().ToString(); break; @@ -352,7 +352,7 @@ namespace SabreTools.Serialization.Wrappers // Ensure the full output directory exists iniFilePath = Path.Combine(outputDirectory, iniFilePath); var directoryName = Path.GetDirectoryName(iniFilePath); - if (directoryName != null && !Directory.Exists(directoryName)) + if (directoryName is not null && !Directory.Exists(directoryName)) Directory.CreateDirectory(directoryName); using var iniFile = File.Open(iniFilePath, FileMode.Append, FileAccess.Write, FileShare.ReadWrite); diff --git a/SabreTools.Serialization/Wrappers/WiseSectionHeader.Extraction.cs b/SabreTools.Serialization/Wrappers/WiseSectionHeader.Extraction.cs index 253f2b8a..e16305b5 100644 --- a/SabreTools.Serialization/Wrappers/WiseSectionHeader.Extraction.cs +++ b/SabreTools.Serialization/Wrappers/WiseSectionHeader.Extraction.cs @@ -88,7 +88,7 @@ namespace SabreTools.Serialization.Wrappers // Extract the file var destination = new MemoryStream(); ExtractionStatus status; - if (!(Version != null && Version[1] == 0x01)) + if (!(Version is not null && Version[1] == 0x01)) status = ExtractStreamWithChecksum(destination, entrySize, includeDebug); else // hack for Codesited5.exe , very early and very strange. status = ExtractStreamWithoutChecksum(destination, entrySize, includeDebug); @@ -100,7 +100,7 @@ namespace SabreTools.Serialization.Wrappers // Ensure the full output directory exists filename = Path.Combine(outputDirectory, filename); var directoryName = Path.GetDirectoryName(filename); - if (directoryName != null && !Directory.Exists(directoryName)) + if (directoryName is not null && !Directory.Exists(directoryName)) Directory.CreateDirectory(directoryName); // Write the output file @@ -142,7 +142,7 @@ namespace SabreTools.Serialization.Wrappers if (includeDebug) Console.WriteLine($"Expected CRC-32: {expectedCrc32:X8}"); byte[]? hashBytes = HashTool.GetByteArrayHashArray(actual, HashType.CRC32); - if (hashBytes != null) + if (hashBytes is not null) { uint actualCrc32 = BitConverter.ToUInt32(hashBytes, 0); diff --git a/SabreTools.Serialization/Wrappers/XMID.cs b/SabreTools.Serialization/Wrappers/XMID.cs index 7d56ae01..b527d97e 100644 --- a/SabreTools.Serialization/Wrappers/XMID.cs +++ b/SabreTools.Serialization/Wrappers/XMID.cs @@ -23,7 +23,7 @@ namespace SabreTools.Serialization.Wrappers get { // Use the cached data if possible - if (field != null) + if (field is not null) return field; if (Publishers.TryGetValue(Model.PublisherIdentifier, out var publisher)) @@ -45,7 +45,7 @@ namespace SabreTools.Serialization.Wrappers get { // Use the cached data if possible - if (field != null) + if (field is not null) return field; if (Regions.TryGetValue(Model.RegionIdentifier, out var region)) diff --git a/SabreTools.Serialization/Wrappers/XZ.Extraction.cs b/SabreTools.Serialization/Wrappers/XZ.Extraction.cs index eb7ee937..fad47c3d 100644 --- a/SabreTools.Serialization/Wrappers/XZ.Extraction.cs +++ b/SabreTools.Serialization/Wrappers/XZ.Extraction.cs @@ -26,7 +26,7 @@ namespace SabreTools.Serialization.Wrappers using var xzFile = new XZStream(_dataSource); // Ensure directory separators are consistent - string filename = Filename != null + string filename = Filename is not null ? Path.GetFileNameWithoutExtension(Filename) : Guid.NewGuid().ToString(); if (Path.DirectorySeparatorChar == '\\') @@ -37,7 +37,7 @@ namespace SabreTools.Serialization.Wrappers // Ensure the full output directory exists filename = Path.Combine(outputDirectory, filename); var directoryName = Path.GetDirectoryName(filename); - if (directoryName != null && !Directory.Exists(directoryName)) + if (directoryName is not null && !Directory.Exists(directoryName)) Directory.CreateDirectory(directoryName); // Extract the file diff --git a/SabreTools.Serialization/Wrappers/XZP.Extraction.cs b/SabreTools.Serialization/Wrappers/XZP.Extraction.cs index de01b0b8..d2e34614 100644 --- a/SabreTools.Serialization/Wrappers/XZP.Extraction.cs +++ b/SabreTools.Serialization/Wrappers/XZP.Extraction.cs @@ -68,7 +68,7 @@ namespace SabreTools.Serialization.Wrappers // Ensure the full output directory exists filename = Path.Combine(outputDirectory, filename); var directoryName = Path.GetDirectoryName(filename); - if (directoryName != null && !Directory.Exists(directoryName)) + if (directoryName is not null && !Directory.Exists(directoryName)) Directory.CreateDirectory(directoryName); // Try to write the data diff --git a/SabreTools.Serialization/Wrappers/XeMID.cs b/SabreTools.Serialization/Wrappers/XeMID.cs index 68fcc570..a04a9c71 100644 --- a/SabreTools.Serialization/Wrappers/XeMID.cs +++ b/SabreTools.Serialization/Wrappers/XeMID.cs @@ -23,7 +23,7 @@ namespace SabreTools.Serialization.Wrappers get { // Use the cached data if possible - if (field != null) + if (field is not null) return field; if (MediaSubtypes.TryGetValue(Model.MediaSubtypeIdentifier, out var mediaSubtype)) @@ -45,7 +45,7 @@ namespace SabreTools.Serialization.Wrappers get { // Use the cached data if possible - if (field != null) + if (field is not null) return field; if (Publishers.TryGetValue(Model.PublisherIdentifier, out var publisher)) @@ -67,7 +67,7 @@ namespace SabreTools.Serialization.Wrappers get { // Use the cached data if possible - if (field != null) + if (field is not null) return field; if (Regions.TryGetValue(Model.RegionIdentifier, out var region)) diff --git a/SabreTools.Serialization/Wrappers/ZSTD.Extraction.cs b/SabreTools.Serialization/Wrappers/ZSTD.Extraction.cs index f1b39b37..dad283de 100644 --- a/SabreTools.Serialization/Wrappers/ZSTD.Extraction.cs +++ b/SabreTools.Serialization/Wrappers/ZSTD.Extraction.cs @@ -39,7 +39,7 @@ namespace SabreTools.Serialization.Wrappers // Ensure the full output directory exists filename = Path.Combine(outputDirectory, filename); var directoryName = Path.GetDirectoryName(filename); - if (directoryName != null && !Directory.Exists(directoryName)) + if (directoryName is not null && !Directory.Exists(directoryName)) Directory.CreateDirectory(directoryName); // Open the source as a zStandard stream diff --git a/SabreTools.Serialization/Writers/CueSheet.cs b/SabreTools.Serialization/Writers/CueSheet.cs index 21edd4dd..38dd6372 100644 --- a/SabreTools.Serialization/Writers/CueSheet.cs +++ b/SabreTools.Serialization/Writers/CueSheet.cs @@ -122,7 +122,7 @@ namespace SabreTools.Serialization.Writers if (!string.IsNullOrEmpty(cueTrack.Title)) sw.WriteLine($" TITLE {cueTrack.Title}"); - if (cueTrack.PreGap != null) + if (cueTrack.PreGap is not null) WritePreGap(cueTrack.PreGap, sw); foreach (var index in cueTrack.Indices) @@ -130,7 +130,7 @@ namespace SabreTools.Serialization.Writers WriteCueIndex(index, sw); } - if (cueTrack.PostGap != null) + if (cueTrack.PostGap is not null) WritePostGap(cueTrack.PostGap, sw); } diff --git a/SabreTools.Serialization/Writers/EverdriveSMDB.cs b/SabreTools.Serialization/Writers/EverdriveSMDB.cs index 76f3b371..c0ba96f7 100644 --- a/SabreTools.Serialization/Writers/EverdriveSMDB.cs +++ b/SabreTools.Serialization/Writers/EverdriveSMDB.cs @@ -54,7 +54,7 @@ namespace SabreTools.Serialization.Writers row.CRC32, }; - if (row.Size != null) + if (row.Size is not null) rowArray.Add(row.Size); writer.WriteValues([.. rowArray]); diff --git a/SabreTools.Serialization/Writers/Listrom.cs b/SabreTools.Serialization/Writers/Listrom.cs index 1e3fa2b3..36bad621 100644 --- a/SabreTools.Serialization/Writers/Listrom.cs +++ b/SabreTools.Serialization/Writers/Listrom.cs @@ -58,7 +58,7 @@ namespace SabreTools.Serialization.Writers if (!string.IsNullOrEmpty(set.Driver)) { - if (set.Row != null && set.Row.Length > 0) + if (set.Row is not null && set.Row.Length > 0) { writer.WriteLine($"ROMs required for driver \"{set.Driver}\"."); writer.WriteLine("Name Size Checksum"); @@ -78,7 +78,7 @@ namespace SabreTools.Serialization.Writers } else if (!string.IsNullOrEmpty(set.Device)) { - if (set.Row != null && set.Row.Length > 0) + if (set.Row is not null && set.Row.Length > 0) { writer.WriteLine($"ROMs required for device \"{set.Device}\"."); writer.WriteLine("Name Size Checksum"); @@ -121,7 +121,7 @@ namespace SabreTools.Serialization.Writers padding = row.Name.Length + 2; rowBuilder.Append($"{row.Name.PadRight(padding, ' ')}"); - if (row.Size != null) + if (row.Size is not null) rowBuilder.Append($"{row.Size} "); if (row.NoGoodDumpKnown) @@ -133,7 +133,7 @@ namespace SabreTools.Serialization.Writers if (row.Bad) rowBuilder.Append("BAD "); - if (row.Size != null) + if (row.Size is not null) { rowBuilder.Append($"CRC({row.CRC}) "); rowBuilder.Append($"SHA1({row.SHA1}) "); diff --git a/SabreTools.Serialization/Writers/RomCenter.cs b/SabreTools.Serialization/Writers/RomCenter.cs index c40985c4..f1b92e78 100644 --- a/SabreTools.Serialization/Writers/RomCenter.cs +++ b/SabreTools.Serialization/Writers/RomCenter.cs @@ -49,19 +49,19 @@ namespace SabreTools.Serialization.Writers writer.WriteSection("CREDITS"); - if (credits.Author != null) + if (credits.Author is not null) writer.WriteKeyValuePair("Author", credits.Author); - if (credits.Version != null) + if (credits.Version is not null) writer.WriteKeyValuePair("Version", credits.Version); - if (credits.Email != null) + if (credits.Email is not null) writer.WriteKeyValuePair("Email", credits.Email); - if (credits.Homepage != null) + if (credits.Homepage is not null) writer.WriteKeyValuePair("Homepage", credits.Homepage); - if (credits.Url != null) + if (credits.Url is not null) writer.WriteKeyValuePair("Url", credits.Url); - if (credits.Date != null) + if (credits.Date is not null) writer.WriteKeyValuePair("Date", credits.Date); - if (credits.Comment != null) + if (credits.Comment is not null) writer.WriteKeyValuePair("Comment", credits.Comment); writer.WriteLine(); @@ -81,13 +81,13 @@ namespace SabreTools.Serialization.Writers writer.WriteSection("DAT"); - if (dat.Version != null) + if (dat.Version is not null) writer.WriteKeyValuePair("Version", dat.Version); - if (dat.Plugin != null) + if (dat.Plugin is not null) writer.WriteKeyValuePair("Plugin", dat.Plugin); - if (dat.Split != null) + if (dat.Split is not null) writer.WriteKeyValuePair("Split", dat.Split); - if (dat.Merge != null) + if (dat.Merge is not null) writer.WriteKeyValuePair("Merge", dat.Merge); writer.WriteLine(); @@ -107,9 +107,9 @@ namespace SabreTools.Serialization.Writers writer.WriteSection("EMULATOR"); - if (emulator.RefName != null) + if (emulator.RefName is not null) writer.WriteKeyValuePair("refname", emulator.RefName); - if (emulator.Version != null) + if (emulator.Version is not null) writer.WriteKeyValuePair("version", emulator.Version); writer.WriteLine(); diff --git a/SabreTools.Serialization/_EXTERNAL/StormLibSharp/MpqArchive.cs b/SabreTools.Serialization/_EXTERNAL/StormLibSharp/MpqArchive.cs index 13144ff5..6a81001d 100644 --- a/SabreTools.Serialization/_EXTERNAL/StormLibSharp/MpqArchive.cs +++ b/SabreTools.Serialization/_EXTERNAL/StormLibSharp/MpqArchive.cs @@ -284,7 +284,7 @@ namespace StormLibSharp _openFiles.Clear(); // Release - if (_handle != null && !_handle.IsInvalid) + if (_handle is not null && !_handle.IsInvalid) { _handle.Close(); _handle = null; diff --git a/SabreTools.Serialization/_EXTERNAL/StormLibSharp/MpqFileStream.cs b/SabreTools.Serialization/_EXTERNAL/StormLibSharp/MpqFileStream.cs index 77feb504..2aa5c862 100644 --- a/SabreTools.Serialization/_EXTERNAL/StormLibSharp/MpqFileStream.cs +++ b/SabreTools.Serialization/_EXTERNAL/StormLibSharp/MpqFileStream.cs @@ -147,7 +147,7 @@ namespace StormLibSharp if (disposing) { - if (_handle != null && !_handle.IsInvalid) + if (_handle is not null && !_handle.IsInvalid) { _handle.Close(); _handle = null;