diff --git a/SabreTools.Core/DictionaryBaseExtensions.cs b/SabreTools.Core/DictionaryBaseExtensions.cs index 05475976..eac7738f 100644 --- a/SabreTools.Core/DictionaryBaseExtensions.cs +++ b/SabreTools.Core/DictionaryBaseExtensions.cs @@ -14,10 +14,7 @@ namespace SabreTools.Core public static DictionaryBase? Clone(this DictionaryBase dictionaryBase) { // Create a new object of the same type - var clone = dictionaryBase - .GetType() - .GetConstructor(System.Reflection.BindingFlags.Public, Array.Empty())? - .Invoke(null) as DictionaryBase; + var clone = Activator.CreateInstance(dictionaryBase.GetType()) as DictionaryBase; // If construction failed, we can't do anything if (clone == null) diff --git a/SabreTools.Core/Tools/TextHelper.cs b/SabreTools.Core/Tools/TextHelper.cs index c407ce95..31851fd6 100644 --- a/SabreTools.Core/Tools/TextHelper.cs +++ b/SabreTools.Core/Tools/TextHelper.cs @@ -81,37 +81,37 @@ namespace SabreTools.Core.Tools /// /// Normalize a CRC32 string and pad to the correct size /// - public static string NormalizeCRC32(string? hash) + public static string? NormalizeCRC32(string? hash) => NormalizeHashData(hash, Constants.CRCLength); /// /// Normalize a MD5 string and pad to the correct size /// - public static string NormalizeMD5(string? hash) + public static string? NormalizeMD5(string? hash) => NormalizeHashData(hash, Constants.MD5Length); /// /// Normalize a SHA1 string and pad to the correct size /// - public static string NormalizeSHA1(string? hash) + public static string? NormalizeSHA1(string? hash) => NormalizeHashData(hash, Constants.SHA1Length); /// /// Normalize a SHA256 string and pad to the correct size /// - public static string NormalizeSHA256(string? hash) + public static string? NormalizeSHA256(string? hash) => NormalizeHashData(hash, Constants.SHA256Length); /// /// Normalize a SHA384 string and pad to the correct size /// - public static string NormalizeSHA384(string? hash) + public static string? NormalizeSHA384(string? hash) => NormalizeHashData(hash, Constants.SHA384Length); /// /// Normalize a SHA512 string and pad to the correct size /// - public static string NormalizeSHA512(string? hash) + public static string? NormalizeSHA512(string? hash) => NormalizeHashData(hash, Constants.SHA512Length); /// @@ -186,10 +186,12 @@ namespace SabreTools.Core.Tools /// /// Normalize a hash string and pad to the correct size /// - private static string NormalizeHashData(string? hash, int expectedLength) + private static string? NormalizeHashData(string? hash, int expectedLength) { // If we have a known blank hash, return blank - if (string.IsNullOrWhiteSpace(hash) || hash == "-" || hash == "_") + if (string.IsNullOrWhiteSpace(hash)) + return null; + else if (hash == "-" || hash == "_") return string.Empty; // Check to see if it's a "hex" hash diff --git a/SabreTools.DatFiles/DatFile.cs b/SabreTools.DatFiles/DatFile.cs index c7b9939b..bb13b43c 100644 --- a/SabreTools.DatFiles/DatFile.cs +++ b/SabreTools.DatFiles/DatFile.cs @@ -316,7 +316,7 @@ namespace SabreTools.DatFiles { // Initialize strings string fix, - game = item.Machine?.Name ?? string.Empty, + game = item.Machine.Name ?? string.Empty, name = item.GetName() ?? item.ItemType.ToString(), crc = string.Empty, md5 = string.Empty, @@ -365,9 +365,9 @@ namespace SabreTools.DatFiles .Replace("%game%", game) .Replace("%machine%", game) .Replace("%name%", name) - .Replace("%manufacturer%", item.Machine?.Manufacturer ?? string.Empty) - .Replace("%publisher%", item.Machine?.Publisher ?? string.Empty) - .Replace("%category%", item.Machine?.Category ?? string.Empty) + .Replace("%manufacturer%", item.Machine.Manufacturer ?? string.Empty) + .Replace("%publisher%", item.Machine.Publisher ?? string.Empty) + .Replace("%category%", item.Machine.Category ?? string.Empty) .Replace("%crc%", crc) .Replace("%md5%", md5) .Replace("%sha1%", sha1) @@ -397,7 +397,7 @@ namespace SabreTools.DatFiles Header.UseRomName = true; // Get the name to update - string? name = (Header.UseRomName ? item.GetName() : item.Machine?.Name) ?? string.Empty; + string? name = (Header.UseRomName ? item.GetName() : item.Machine.Name) ?? string.Empty; // Create the proper Prefix and Postfix string pre = CreatePrefixPostfix(item, true); @@ -454,7 +454,7 @@ namespace SabreTools.DatFiles name += Header.AddExtension; if (Header.UseRomName && Header.GameName) - name = Path.Combine(item.Machine?.Name ?? string.Empty, name); + name = Path.Combine(item.Machine.Name ?? string.Empty, name); // Now assign back the formatted name name = $"{pre}{name}{post}"; @@ -489,7 +489,7 @@ namespace SabreTools.DatFiles // If the Rom has "null" characteristics, ensure all fields if (rom.Size == null && rom.CRC == "null") { - logger.Verbose($"Empty folder found: {datItem.Machine?.Name}"); + logger.Verbose($"Empty folder found: {datItem.Machine.Name}"); rom.Name = (rom.Name == "null" ? "-" : rom.Name); rom.Size = Constants.SizeZero; diff --git a/SabreTools.DatFiles/Formats/AttractMode.Writer.cs b/SabreTools.DatFiles/Formats/AttractMode.Writer.cs index 662f1107..3c3bacf6 100644 --- a/SabreTools.DatFiles/Formats/AttractMode.Writer.cs +++ b/SabreTools.DatFiles/Formats/AttractMode.Writer.cs @@ -121,23 +121,23 @@ namespace SabreTools.DatFiles.Formats { var row = new Models.AttractMode.Row { - Name = rom.Machine?.Name, - Title = rom.Machine?.Description, + Name = rom.Machine.Name, + Title = rom.Machine.Description, Emulator = Header.FileName, - CloneOf = rom.Machine?.CloneOf, - Year = rom.Machine?.Year, - Manufacturer = rom.Machine?.Manufacturer, - Category = rom.Machine?.Category, - Players = rom.Machine?.Players, - Rotation = rom.Machine?.Rotation, - Control = rom.Machine?.Control, - Status = rom.Machine?.Status, - DisplayCount = rom.Machine?.DisplayCount, - DisplayType = rom.Machine?.DisplayType, + CloneOf = rom.Machine.CloneOf, + Year = rom.Machine.Year, + Manufacturer = rom.Machine.Manufacturer, + Category = rom.Machine.Category, + Players = rom.Machine.Players, + Rotation = rom.Machine.Rotation, + Control = rom.Machine.Control, + Status = rom.Machine.Status, + DisplayCount = rom.Machine.DisplayCount, + DisplayType = rom.Machine.DisplayType, AltRomname = rom.AltName, AltTitle = rom.AltTitle, - Extra = rom.Machine?.Comment, - Buttons = rom.Machine?.Buttons, + Extra = rom.Machine.Comment, + Buttons = rom.Machine.Buttons, // TODO: Add extended fields }; return row; diff --git a/SabreTools.DatFiles/Formats/EverdriveSMDB.Writer.cs b/SabreTools.DatFiles/Formats/EverdriveSMDB.Writer.cs index 3bdcf9f0..3be1df28 100644 --- a/SabreTools.DatFiles/Formats/EverdriveSMDB.Writer.cs +++ b/SabreTools.DatFiles/Formats/EverdriveSMDB.Writer.cs @@ -139,7 +139,7 @@ namespace SabreTools.DatFiles.Formats var row = new Models.EverdriveSMDB.Row { SHA256 = rom.SHA256, - Name = $"{rom.Machine?.Name ?? string.Empty}/{rom.Name}", + Name = $"{rom.Machine.Name ?? string.Empty}/{rom.Name}", SHA1 = rom.SHA1, MD5 = rom.MD5, CRC32 = rom.CRC, diff --git a/SabreTools.DatFiles/Formats/Missfile.Writer.cs b/SabreTools.DatFiles/Formats/Missfile.Writer.cs index 24d44448..bda57a5d 100644 --- a/SabreTools.DatFiles/Formats/Missfile.Writer.cs +++ b/SabreTools.DatFiles/Formats/Missfile.Writer.cs @@ -63,7 +63,7 @@ namespace SabreTools.DatFiles.Formats WriteDatItem(sw, datItem, lastgame); // Set the new data to compare against - lastgame = datItem.Machine?.Name; + lastgame = datItem.Machine.Name; } } @@ -94,8 +94,8 @@ namespace SabreTools.DatFiles.Formats // Romba mode automatically uses item name if (Header.OutputDepot?.IsActive == true || Header.UseRomName) sw.Write($"{datItem.GetName() ?? string.Empty}\n"); - else if (!Header.UseRomName && datItem.Machine?.Name != lastgame) - sw.Write($"{datItem.Machine?.Name ?? string.Empty}\n"); + else if (!Header.UseRomName && datItem.Machine.Name != lastgame) + sw.Write($"{datItem.Machine.Name ?? string.Empty}\n"); sw.Flush(); } diff --git a/SabreTools.DatFiles/Formats/RomCenter.Writer.cs b/SabreTools.DatFiles/Formats/RomCenter.Writer.cs index e98f6bc8..aeabd613 100644 --- a/SabreTools.DatFiles/Formats/RomCenter.Writer.cs +++ b/SabreTools.DatFiles/Formats/RomCenter.Writer.cs @@ -183,14 +183,14 @@ namespace SabreTools.DatFiles.Formats { var rom = new Models.RomCenter.Rom { - ParentName = item.Machine?.CloneOf, - //ParentDescription = item.Machine?.CloneOfDescription, // TODO: Add to internal model or find mapping - GameName = item.Machine?.Name, - GameDescription = item.Machine?.Description, + ParentName = item.Machine.CloneOf, + //ParentDescription = item.Machine.CloneOfDescription, // TODO: Add to internal model or find mapping + GameName = item.Machine.Name, + GameDescription = item.Machine.Description, RomName = item.Name, RomCRC = item.CRC, RomSize = item.Size?.ToString(), - RomOf = item.Machine?.RomOf, + RomOf = item.Machine.RomOf, MergeName = item.MergeTag, }; return rom; diff --git a/SabreTools.DatFiles/Formats/SabreJSON.cs b/SabreTools.DatFiles/Formats/SabreJSON.cs index 7fb68288..bd7dcbac 100644 --- a/SabreTools.DatFiles/Formats/SabreJSON.cs +++ b/SabreTools.DatFiles/Formats/SabreJSON.cs @@ -395,11 +395,11 @@ namespace SabreTools.DatFiles.Formats DatItem datItem = datItems[index]; // If we have a different game and we're not at the start of the list, output the end of last item - if (lastgame != null && lastgame.ToLowerInvariant() != datItem.Machine?.Name?.ToLowerInvariant()) + if (lastgame != null && lastgame.ToLowerInvariant() != datItem.Machine.Name?.ToLowerInvariant()) WriteEndGame(jtw); // If we have a new game, output the beginning of the new item - if (lastgame == null || lastgame.ToLowerInvariant() != datItem.Machine?.Name?.ToLowerInvariant()) + if (lastgame == null || lastgame.ToLowerInvariant() != datItem.Machine.Name?.ToLowerInvariant()) WriteStartGame(jtw, datItem); // Check for a "null" item @@ -410,7 +410,7 @@ namespace SabreTools.DatFiles.Formats WriteDatItem(jtw, datItem); // Set the new data to compare against - lastgame = datItem.Machine?.Name; + lastgame = datItem.Machine.Name; } } @@ -457,7 +457,7 @@ namespace SabreTools.DatFiles.Formats private void WriteStartGame(JsonTextWriter jtw, DatItem datItem) { // No game should start with a path separator - if (!string.IsNullOrWhiteSpace(datItem.Machine?.Name)) + if (!string.IsNullOrWhiteSpace(datItem.Machine.Name)) datItem.Machine.Name = datItem.Machine.Name.TrimStart(Path.DirectorySeparatorChar) ?? string.Empty; // Build the state diff --git a/SabreTools.DatFiles/Formats/SabreXML.cs b/SabreTools.DatFiles/Formats/SabreXML.cs index 67c49c3f..f237612f 100644 --- a/SabreTools.DatFiles/Formats/SabreXML.cs +++ b/SabreTools.DatFiles/Formats/SabreXML.cs @@ -223,11 +223,11 @@ namespace SabreTools.DatFiles.Formats DatItem datItem = datItems[index]; // If we have a different game and we're not at the start of the list, output the end of last item - if (lastgame != null && lastgame.ToLowerInvariant() != datItem.Machine?.Name?.ToLowerInvariant()) + if (lastgame != null && lastgame.ToLowerInvariant() != datItem.Machine.Name?.ToLowerInvariant()) WriteEndGame(xtw); // If we have a new game, output the beginning of the new item - if (lastgame == null || lastgame.ToLowerInvariant() != datItem.Machine?.Name?.ToLowerInvariant()) + if (lastgame == null || lastgame.ToLowerInvariant() != datItem.Machine.Name?.ToLowerInvariant()) WriteStartGame(xtw, datItem); // Check for a "null" item @@ -238,7 +238,7 @@ namespace SabreTools.DatFiles.Formats WriteDatItem(xtw, datItem); // Set the new data to compare against - lastgame = datItem.Machine?.Name; + lastgame = datItem.Machine.Name; } } diff --git a/SabreTools.DatFiles/Formats/SeparatedValue.Writer.cs b/SabreTools.DatFiles/Formats/SeparatedValue.Writer.cs index d59d46b8..8540a9b6 100644 --- a/SabreTools.DatFiles/Formats/SeparatedValue.Writer.cs +++ b/SabreTools.DatFiles/Formats/SeparatedValue.Writer.cs @@ -162,8 +162,8 @@ namespace SabreTools.DatFiles.Formats FileName = Header.FileName, InternalName = Header.Name, Description = Header.Description, - GameName = disk.Machine?.Name, - GameDescription = disk.Machine?.Description, + GameName = disk.Machine.Name, + GameDescription = disk.Machine.Description, Type = disk.ItemType.FromItemType(), RomName = string.Empty, DiskName = disk.Name, @@ -190,8 +190,8 @@ namespace SabreTools.DatFiles.Formats FileName = Header.FileName, InternalName = Header.Name, Description = Header.Description, - GameName = media.Machine?.Name, - GameDescription = media.Machine?.Description, + GameName = media.Machine.Name, + GameDescription = media.Machine.Description, Type = media.ItemType.FromItemType(), RomName = string.Empty, DiskName = media.Name, @@ -218,8 +218,8 @@ namespace SabreTools.DatFiles.Formats FileName = Header.FileName, InternalName = Header.Name, Description = Header.Description, - GameName = rom.Machine?.Name, - GameDescription = rom.Machine?.Description, + GameName = rom.Machine.Name, + GameDescription = rom.Machine.Description, Type = rom.ItemType.FromItemType(), RomName = rom.Name, DiskName = string.Empty, diff --git a/SabreTools.DatFiles/ItemDictionary.cs b/SabreTools.DatFiles/ItemDictionary.cs index 2092a6c4..cb1985c7 100644 --- a/SabreTools.DatFiles/ItemDictionary.cs +++ b/SabreTools.DatFiles/ItemDictionary.cs @@ -728,7 +728,7 @@ namespace SabreTools.DatFiles // Filter the list return fi.Where(i => i != null) .Where(i => !i.Remove) - .Where(i => i.Machine?.Name != null) + .Where(i => i.Machine.Name != null) .ToConcurrentList(); } } diff --git a/SabreTools.DatFiles/ItemDictionaryDB.cs b/SabreTools.DatFiles/ItemDictionaryDB.cs index c42b4b19..45163236 100644 --- a/SabreTools.DatFiles/ItemDictionaryDB.cs +++ b/SabreTools.DatFiles/ItemDictionaryDB.cs @@ -869,7 +869,7 @@ namespace SabreTools.DatFiles // Filter the list return fi.Where(i => i != null) .Where(i => !i.Remove) - .Where(i => i.Machine?.Name != null) + .Where(i => i.Machine.Name != null) .ToConcurrentList(); } } diff --git a/SabreTools.DatItems/DatItem.cs b/SabreTools.DatItems/DatItem.cs index 24ce3eb3..14f943df 100644 --- a/SabreTools.DatItems/DatItem.cs +++ b/SabreTools.DatItems/DatItem.cs @@ -102,7 +102,7 @@ namespace SabreTools.DatItems /// /// Hack on top of internal model [JsonIgnore, XmlIgnore] - public Machine? Machine + public Machine Machine { get => _internal.Read("MACHINE") ?? new Machine(); set => _internal["MACHINE"] = value; @@ -180,6 +180,8 @@ namespace SabreTools.DatItems public DatItem() { _internal = new Models.Internal.Blank(); + Machine = new Machine(); + logger = new Logger(this); } @@ -277,7 +279,9 @@ namespace SabreTools.DatItems if (item?.Machine == null) return; - Machine = item.Machine.Clone() as Machine; + var cloned = item.Machine.Clone() as Machine; + if (cloned != null) + Machine = cloned; } /// @@ -289,7 +293,9 @@ namespace SabreTools.DatItems if (machine == null) return; - Machine = machine.Clone() as Machine; + var cloned = machine.Clone() as Machine; + if (cloned != null) + Machine = cloned; } #endregion @@ -343,7 +349,7 @@ namespace SabreTools.DatItems // If the duplicate is external already or should be, set it if (lastItem.DupeType.HasFlag(DupeType.External) || lastItem?.Source?.Index != Source?.Index) { - if (lastItem?.Machine?.Name == Machine?.Name && lastItem?.GetName() == GetName()) + if (lastItem?.Machine.Name == Machine?.Name && lastItem?.GetName() == GetName()) output = DupeType.External | DupeType.All; else output = DupeType.External | DupeType.Hash; @@ -352,7 +358,7 @@ namespace SabreTools.DatItems // Otherwise, it's considered an internal dupe else { - if (lastItem?.Machine?.Name == Machine?.Name && lastItem?.GetName() == GetName()) + if (lastItem?.Machine.Name == Machine?.Name && lastItem?.GetName() == GetName()) output = DupeType.Internal | DupeType.All; else output = DupeType.Internal | DupeType.Hash; @@ -526,7 +532,7 @@ namespace SabreTools.DatItems } // If the current machine is a child of the new machine, use the new machine instead - if (saveditem.Machine?.CloneOf == file.Machine?.Name || saveditem.Machine?.RomOf == file.Machine?.Name) + if (saveditem.Machine.CloneOf == file.Machine.Name || saveditem.Machine.RomOf == file.Machine.Name) { saveditem.CopyMachineInformation(file); saveditem.SetName(file.GetName()); @@ -673,7 +679,7 @@ namespace SabreTools.DatItems NaturalComparer nc = new(); // If machine names match, more refinement is needed - if (x.Machine?.Name == y.Machine?.Name) + if (x.Machine.Name == y.Machine.Name) { // If item types match, more refinement is needed if (x.ItemType == y.ItemType) @@ -689,7 +695,7 @@ namespace SabreTools.DatItems // If item names match, then compare on machine or source, depending on the flag if (xName == yName) - return (norename ? nc.Compare(x.Machine?.Name, y.Machine?.Name) : (x.Source?.Index - y.Source?.Index) ?? 0); + return (norename ? nc.Compare(x.Machine.Name, y.Machine.Name) : (x.Source?.Index - y.Source?.Index) ?? 0); // Otherwise, just sort based on item names return nc.Compare(xName, yName); @@ -704,7 +710,7 @@ namespace SabreTools.DatItems } // Otherwise, just sort based on machine name - return nc.Compare(x.Machine?.Name, y.Machine?.Name); + return nc.Compare(x.Machine.Name, y.Machine.Name); } catch { diff --git a/SabreTools.DatItems/Formats/Adjuster.cs b/SabreTools.DatItems/Formats/Adjuster.cs index d16df1e9..1d425e62 100644 --- a/SabreTools.DatItems/Formats/Adjuster.cs +++ b/SabreTools.DatItems/Formats/Adjuster.cs @@ -70,6 +70,8 @@ namespace SabreTools.DatItems.Formats public Adjuster() { _internal = new Models.Internal.Adjuster(); + Machine = new Machine(); + Name = string.Empty; ItemType = ItemType.Adjuster; } @@ -86,7 +88,7 @@ namespace SabreTools.DatItems.Formats ItemType = this.ItemType, DupeType = this.DupeType, - Machine = this.Machine?.Clone() as Machine, + Machine = this.Machine.Clone() as Machine ?? new Machine(), Source = this.Source?.Clone() as Source, Remove = this.Remove, diff --git a/SabreTools.DatItems/Formats/Analog.cs b/SabreTools.DatItems/Formats/Analog.cs index 7878ff60..260d62c8 100644 --- a/SabreTools.DatItems/Formats/Analog.cs +++ b/SabreTools.DatItems/Formats/Analog.cs @@ -32,6 +32,8 @@ namespace SabreTools.DatItems.Formats public Analog() { _internal = new Models.Internal.Analog(); + Machine = new Machine(); + ItemType = ItemType.Analog; } @@ -47,7 +49,7 @@ namespace SabreTools.DatItems.Formats ItemType = this.ItemType, DupeType = this.DupeType, - Machine = this.Machine?.Clone() as Machine, + Machine = this.Machine.Clone() as Machine ?? new Machine(), Source = this.Source?.Clone() as Source, Remove = this.Remove, diff --git a/SabreTools.DatItems/Formats/Archive.cs b/SabreTools.DatItems/Formats/Archive.cs index e12a96aa..b9af7d2d 100644 --- a/SabreTools.DatItems/Formats/Archive.cs +++ b/SabreTools.DatItems/Formats/Archive.cs @@ -107,6 +107,8 @@ namespace SabreTools.DatItems.Formats public Archive() { _internal = new Models.Internal.Archive(); + Machine = new Machine(); + Name = string.Empty; ItemType = ItemType.Archive; } @@ -123,7 +125,7 @@ namespace SabreTools.DatItems.Formats ItemType = this.ItemType, DupeType = this.DupeType, - Machine = this.Machine?.Clone() as Machine, + Machine = this.Machine.Clone() as Machine ?? new Machine(), Source = this.Source?.Clone() as Source, Remove = this.Remove, diff --git a/SabreTools.DatItems/Formats/BiosSet.cs b/SabreTools.DatItems/Formats/BiosSet.cs index dfd0123b..43bf0604 100644 --- a/SabreTools.DatItems/Formats/BiosSet.cs +++ b/SabreTools.DatItems/Formats/BiosSet.cs @@ -65,6 +65,8 @@ namespace SabreTools.DatItems.Formats public BiosSet() { _internal = new Models.Internal.BiosSet(); + Machine = new Machine(); + Name = string.Empty; ItemType = ItemType.BiosSet; } @@ -81,7 +83,7 @@ namespace SabreTools.DatItems.Formats ItemType = this.ItemType, DupeType = this.DupeType, - Machine = this.Machine?.Clone() as Machine, + Machine = this.Machine.Clone() as Machine ?? new Machine(), Source = this.Source?.Clone() as Source, Remove = this.Remove, diff --git a/SabreTools.DatItems/Formats/Blank.cs b/SabreTools.DatItems/Formats/Blank.cs index 1264952f..6ac8543c 100644 --- a/SabreTools.DatItems/Formats/Blank.cs +++ b/SabreTools.DatItems/Formats/Blank.cs @@ -32,7 +32,7 @@ namespace SabreTools.DatItems.Formats ItemType = this.ItemType, DupeType = this.DupeType, - Machine = this.Machine?.Clone() as Machine, + Machine = this.Machine.Clone() as Machine ?? new Machine(), Source = this.Source?.Clone() as Source, Remove = this.Remove, }; diff --git a/SabreTools.DatItems/Formats/Chip.cs b/SabreTools.DatItems/Formats/Chip.cs index e3902a6d..38ed0133 100644 --- a/SabreTools.DatItems/Formats/Chip.cs +++ b/SabreTools.DatItems/Formats/Chip.cs @@ -81,6 +81,8 @@ namespace SabreTools.DatItems.Formats public Chip() { _internal = new Models.Internal.Chip(); + Machine = new Machine(); + Name = string.Empty; ItemType = ItemType.Chip; } @@ -97,7 +99,7 @@ namespace SabreTools.DatItems.Formats ItemType = this.ItemType, DupeType = this.DupeType, - Machine = this.Machine?.Clone() as Machine, + Machine = this.Machine.Clone() as Machine ?? new Machine(), Source = this.Source?.Clone() as Source, Remove = this.Remove, diff --git a/SabreTools.DatItems/Formats/Condition.cs b/SabreTools.DatItems/Formats/Condition.cs index ca340dbd..ce49a71a 100644 --- a/SabreTools.DatItems/Formats/Condition.cs +++ b/SabreTools.DatItems/Formats/Condition.cs @@ -68,6 +68,8 @@ namespace SabreTools.DatItems.Formats public Condition() { _internal = new Models.Internal.Condition(); + Machine = new Machine(); + ItemType = ItemType.Condition; } @@ -83,7 +85,7 @@ namespace SabreTools.DatItems.Formats ItemType = this.ItemType, DupeType = this.DupeType, - Machine = this.Machine?.Clone() as Machine, + Machine = this.Machine.Clone() as Machine ?? new Machine(), Source = this.Source?.Clone() as Source, Remove = this.Remove, diff --git a/SabreTools.DatItems/Formats/ConfLocation.cs b/SabreTools.DatItems/Formats/ConfLocation.cs index 01d24452..aa81c744 100644 --- a/SabreTools.DatItems/Formats/ConfLocation.cs +++ b/SabreTools.DatItems/Formats/ConfLocation.cs @@ -68,6 +68,8 @@ namespace SabreTools.DatItems.Formats public ConfLocation() { _internal = new Models.Internal.ConfLocation(); + Machine = new Machine(); + Name = string.Empty; ItemType = ItemType.ConfLocation; } @@ -84,7 +86,7 @@ namespace SabreTools.DatItems.Formats ItemType = this.ItemType, DupeType = this.DupeType, - Machine = this.Machine?.Clone() as Machine, + Machine = this.Machine.Clone() as Machine ?? new Machine(), Source = this.Source?.Clone() as Source, Remove = this.Remove, diff --git a/SabreTools.DatItems/Formats/ConfSetting.cs b/SabreTools.DatItems/Formats/ConfSetting.cs index 825ffcdb..1405d180 100644 --- a/SabreTools.DatItems/Formats/ConfSetting.cs +++ b/SabreTools.DatItems/Formats/ConfSetting.cs @@ -80,6 +80,8 @@ namespace SabreTools.DatItems.Formats public ConfSetting() { _internal = new Models.Internal.ConfSetting(); + Machine = new Machine(); + Name = string.Empty; ItemType = ItemType.ConfSetting; } @@ -96,7 +98,7 @@ namespace SabreTools.DatItems.Formats ItemType = this.ItemType, DupeType = this.DupeType, - Machine = this.Machine?.Clone() as Machine, + Machine = this.Machine.Clone() as Machine ?? new Machine(), Source = this.Source?.Clone() as Source, Remove = this.Remove, diff --git a/SabreTools.DatItems/Formats/Configuration.cs b/SabreTools.DatItems/Formats/Configuration.cs index d237de43..5afb2361 100644 --- a/SabreTools.DatItems/Formats/Configuration.cs +++ b/SabreTools.DatItems/Formats/Configuration.cs @@ -103,6 +103,8 @@ namespace SabreTools.DatItems.Formats public Configuration() { _internal = new Models.Internal.Configuration(); + Machine = new Machine(); + Name = string.Empty; ItemType = ItemType.Configuration; } @@ -119,7 +121,7 @@ namespace SabreTools.DatItems.Formats ItemType = this.ItemType, DupeType = this.DupeType, - Machine = this.Machine?.Clone() as Machine, + Machine = this.Machine.Clone() as Machine ?? new Machine(), Source = this.Source?.Clone() as Source, Remove = this.Remove, diff --git a/SabreTools.DatItems/Formats/Control.cs b/SabreTools.DatItems/Formats/Control.cs index e40eceb6..ea301287 100644 --- a/SabreTools.DatItems/Formats/Control.cs +++ b/SabreTools.DatItems/Formats/Control.cs @@ -172,6 +172,8 @@ namespace SabreTools.DatItems.Formats public Control() { _internal = new Models.Internal.Control(); + Machine = new Machine(); + ItemType = ItemType.Control; } @@ -187,7 +189,7 @@ namespace SabreTools.DatItems.Formats ItemType = this.ItemType, DupeType = this.DupeType, - Machine = this.Machine?.Clone() as Machine, + Machine = this.Machine.Clone() as Machine ?? new Machine(), Source = this.Source?.Clone() as Source, Remove = this.Remove, diff --git a/SabreTools.DatItems/Formats/DataArea.cs b/SabreTools.DatItems/Formats/DataArea.cs index d9f20b57..ca2cfccc 100644 --- a/SabreTools.DatItems/Formats/DataArea.cs +++ b/SabreTools.DatItems/Formats/DataArea.cs @@ -83,6 +83,8 @@ namespace SabreTools.DatItems.Formats public DataArea() { _internal = new Models.Internal.DataArea(); + Machine = new Machine(); + Name = string.Empty; ItemType = ItemType.DataArea; } @@ -99,7 +101,7 @@ namespace SabreTools.DatItems.Formats ItemType = this.ItemType, DupeType = this.DupeType, - Machine = this.Machine?.Clone() as Machine, + Machine = this.Machine.Clone() as Machine ?? new Machine(), Source = this.Source?.Clone() as Source, Remove = this.Remove, diff --git a/SabreTools.DatItems/Formats/Device.cs b/SabreTools.DatItems/Formats/Device.cs index 74566311..d243a95b 100644 --- a/SabreTools.DatItems/Formats/Device.cs +++ b/SabreTools.DatItems/Formats/Device.cs @@ -110,6 +110,8 @@ namespace SabreTools.DatItems.Formats public Device() { _internal = new Models.Internal.Device(); + Machine = new Machine(); + ItemType = ItemType.Device; } @@ -125,7 +127,7 @@ namespace SabreTools.DatItems.Formats ItemType = this.ItemType, DupeType = this.DupeType, - Machine = this.Machine?.Clone() as Machine, + Machine = this.Machine.Clone() as Machine ?? new Machine(), Source = this.Source?.Clone() as Source, Remove = this.Remove, diff --git a/SabreTools.DatItems/Formats/DeviceReference.cs b/SabreTools.DatItems/Formats/DeviceReference.cs index 3805a8e0..098f69e6 100644 --- a/SabreTools.DatItems/Formats/DeviceReference.cs +++ b/SabreTools.DatItems/Formats/DeviceReference.cs @@ -42,6 +42,8 @@ namespace SabreTools.DatItems.Formats public DeviceReference() { _internal = new Models.Internal.DeviceRef(); + Machine = new Machine(); + Name = string.Empty; ItemType = ItemType.DeviceReference; } @@ -58,7 +60,7 @@ namespace SabreTools.DatItems.Formats ItemType = this.ItemType, DupeType = this.DupeType, - Machine = this.Machine?.Clone() as Machine, + Machine = this.Machine.Clone() as Machine ?? new Machine(), Source = this.Source?.Clone() as Source, Remove = this.Remove, diff --git a/SabreTools.DatItems/Formats/DipLocation.cs b/SabreTools.DatItems/Formats/DipLocation.cs index 3efb5804..44d2bf9c 100644 --- a/SabreTools.DatItems/Formats/DipLocation.cs +++ b/SabreTools.DatItems/Formats/DipLocation.cs @@ -68,6 +68,8 @@ namespace SabreTools.DatItems.Formats public DipLocation() { _internal = new Models.Internal.DipLocation(); + Machine = new Machine(); + Name = string.Empty; ItemType = ItemType.DipLocation; } @@ -84,7 +86,7 @@ namespace SabreTools.DatItems.Formats ItemType = this.ItemType, DupeType = this.DupeType, - Machine = this.Machine?.Clone() as Machine, + Machine = this.Machine.Clone() as Machine ?? new Machine(), Source = this.Source?.Clone() as Source, Remove = this.Remove, diff --git a/SabreTools.DatItems/Formats/DipSwitch.cs b/SabreTools.DatItems/Formats/DipSwitch.cs index 2725e6c7..b8411d8e 100644 --- a/SabreTools.DatItems/Formats/DipSwitch.cs +++ b/SabreTools.DatItems/Formats/DipSwitch.cs @@ -129,6 +129,8 @@ namespace SabreTools.DatItems.Formats public DipSwitch() { _internal = new Models.Internal.DipSwitch(); + Machine = new Machine(); + Name = string.Empty; ItemType = ItemType.DipSwitch; } @@ -145,7 +147,7 @@ namespace SabreTools.DatItems.Formats ItemType = this.ItemType, DupeType = this.DupeType, - Machine = this.Machine?.Clone() as Machine, + Machine = this.Machine.Clone() as Machine ?? new Machine(), Source = this.Source?.Clone() as Source, Remove = this.Remove, diff --git a/SabreTools.DatItems/Formats/DipValue.cs b/SabreTools.DatItems/Formats/DipValue.cs index e24ad9e1..f1e50886 100644 --- a/SabreTools.DatItems/Formats/DipValue.cs +++ b/SabreTools.DatItems/Formats/DipValue.cs @@ -80,6 +80,8 @@ namespace SabreTools.DatItems.Formats public DipValue() { _internal = new Models.Internal.DipValue(); + Machine = new Machine(); + Name = string.Empty; ItemType = ItemType.DipValue; } @@ -96,7 +98,7 @@ namespace SabreTools.DatItems.Formats ItemType = this.ItemType, DupeType = this.DupeType, - Machine = this.Machine?.Clone() as Machine, + Machine = this.Machine.Clone() as Machine ?? new Machine(), Source = this.Source?.Clone() as Source, Remove = this.Remove, diff --git a/SabreTools.DatItems/Formats/Disk.cs b/SabreTools.DatItems/Formats/Disk.cs index 590b496d..93fcee5b 100644 --- a/SabreTools.DatItems/Formats/Disk.cs +++ b/SabreTools.DatItems/Formats/Disk.cs @@ -186,6 +186,8 @@ namespace SabreTools.DatItems.Formats public Disk() { _internal = new Models.Internal.Disk(); + Machine = new Machine(); + Name = string.Empty; ItemType = ItemType.Disk; DupeType = 0x00; @@ -198,6 +200,8 @@ namespace SabreTools.DatItems.Formats public Disk(BaseFile baseFile) { _internal = new Models.Internal.Disk(); + Machine = new Machine(); + Name = baseFile.Filename; MD5 = TextHelper.ByteArrayToString(baseFile.MD5); SHA1 = TextHelper.ByteArrayToString(baseFile.SHA1); @@ -219,7 +223,7 @@ namespace SabreTools.DatItems.Formats ItemType = this.ItemType, DupeType = this.DupeType, - Machine = this.Machine?.Clone() as Machine, + Machine = this.Machine.Clone() as Machine ?? new Machine(), Source = this.Source?.Clone() as Source, Remove = this.Remove, @@ -235,7 +239,7 @@ namespace SabreTools.DatItems.Formats return new BaseFile() { Filename = this.Name, - Parent = this.Machine?.Name, + Parent = this.Machine.Name, MD5 = TextHelper.StringToByteArray(this.MD5), SHA1 = TextHelper.StringToByteArray(this.SHA1), }; @@ -252,7 +256,7 @@ namespace SabreTools.DatItems.Formats ItemType = ItemType.Rom, DupeType = this.DupeType, - Machine = this.Machine?.Clone() as Machine, + Machine = this.Machine.Clone() as Machine ?? new Machine(), Source = this.Source?.Clone() as Source, Remove = this.Remove, diff --git a/SabreTools.DatItems/Formats/DiskArea.cs b/SabreTools.DatItems/Formats/DiskArea.cs index 9d0a678f..ea9c2ee3 100644 --- a/SabreTools.DatItems/Formats/DiskArea.cs +++ b/SabreTools.DatItems/Formats/DiskArea.cs @@ -43,6 +43,8 @@ namespace SabreTools.DatItems.Formats public DiskArea() { _internal = new Models.Internal.DiskArea(); + Machine = new Machine(); + Name = string.Empty; ItemType = ItemType.DiskArea; } @@ -59,7 +61,7 @@ namespace SabreTools.DatItems.Formats ItemType = this.ItemType, DupeType = this.DupeType, - Machine = this.Machine?.Clone() as Machine, + Machine = this.Machine.Clone() as Machine ?? new Machine(), Source = this.Source?.Clone() as Source, Remove = this.Remove, diff --git a/SabreTools.DatItems/Formats/Display.cs b/SabreTools.DatItems/Formats/Display.cs index cd95f2c8..3af82aff 100644 --- a/SabreTools.DatItems/Formats/Display.cs +++ b/SabreTools.DatItems/Formats/Display.cs @@ -204,6 +204,8 @@ namespace SabreTools.DatItems.Formats public Display() { _internal = new Models.Internal.Display(); + Machine = new Machine(); + ItemType = ItemType.Display; } @@ -219,7 +221,7 @@ namespace SabreTools.DatItems.Formats ItemType = this.ItemType, DupeType = this.DupeType, - Machine = this.Machine?.Clone() as Machine, + Machine = this.Machine.Clone() as Machine ?? new Machine(), Source = this.Source?.Clone() as Source, Remove = this.Remove, diff --git a/SabreTools.DatItems/Formats/Driver.cs b/SabreTools.DatItems/Formats/Driver.cs index 08536174..b140bcec 100644 --- a/SabreTools.DatItems/Formats/Driver.cs +++ b/SabreTools.DatItems/Formats/Driver.cs @@ -135,6 +135,8 @@ namespace SabreTools.DatItems.Formats public Driver() { _internal = new Models.Internal.Driver(); + Machine = new Machine(); + ItemType = ItemType.Driver; } @@ -150,7 +152,7 @@ namespace SabreTools.DatItems.Formats ItemType = this.ItemType, DupeType = this.DupeType, - Machine = this.Machine?.Clone() as Machine, + Machine = this.Machine.Clone() as Machine ?? new Machine(), Source = this.Source?.Clone() as Source, Remove = this.Remove, diff --git a/SabreTools.DatItems/Formats/Extension.cs b/SabreTools.DatItems/Formats/Extension.cs index 2ad193e6..80a67b61 100644 --- a/SabreTools.DatItems/Formats/Extension.cs +++ b/SabreTools.DatItems/Formats/Extension.cs @@ -42,6 +42,8 @@ namespace SabreTools.DatItems.Formats public Extension() { _internal = new Models.Internal.Extension(); + Machine = new Machine(); + Name = string.Empty; ItemType = ItemType.Extension; } @@ -58,7 +60,7 @@ namespace SabreTools.DatItems.Formats ItemType = this.ItemType, DupeType = this.DupeType, - Machine = this.Machine?.Clone() as Machine, + Machine = this.Machine.Clone() as Machine ?? new Machine(), Source = this.Source?.Clone() as Source, Remove = this.Remove, diff --git a/SabreTools.DatItems/Formats/Feature.cs b/SabreTools.DatItems/Formats/Feature.cs index 4044f520..c02166c3 100644 --- a/SabreTools.DatItems/Formats/Feature.cs +++ b/SabreTools.DatItems/Formats/Feature.cs @@ -66,6 +66,8 @@ namespace SabreTools.DatItems.Formats public Feature() { _internal = new Models.Internal.Feature(); + Machine = new Machine(); + ItemType = ItemType.Feature; } @@ -81,7 +83,7 @@ namespace SabreTools.DatItems.Formats ItemType = this.ItemType, DupeType = this.DupeType, - Machine = this.Machine?.Clone() as Machine, + Machine = this.Machine.Clone() as Machine ?? new Machine(), Source = this.Source?.Clone() as Source, Remove = this.Remove, diff --git a/SabreTools.DatItems/Formats/File.cs b/SabreTools.DatItems/Formats/File.cs index 280bc282..7fa9528a 100644 --- a/SabreTools.DatItems/Formats/File.cs +++ b/SabreTools.DatItems/Formats/File.cs @@ -132,7 +132,7 @@ namespace SabreTools.DatItems.Formats ItemType = this.ItemType, DupeType = this.DupeType, - Machine = this.Machine?.Clone() as Machine, + Machine = this.Machine.Clone() as Machine ?? new Machine(), Source = this.Source?.Clone() as Source, Remove = this.Remove, @@ -154,7 +154,7 @@ namespace SabreTools.DatItems.Formats { return new BaseFile() { - Parent = this.Machine?.Name, + Parent = this.Machine.Name, CRC = this._crc, MD5 = this._md5, SHA1 = this._sha1, @@ -174,7 +174,7 @@ namespace SabreTools.DatItems.Formats ItemType = ItemType.Rom, DupeType = this.DupeType, - Machine = this.Machine?.Clone() as Machine, + Machine = this.Machine.Clone() as Machine ?? new Machine(), Source = this.Source?.Clone() as Source, Remove = this.Remove, diff --git a/SabreTools.DatItems/Formats/Info.cs b/SabreTools.DatItems/Formats/Info.cs index 1dfe76f1..59c421d8 100644 --- a/SabreTools.DatItems/Formats/Info.cs +++ b/SabreTools.DatItems/Formats/Info.cs @@ -52,6 +52,8 @@ namespace SabreTools.DatItems.Formats public Info() { _internal = new Models.Internal.Info(); + Machine = new Machine(); + Name = string.Empty; ItemType = ItemType.Info; } @@ -68,7 +70,7 @@ namespace SabreTools.DatItems.Formats ItemType = this.ItemType, DupeType = this.DupeType, - Machine = this.Machine?.Clone() as Machine, + Machine = this.Machine.Clone() as Machine ?? new Machine(), Source = this.Source?.Clone() as Source, Remove = this.Remove, diff --git a/SabreTools.DatItems/Formats/Input.cs b/SabreTools.DatItems/Formats/Input.cs index e0308a84..8d094d17 100644 --- a/SabreTools.DatItems/Formats/Input.cs +++ b/SabreTools.DatItems/Formats/Input.cs @@ -89,6 +89,8 @@ namespace SabreTools.DatItems.Formats public Input() { _internal = new Models.Internal.Input(); + Machine = new Machine(); + ItemType = ItemType.Input; } @@ -104,7 +106,7 @@ namespace SabreTools.DatItems.Formats ItemType = this.ItemType, DupeType = this.DupeType, - Machine = this.Machine?.Clone() as Machine, + Machine = this.Machine.Clone() as Machine ?? new Machine(), Source = this.Source?.Clone() as Source, Remove = this.Remove, diff --git a/SabreTools.DatItems/Formats/Instance.cs b/SabreTools.DatItems/Formats/Instance.cs index b2cbd228..96d73a5b 100644 --- a/SabreTools.DatItems/Formats/Instance.cs +++ b/SabreTools.DatItems/Formats/Instance.cs @@ -52,6 +52,8 @@ namespace SabreTools.DatItems.Formats public Instance() { _internal = new Models.Internal.Instance(); + Machine = new Machine(); + Name = string.Empty; ItemType = ItemType.Instance; } @@ -68,7 +70,7 @@ namespace SabreTools.DatItems.Formats ItemType = this.ItemType, DupeType = this.DupeType, - Machine = this.Machine?.Clone() as Machine, + Machine = this.Machine.Clone() as Machine ?? new Machine(), Source = this.Source?.Clone() as Source, Remove = this.Remove, diff --git a/SabreTools.DatItems/Formats/Media.cs b/SabreTools.DatItems/Formats/Media.cs index 89de1854..fa74d5dd 100644 --- a/SabreTools.DatItems/Formats/Media.cs +++ b/SabreTools.DatItems/Formats/Media.cs @@ -85,6 +85,8 @@ namespace SabreTools.DatItems.Formats public Media() { _internal = new Models.Internal.Media(); + Machine = new Machine(); + Name = string.Empty; ItemType = ItemType.Media; DupeType = 0x00; @@ -97,6 +99,8 @@ namespace SabreTools.DatItems.Formats public Media(BaseFile baseFile) { _internal = new Models.Internal.Media(); + Machine = new Machine(); + Name = baseFile.Filename; MD5 = TextHelper.ByteArrayToString(baseFile.MD5); SHA1 = TextHelper.ByteArrayToString(baseFile.SHA1); @@ -119,7 +123,7 @@ namespace SabreTools.DatItems.Formats ItemType = this.ItemType, DupeType = this.DupeType, - Machine = this.Machine?.Clone() as Machine, + Machine = this.Machine.Clone() as Machine ?? new Machine(), Source = this.Source?.Clone() as Source, Remove = this.Remove, @@ -135,7 +139,7 @@ namespace SabreTools.DatItems.Formats return new BaseFile() { Filename = this.Name, - Parent = this.Machine?.Name, + Parent = this.Machine.Name, MD5 = TextHelper.StringToByteArray(this.MD5), SHA1 = TextHelper.StringToByteArray(this.SHA1), SHA256 = TextHelper.StringToByteArray(this.SHA256), @@ -154,7 +158,7 @@ namespace SabreTools.DatItems.Formats ItemType = ItemType.Rom, DupeType = this.DupeType, - Machine = this.Machine?.Clone() as Machine, + Machine = this.Machine.Clone() as Machine ?? new Machine(), Source = this.Source?.Clone() as Source, Remove = this.Remove, }; diff --git a/SabreTools.DatItems/Formats/Part.cs b/SabreTools.DatItems/Formats/Part.cs index e9903e7b..93072fe4 100644 --- a/SabreTools.DatItems/Formats/Part.cs +++ b/SabreTools.DatItems/Formats/Part.cs @@ -59,6 +59,8 @@ namespace SabreTools.DatItems.Formats public Part() { _internal = new Models.Internal.Part(); + Machine = new Machine(); + Name = string.Empty; ItemType = ItemType.Part; } @@ -75,7 +77,7 @@ namespace SabreTools.DatItems.Formats ItemType = this.ItemType, DupeType = this.DupeType, - Machine = this.Machine?.Clone() as Machine, + Machine = this.Machine.Clone() as Machine ?? new Machine(), Source = this.Source?.Clone() as Source, Remove = this.Remove, diff --git a/SabreTools.DatItems/Formats/PartFeature.cs b/SabreTools.DatItems/Formats/PartFeature.cs index 45b87f50..959c1dc6 100644 --- a/SabreTools.DatItems/Formats/PartFeature.cs +++ b/SabreTools.DatItems/Formats/PartFeature.cs @@ -52,6 +52,8 @@ namespace SabreTools.DatItems.Formats public PartFeature() { _internal = new Models.Internal.Feature(); + Machine = new Machine(); + Name = string.Empty; ItemType = ItemType.PartFeature; } @@ -68,7 +70,7 @@ namespace SabreTools.DatItems.Formats ItemType = this.ItemType, DupeType = this.DupeType, - Machine = this.Machine?.Clone() as Machine, + Machine = this.Machine.Clone() as Machine ?? new Machine(), Source = this.Source?.Clone() as Source, Remove = this.Remove, diff --git a/SabreTools.DatItems/Formats/Port.cs b/SabreTools.DatItems/Formats/Port.cs index b8ba7952..a8474cd9 100644 --- a/SabreTools.DatItems/Formats/Port.cs +++ b/SabreTools.DatItems/Formats/Port.cs @@ -47,6 +47,8 @@ namespace SabreTools.DatItems.Formats public Port() { _internal = new Models.Internal.Port(); + Machine = new Machine(); + ItemType = ItemType.Port; } @@ -62,7 +64,7 @@ namespace SabreTools.DatItems.Formats ItemType = this.ItemType, DupeType = this.DupeType, - Machine = this.Machine?.Clone() as Machine, + Machine = this.Machine.Clone() as Machine ?? new Machine(), Source = this.Source?.Clone() as Source, Remove = this.Remove, diff --git a/SabreTools.DatItems/Formats/RamOption.cs b/SabreTools.DatItems/Formats/RamOption.cs index 841318c1..e0922eec 100644 --- a/SabreTools.DatItems/Formats/RamOption.cs +++ b/SabreTools.DatItems/Formats/RamOption.cs @@ -65,6 +65,8 @@ namespace SabreTools.DatItems.Formats public RamOption() { _internal = new Models.Internal.RamOption(); + Machine = new Machine(); + Name = string.Empty; ItemType = ItemType.RamOption; } @@ -81,7 +83,7 @@ namespace SabreTools.DatItems.Formats ItemType = this.ItemType, DupeType = this.DupeType, - Machine = this.Machine?.Clone() as Machine, + Machine = this.Machine.Clone() as Machine ?? new Machine(), Source = this.Source?.Clone() as Source, Remove = this.Remove, diff --git a/SabreTools.DatItems/Formats/Release.cs b/SabreTools.DatItems/Formats/Release.cs index 320425a8..00115a0c 100644 --- a/SabreTools.DatItems/Formats/Release.cs +++ b/SabreTools.DatItems/Formats/Release.cs @@ -85,6 +85,8 @@ namespace SabreTools.DatItems.Formats public Release() { _internal = new Models.Internal.Release(); + Machine = new Machine(); + Name = string.Empty; ItemType = ItemType.Release; Region = string.Empty; @@ -105,7 +107,7 @@ namespace SabreTools.DatItems.Formats ItemType = this.ItemType, DupeType = this.DupeType, - Machine = this.Machine?.Clone() as Machine, + Machine = this.Machine.Clone() as Machine ?? new Machine(), Source = this.Source?.Clone() as Source, Remove = this.Remove, diff --git a/SabreTools.DatItems/Formats/ReleaseDetails.cs b/SabreTools.DatItems/Formats/ReleaseDetails.cs index 94696135..a3c97774 100644 --- a/SabreTools.DatItems/Formats/ReleaseDetails.cs +++ b/SabreTools.DatItems/Formats/ReleaseDetails.cs @@ -131,7 +131,7 @@ namespace SabreTools.DatItems.Formats ItemType = this.ItemType, DupeType = this.DupeType, - Machine = this.Machine?.Clone() as Machine, + Machine = this.Machine.Clone() as Machine ?? new Machine(), Source = this.Source?.Clone() as Source, Remove = this.Remove, diff --git a/SabreTools.DatItems/Formats/Rom.cs b/SabreTools.DatItems/Formats/Rom.cs index f5d73c50..265eb5ef 100644 --- a/SabreTools.DatItems/Formats/Rom.cs +++ b/SabreTools.DatItems/Formats/Rom.cs @@ -459,6 +459,8 @@ namespace SabreTools.DatItems.Formats public Rom() { _internal = new Models.Internal.Rom(); + Machine = new Machine(); + Name = null; ItemType = ItemType.Rom; DupeType = 0x00; @@ -493,6 +495,8 @@ namespace SabreTools.DatItems.Formats public Rom(BaseFile baseFile) { _internal = new Models.Internal.Rom(); + Machine = new Machine(); + Name = baseFile.Filename; Size = baseFile.Size; CRC = TextHelper.ByteArrayToString(baseFile.CRC); @@ -534,7 +538,7 @@ namespace SabreTools.DatItems.Formats ItemType = this.ItemType, DupeType = this.DupeType, - Machine = this.Machine?.Clone() as Machine, + Machine = this.Machine.Clone() as Machine ?? new Machine(), Source = this.Source?.Clone() as Source, Remove = this.Remove, @@ -550,7 +554,7 @@ namespace SabreTools.DatItems.Formats return new BaseFile() { Filename = this.Name, - Parent = this.Machine?.Name, + Parent = this.Machine.Name, Date = this.Date, Size = this.Size, CRC = TextHelper.StringToByteArray(this.CRC), diff --git a/SabreTools.DatItems/Formats/Sample.cs b/SabreTools.DatItems/Formats/Sample.cs index d30f7c06..2fd22cee 100644 --- a/SabreTools.DatItems/Formats/Sample.cs +++ b/SabreTools.DatItems/Formats/Sample.cs @@ -42,6 +42,8 @@ namespace SabreTools.DatItems.Formats public Sample() { _internal = new Models.Internal.Sample(); + Machine = new Machine(); + Name = string.Empty; ItemType = ItemType.Sample; } @@ -58,7 +60,7 @@ namespace SabreTools.DatItems.Formats ItemType = this.ItemType, DupeType = this.DupeType, - Machine = this.Machine?.Clone() as Machine, + Machine = this.Machine.Clone() as Machine ?? new Machine(), Source = this.Source?.Clone() as Source, Remove = this.Remove, diff --git a/SabreTools.DatItems/Formats/Serials.cs b/SabreTools.DatItems/Formats/Serials.cs index 697231a8..5f35fb70 100644 --- a/SabreTools.DatItems/Formats/Serials.cs +++ b/SabreTools.DatItems/Formats/Serials.cs @@ -121,7 +121,7 @@ namespace SabreTools.DatItems.Formats ItemType = this.ItemType, DupeType = this.DupeType, - Machine = this.Machine?.Clone() as Machine, + Machine = this.Machine.Clone() as Machine ?? new Machine(), Source = this.Source?.Clone() as Source, Remove = this.Remove, diff --git a/SabreTools.DatItems/Formats/SharedFeature.cs b/SabreTools.DatItems/Formats/SharedFeature.cs index 75d3359f..30bc07e1 100644 --- a/SabreTools.DatItems/Formats/SharedFeature.cs +++ b/SabreTools.DatItems/Formats/SharedFeature.cs @@ -52,6 +52,8 @@ namespace SabreTools.DatItems.Formats public SharedFeature() { _internal = new Models.Internal.SharedFeat(); + Machine = new Machine(); + Name = string.Empty; ItemType = ItemType.SharedFeature; } @@ -68,7 +70,7 @@ namespace SabreTools.DatItems.Formats ItemType = this.ItemType, DupeType = this.DupeType, - Machine = this.Machine?.Clone() as Machine, + Machine = this.Machine.Clone() as Machine ?? new Machine(), Source = this.Source?.Clone() as Source, Remove = this.Remove, diff --git a/SabreTools.DatItems/Formats/Slot.cs b/SabreTools.DatItems/Formats/Slot.cs index 9fa64c34..296c67a7 100644 --- a/SabreTools.DatItems/Formats/Slot.cs +++ b/SabreTools.DatItems/Formats/Slot.cs @@ -57,6 +57,8 @@ namespace SabreTools.DatItems.Formats public Slot() { _internal = new Models.Internal.Slot(); + Machine = new Machine(); + Name = string.Empty; ItemType = ItemType.Slot; } @@ -73,7 +75,7 @@ namespace SabreTools.DatItems.Formats ItemType = this.ItemType, DupeType = this.DupeType, - Machine = this.Machine?.Clone() as Machine, + Machine = this.Machine.Clone() as Machine ?? new Machine(), Source = this.Source?.Clone() as Source, Remove = this.Remove, diff --git a/SabreTools.DatItems/Formats/SlotOption.cs b/SabreTools.DatItems/Formats/SlotOption.cs index 70c8d293..1bfcf5c8 100644 --- a/SabreTools.DatItems/Formats/SlotOption.cs +++ b/SabreTools.DatItems/Formats/SlotOption.cs @@ -65,6 +65,8 @@ namespace SabreTools.DatItems.Formats public SlotOption() { _internal = new Models.Internal.SlotOption(); + Machine = new Machine(); + Name = string.Empty; ItemType = ItemType.SlotOption; } @@ -81,7 +83,7 @@ namespace SabreTools.DatItems.Formats ItemType = this.ItemType, DupeType = this.DupeType, - Machine = this.Machine?.Clone() as Machine, + Machine = this.Machine.Clone() as Machine ?? new Machine(), Source = this.Source?.Clone() as Source, Remove = this.Remove, diff --git a/SabreTools.DatItems/Formats/SoftwareList.cs b/SabreTools.DatItems/Formats/SoftwareList.cs index 64fa7397..d6305a43 100644 --- a/SabreTools.DatItems/Formats/SoftwareList.cs +++ b/SabreTools.DatItems/Formats/SoftwareList.cs @@ -85,6 +85,8 @@ namespace SabreTools.DatItems.Formats public SoftwareList() { _internal = new Models.Internal.SoftwareList(); + Machine = new Machine(); + Name = string.Empty; ItemType = ItemType.SoftwareList; } @@ -100,7 +102,7 @@ namespace SabreTools.DatItems.Formats ItemType = this.ItemType, DupeType = this.DupeType, - Machine = this.Machine?.Clone() as Machine, + Machine = this.Machine.Clone() as Machine ?? new Machine(), Source = this.Source?.Clone() as Source, Remove = this.Remove, diff --git a/SabreTools.DatItems/Formats/Sound.cs b/SabreTools.DatItems/Formats/Sound.cs index 4b59d94c..c020a192 100644 --- a/SabreTools.DatItems/Formats/Sound.cs +++ b/SabreTools.DatItems/Formats/Sound.cs @@ -35,6 +35,8 @@ namespace SabreTools.DatItems.Formats public Sound() { _internal = new Models.Internal.Sound(); + Machine = new Machine(); + ItemType = ItemType.Sound; } @@ -50,7 +52,7 @@ namespace SabreTools.DatItems.Formats ItemType = this.ItemType, DupeType = this.DupeType, - Machine = this.Machine?.Clone() as Machine, + Machine = this.Machine.Clone() as Machine ?? new Machine(), Source = this.Source?.Clone() as Source, Remove = this.Remove, diff --git a/SabreTools.DatItems/Formats/SourceDetails.cs b/SabreTools.DatItems/Formats/SourceDetails.cs index ad8fdf52..a20ff661 100644 --- a/SabreTools.DatItems/Formats/SourceDetails.cs +++ b/SabreTools.DatItems/Formats/SourceDetails.cs @@ -158,7 +158,7 @@ namespace SabreTools.DatItems.Formats ItemType = this.ItemType, DupeType = this.DupeType, - Machine = this.Machine?.Clone() as Machine, + Machine = this.Machine.Clone() as Machine ?? new Machine(), Source = this.Source?.Clone() as Source, Remove = this.Remove,