diff --git a/SabreTools.DatFiles/DatFile.FromMetadata.cs b/SabreTools.DatFiles/DatFile.FromMetadata.cs index 8e115d01..ddaf4dd2 100644 --- a/SabreTools.DatFiles/DatFile.FromMetadata.cs +++ b/SabreTools.DatFiles/DatFile.FromMetadata.cs @@ -320,7 +320,7 @@ namespace SabreTools.DatFiles private void ConvertMachines(Models.Metadata.Machine[]? items, string filename, int indexId, bool statsOnly) { // If the array is invalid, we can't do anything - if (items == null || !items.Any()) + if (items == null || items.Length == 0) return; // Loop through the machines and add diff --git a/SabreTools.DatFiles/DatFile.ToMetadata.cs b/SabreTools.DatFiles/DatFile.ToMetadata.cs index cb43b95f..037e9d34 100644 --- a/SabreTools.DatFiles/DatFile.ToMetadata.cs +++ b/SabreTools.DatFiles/DatFile.ToMetadata.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Linq; using SabreTools.Core.Tools; @@ -15,7 +16,7 @@ namespace SabreTools.DatFiles public Models.Metadata.MetadataFile? ConvertMetadata(bool ignoreblanks = false) { // If we don't have items, we can't do anything - if (this.Items == null || !this.Items.Any()) + if (Items == null || Items.Count == 0) return null; // Create an object to hold the data @@ -212,7 +213,7 @@ namespace SabreTools.DatFiles foreach (string key in Items.SortedKeys) { var items = Items.FilteredItems(key); - if (items == null || !items.Any()) + if (items == null || items.Count == 0) continue; // Create a machine to hold everything @@ -436,7 +437,7 @@ namespace SabreTools.DatFiles } // Handle Part, DiskItem, and DatItem mappings, if they exist - if (partMappings.Any()) + if (partMappings.Count != 0) { // Create a collection to hold the inverted Parts Dictionary partItems = []; @@ -948,7 +949,11 @@ namespace SabreTools.DatFiles private static void EnsureMachineKey(Models.Metadata.Machine machine, string key) { if (machine.Read(key) == null) +#if NET20 || NET35 || NET40 || NET452 machine[key] = new T[0]; +#else + machine[key] = Array.Empty(); +#endif } /// @@ -983,6 +988,6 @@ namespace SabreTools.DatFiles } } - #endregion +#endregion } } \ No newline at end of file diff --git a/SabreTools.DatFiles/Formats/SabreJSON.cs b/SabreTools.DatFiles/Formats/SabreJSON.cs index 0e6dbd70..3e490400 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.GetFieldValue(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.NameKey)?.ToLowerInvariant()) + if (lastgame != null && !string.Equals(lastgame, datItem.GetFieldValue(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.NameKey), StringComparison.OrdinalIgnoreCase)) SabreJSON.WriteEndGame(jtw); // If we have a new game, output the beginning of the new item - if (lastgame == null || lastgame.ToLowerInvariant() != datItem.GetFieldValue(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.NameKey)?.ToLowerInvariant()) + if (lastgame == null || !string.Equals(lastgame, datItem.GetFieldValue(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.NameKey), StringComparison.OrdinalIgnoreCase)) SabreJSON.WriteStartGame(jtw, datItem); // Check for a "null" item diff --git a/SabreTools.DatFiles/Formats/SabreXML.cs b/SabreTools.DatFiles/Formats/SabreXML.cs index ae5ff5ba..b8b63fed 100644 --- a/SabreTools.DatFiles/Formats/SabreXML.cs +++ b/SabreTools.DatFiles/Formats/SabreXML.cs @@ -227,11 +227,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.GetFieldValue(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.NameKey)?.ToLowerInvariant()) + if (lastgame != null && !string.Equals(lastgame, datItem.GetFieldValue(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.NameKey), StringComparison.OrdinalIgnoreCase)) WriteEndGame(xtw); // If we have a new game, output the beginning of the new item - if (lastgame == null || lastgame.ToLowerInvariant() != datItem.GetFieldValue(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.NameKey)?.ToLowerInvariant()) + if (lastgame == null || !string.Equals(lastgame, datItem.GetFieldValue(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.NameKey), StringComparison.OrdinalIgnoreCase)) WriteStartGame(xtw, datItem); // Check for a "null" item diff --git a/SabreTools.DatFiles/ItemDictionary.cs b/SabreTools.DatFiles/ItemDictionary.cs index dbbd2df0..df965733 100644 --- a/SabreTools.DatFiles/ItemDictionary.cs +++ b/SabreTools.DatFiles/ItemDictionary.cs @@ -191,7 +191,7 @@ namespace SabreTools.DatFiles lock (key) { // If the value is null or empty, just return - if (value == null || !value.Any()) + if (value == null || value.Count == 0) return; // Ensure the key exists diff --git a/SabreTools.DatFiles/ItemDictionaryDB.cs b/SabreTools.DatFiles/ItemDictionaryDB.cs index c1622ad8..293f9a2d 100644 --- a/SabreTools.DatFiles/ItemDictionaryDB.cs +++ b/SabreTools.DatFiles/ItemDictionaryDB.cs @@ -430,7 +430,7 @@ namespace SabreTools.DatFiles private List<(long, DatItem)> Deduplicate(List<(long, DatItem)> itemMappings) { // Check for null or blank roms first - if (itemMappings == null || !itemMappings.Any()) + if (itemMappings == null || itemMappings.Count == 0) return []; // Create output list @@ -717,7 +717,7 @@ namespace SabreTools.DatFiles #endif { var itemIndices = _buckets[bucketKeys[i]]; - if (itemIndices == null || !itemIndices.Any()) + if (itemIndices == null || itemIndices.Count == 0) #if NET40_OR_GREATER || NETCOREAPP return; #else @@ -760,7 +760,7 @@ namespace SabreTools.DatFiles #endif { var itemIndices = _buckets[bucketKeys[i]]; - if (itemIndices == null || !itemIndices.Any()) + if (itemIndices == null || itemIndices.Count == 0) { #if NET40_OR_GREATER || NETCOREAPP _buckets.TryRemove(bucketKeys[i], out _); @@ -902,7 +902,7 @@ namespace SabreTools.DatFiles DatStatistics.ResetStatistics(); // If there are no items - if (_items == null || !_items.Any()) + if (_items == null || _items.Count == 0) return; // Loop through and add