diff --git a/SabreTools.Core/Filter/FilterObject.cs b/SabreTools.Core/Filter/FilterObject.cs index df19d0ba..c7acc7d0 100644 --- a/SabreTools.Core/Filter/FilterObject.cs +++ b/SabreTools.Core/Filter/FilterObject.cs @@ -14,29 +14,17 @@ namespace SabreTools.Core.Filter /// /// Key name for the filter /// -#if NETFRAMEWORK || NETCOREAPP3_1 - public string[] Key { get; private set; } -#else - public string[] Key { get; init; } -#endif + public string[] Key { get; } /// /// Value to match in the filter /// -#if NETFRAMEWORK || NETCOREAPP3_1 - public string? Value { get; private set; } -#else - public string? Value { get; init; } -#endif + public string? Value { get; } /// /// Operation on how to match the filter /// -#if NETFRAMEWORK || NETCOREAPP3_1 - public Operation Operation { get; private set; } -#else - public Operation Operation { get; init; } -#endif + public Operation Operation { get; } public FilterObject(string filterString) { @@ -48,9 +36,9 @@ namespace SabreTools.Core.Filter if (itemName == null || fieldName == null) throw new ArgumentOutOfRangeException(nameof(filterString)); - this.Key = [itemName, fieldName]; - this.Value = value; - this.Operation = operation; + Key = [itemName, fieldName]; + Value = value; + Operation = operation; } public FilterObject(string itemField, string? value, string? operation) @@ -59,9 +47,9 @@ namespace SabreTools.Core.Filter if (itemName == null || fieldName == null) throw new ArgumentOutOfRangeException(nameof(value)); - this.Key = [itemName, fieldName]; - this.Value = value; - this.Operation = GetOperation(operation); + Key = [itemName, fieldName]; + Value = value; + Operation = GetOperation(operation); } public FilterObject(string itemField, string? value, Operation operation) @@ -70,9 +58,9 @@ namespace SabreTools.Core.Filter if (itemName == null || fieldName == null) throw new ArgumentOutOfRangeException(nameof(value)); - this.Key = [itemName, fieldName]; - this.Value = value; - this.Operation = operation; + Key = [itemName, fieldName]; + Value = value; + Operation = operation; } #region Matching @@ -82,8 +70,8 @@ namespace SabreTools.Core.Filter /// public bool Matches(DictionaryBase dictionaryBase) { - // TODO: Add validation of dictionary base type from this.Key[0] - return this.Operation switch + // TODO: Add validation of dictionary base type from Key[0] + return Operation switch { Operation.Equals => MatchesEqual(dictionaryBase), Operation.NotEquals => MatchesNotEqual(dictionaryBase), @@ -101,41 +89,41 @@ namespace SabreTools.Core.Filter private bool MatchesEqual(DictionaryBase dictionaryBase) { // If the key doesn't exist, we count it as null - if (!dictionaryBase.ContainsKey(this.Key[1])) - return this.Value == null; + if (!dictionaryBase.ContainsKey(Key[1])) + return Value == null; // If the value in the dictionary is null - string? checkValue = dictionaryBase.ReadString(this.Key[1]); + string? checkValue = dictionaryBase.ReadString(Key[1]); if (checkValue == null) - return this.Value == null; + return Value == null; // If we have both a potentally boolean check and value bool? checkValueBool = ConvertToBoolean(checkValue); - bool? matchValueBool = ConvertToBoolean(this.Value); + bool? matchValueBool = ConvertToBoolean(Value); if (checkValueBool != null && matchValueBool != null) return checkValueBool == matchValueBool; // If we have both a potentially numeric check and value - if (NumberHelper.IsNumeric(checkValue) && NumberHelper.IsNumeric(this.Value)) + if (NumberHelper.IsNumeric(checkValue) && NumberHelper.IsNumeric(Value)) { // Check Int64 values long? checkValueLong = NumberHelper.ConvertToInt64(checkValue); - long? matchValueLong = NumberHelper.ConvertToInt64(this.Value); + long? matchValueLong = NumberHelper.ConvertToInt64(Value); if (checkValueLong != null && matchValueLong != null) return checkValueLong == matchValueLong; // Check Double values double? checkValueDouble = NumberHelper.ConvertToDouble(checkValue); - double? matchValueDouble = NumberHelper.ConvertToDouble(this.Value); + double? matchValueDouble = NumberHelper.ConvertToDouble(Value); if (checkValueDouble != null && matchValueDouble != null) return checkValueDouble == matchValueDouble; } // If the value might contain valid Regex - if (this.Value != null && ContainsRegex(this.Value)) - return Regex.IsMatch(checkValue, this.Value); + if (Value != null && ContainsRegex(Value)) + return Regex.IsMatch(checkValue, Value); - return string.Equals(checkValue, this.Value, StringComparison.OrdinalIgnoreCase); + return string.Equals(checkValue, Value, StringComparison.OrdinalIgnoreCase); } /// @@ -144,41 +132,41 @@ namespace SabreTools.Core.Filter private bool MatchesNotEqual(DictionaryBase dictionaryBase) { // If the key doesn't exist, we count it as null - if (!dictionaryBase.ContainsKey(this.Key[1])) - return this.Value != null; + if (!dictionaryBase.ContainsKey(Key[1])) + return Value != null; // If the value in the dictionary is null - string? checkValue = dictionaryBase.ReadString(this.Key[1]); + string? checkValue = dictionaryBase.ReadString(Key[1]); if (checkValue == null) - return this.Value == null; + return Value == null; // If we have both a potentally boolean check and value bool? checkValueBool = ConvertToBoolean(checkValue); - bool? matchValueBool = ConvertToBoolean(this.Value); + bool? matchValueBool = ConvertToBoolean(Value); if (checkValueBool != null && matchValueBool != null) return checkValueBool != matchValueBool; // If we have both a potentially numeric check and value - if (NumberHelper.IsNumeric(checkValue) && NumberHelper.IsNumeric(this.Value)) + if (NumberHelper.IsNumeric(checkValue) && NumberHelper.IsNumeric(Value)) { // Check Int64 values long? checkValueLong = NumberHelper.ConvertToInt64(checkValue); - long? matchValueLong = NumberHelper.ConvertToInt64(this.Value); + long? matchValueLong = NumberHelper.ConvertToInt64(Value); if (checkValueLong != null && matchValueLong != null) return checkValueLong != matchValueLong; // Check Double values double? checkValueDouble = NumberHelper.ConvertToDouble(checkValue); - double? matchValueDouble = NumberHelper.ConvertToDouble(this.Value); + double? matchValueDouble = NumberHelper.ConvertToDouble(Value); if (checkValueDouble != null && matchValueDouble != null) return checkValueDouble != matchValueDouble; } // If the value might contain valid Regex - if (this.Value != null && ContainsRegex(this.Value)) - return !Regex.IsMatch(checkValue, this.Value); + if (Value != null && ContainsRegex(Value)) + return !Regex.IsMatch(checkValue, Value); - return !string.Equals(checkValue, this.Value, StringComparison.OrdinalIgnoreCase); + return !string.Equals(checkValue, Value, StringComparison.OrdinalIgnoreCase); } /// @@ -187,26 +175,26 @@ namespace SabreTools.Core.Filter private bool MatchesGreaterThan(DictionaryBase dictionaryBase) { // If the key doesn't exist, we count it as null - if (!dictionaryBase.ContainsKey(this.Key[1])) + if (!dictionaryBase.ContainsKey(Key[1])) return false; // If the value in the dictionary is null - string? checkValue = dictionaryBase.ReadString(this.Key[1]); + string? checkValue = dictionaryBase.ReadString(Key[1]); if (checkValue == null) return false; // If we have both a potentially numeric check and value - if (NumberHelper.IsNumeric(checkValue) && NumberHelper.IsNumeric(this.Value)) + if (NumberHelper.IsNumeric(checkValue) && NumberHelper.IsNumeric(Value)) { // Check Int64 values long? checkValueLong = NumberHelper.ConvertToInt64(checkValue); - long? matchValueLong = NumberHelper.ConvertToInt64(this.Value); + long? matchValueLong = NumberHelper.ConvertToInt64(Value); if (checkValueLong != null && matchValueLong != null) return checkValueLong > matchValueLong; // Check Double values double? checkValueDouble = NumberHelper.ConvertToDouble(checkValue); - double? matchValueDouble = NumberHelper.ConvertToDouble(this.Value); + double? matchValueDouble = NumberHelper.ConvertToDouble(Value); if (checkValueDouble != null && matchValueDouble != null) return checkValueDouble > matchValueDouble; } @@ -220,26 +208,26 @@ namespace SabreTools.Core.Filter private bool MatchesGreaterThanOrEqual(DictionaryBase dictionaryBase) { // If the key doesn't exist, we count it as null - if (!dictionaryBase.ContainsKey(this.Key[1])) + if (!dictionaryBase.ContainsKey(Key[1])) return false; // If the value in the dictionary is null - string? checkValue = dictionaryBase.ReadString(this.Key[1]); + string? checkValue = dictionaryBase.ReadString(Key[1]); if (checkValue == null) return false; // If we have both a potentially numeric check and value - if (NumberHelper.IsNumeric(checkValue) && NumberHelper.IsNumeric(this.Value)) + if (NumberHelper.IsNumeric(checkValue) && NumberHelper.IsNumeric(Value)) { // Check Int64 values long? checkValueLong = NumberHelper.ConvertToInt64(checkValue); - long? matchValueLong = NumberHelper.ConvertToInt64(this.Value); + long? matchValueLong = NumberHelper.ConvertToInt64(Value); if (checkValueLong != null && matchValueLong != null) return checkValueLong >= matchValueLong; // Check Double values double? checkValueDouble = NumberHelper.ConvertToDouble(checkValue); - double? matchValueDouble = NumberHelper.ConvertToDouble(this.Value); + double? matchValueDouble = NumberHelper.ConvertToDouble(Value); if (checkValueDouble != null && matchValueDouble != null) return checkValueDouble >= matchValueDouble; } @@ -253,26 +241,26 @@ namespace SabreTools.Core.Filter private bool MatchesLessThan(DictionaryBase dictionaryBase) { // If the key doesn't exist, we count it as null - if (!dictionaryBase.ContainsKey(this.Key[1])) + if (!dictionaryBase.ContainsKey(Key[1])) return false; // If the value in the dictionary is null - string? checkValue = dictionaryBase.ReadString(this.Key[1]); + string? checkValue = dictionaryBase.ReadString(Key[1]); if (checkValue == null) return false; // If we have both a potentially numeric check and value - if (NumberHelper.IsNumeric(checkValue) && NumberHelper.IsNumeric(this.Value)) + if (NumberHelper.IsNumeric(checkValue) && NumberHelper.IsNumeric(Value)) { // Check Int64 values long? checkValueLong = NumberHelper.ConvertToInt64(checkValue); - long? matchValueLong = NumberHelper.ConvertToInt64(this.Value); + long? matchValueLong = NumberHelper.ConvertToInt64(Value); if (checkValueLong != null && matchValueLong != null) return checkValueLong < matchValueLong; // Check Double values double? checkValueDouble = NumberHelper.ConvertToDouble(checkValue); - double? matchValueDouble = NumberHelper.ConvertToDouble(this.Value); + double? matchValueDouble = NumberHelper.ConvertToDouble(Value); if (checkValueDouble != null && matchValueDouble != null) return checkValueDouble < matchValueDouble; } @@ -286,26 +274,26 @@ namespace SabreTools.Core.Filter private bool MatchesLessThanOrEqual(DictionaryBase dictionaryBase) { // If the key doesn't exist, we count it as null - if (!dictionaryBase.ContainsKey(this.Key[1])) + if (!dictionaryBase.ContainsKey(Key[1])) return false; // If the value in the dictionary is null - string? checkValue = dictionaryBase.ReadString(this.Key[1]); + string? checkValue = dictionaryBase.ReadString(Key[1]); if (checkValue == null) return false; // If we have both a potentially numeric check and value - if (NumberHelper.IsNumeric(checkValue) && NumberHelper.IsNumeric(this.Value)) + if (NumberHelper.IsNumeric(checkValue) && NumberHelper.IsNumeric(Value)) { // Check Int64 values long? checkValueLong = NumberHelper.ConvertToInt64(checkValue); - long? matchValueLong = NumberHelper.ConvertToInt64(this.Value); + long? matchValueLong = NumberHelper.ConvertToInt64(Value); if (checkValueLong != null && matchValueLong != null) return checkValueLong <= matchValueLong; // Check Double values double? checkValueDouble = NumberHelper.ConvertToDouble(checkValue); - double? matchValueDouble = NumberHelper.ConvertToDouble(this.Value); + double? matchValueDouble = NumberHelper.ConvertToDouble(Value); if (checkValueDouble != null && matchValueDouble != null) return checkValueDouble <= matchValueDouble; } diff --git a/SabreTools.Core/Filter/FilterRunner.cs b/SabreTools.Core/Filter/FilterRunner.cs index 820041ee..bdf36da2 100644 --- a/SabreTools.Core/Filter/FilterRunner.cs +++ b/SabreTools.Core/Filter/FilterRunner.cs @@ -13,11 +13,7 @@ namespace SabreTools.Core.Filter /// /// Set of filters to be run against an object /// -#if NETFRAMEWORK || NETCOREAPP3_1 - public FilterObject[] Filters { get; private set; } -#else - public FilterObject[] Filters { get; init; } -#endif + public FilterObject[] Filters { get; } public FilterRunner(FilterObject[]? filters) { diff --git a/SabreTools.Core/MappingAttribute.cs b/SabreTools.Core/MappingAttribute.cs index 25442f39..493f4a90 100644 --- a/SabreTools.Core/MappingAttribute.cs +++ b/SabreTools.Core/MappingAttribute.cs @@ -11,14 +11,14 @@ namespace SabreTools.Core /// /// Set of mapping strings /// - public string[] Mappings { get; private set; } + public string[] Mappings { get; } /// /// Constructor /// public MappingAttribute(params string[] mappings) { - this.Mappings = mappings; + Mappings = mappings; } } } \ No newline at end of file diff --git a/SabreTools.DatFiles/DatFile.FromMetadata.cs b/SabreTools.DatFiles/DatFile.FromMetadata.cs index cc6cc8ee..e687ccd1 100644 --- a/SabreTools.DatFiles/DatFile.FromMetadata.cs +++ b/SabreTools.DatFiles/DatFile.FromMetadata.cs @@ -24,7 +24,7 @@ namespace SabreTools.DatFiles return; // Create an internal source and add to the dictionary - var source = new DatItems.Source { Index = indexId, Name = filename }; + var source = new DatItems.Source(indexId, filename); long sourceIndex = ItemsDB.AddSource(source); // Get the header from the metadata diff --git a/SabreTools.DatFiles/DatFile.cs b/SabreTools.DatFiles/DatFile.cs index 33b93ae9..e10b801d 100644 --- a/SabreTools.DatFiles/DatFile.cs +++ b/SabreTools.DatFiles/DatFile.cs @@ -172,7 +172,7 @@ namespace SabreTools.DatFiles /// public void ResetDictionary() { - Items = []; + Items.Clear(); ItemsDB = new ItemDictionaryDB(); } diff --git a/SabreTools.DatFiles/DatStatistics.cs b/SabreTools.DatFiles/DatStatistics.cs index 9ad20e40..07491f5b 100644 --- a/SabreTools.DatFiles/DatStatistics.cs +++ b/SabreTools.DatFiles/DatStatistics.cs @@ -30,7 +30,7 @@ namespace SabreTools.DatFiles /// /// Number of items for each item type /// - public Dictionary ItemCounts { get; private set; } = []; + public Dictionary ItemCounts { get; } = []; /// /// Number of machines @@ -46,12 +46,12 @@ namespace SabreTools.DatFiles /// /// Number of items for each hash type /// - public Dictionary HashCounts { get; private set; } = []; + public Dictionary HashCounts { get; } = []; /// /// Number of items for each item status /// - public Dictionary StatusCounts { get; private set; } = []; + public Dictionary StatusCounts { get; } = []; /// /// Number of items with the remove flag @@ -344,11 +344,11 @@ namespace SabreTools.DatFiles public void ResetStatistics() { TotalCount = 0; - ItemCounts = []; + ItemCounts.Clear(); GameCount = 0; TotalSize = 0; - HashCounts = []; - StatusCounts = []; + HashCounts.Clear(); + StatusCounts.Clear(); RemovedCount = 0; } diff --git a/SabreTools.DatFiles/DepotInformation.cs b/SabreTools.DatFiles/DepotInformation.cs index 43d41ab2..1de7b045 100644 --- a/SabreTools.DatFiles/DepotInformation.cs +++ b/SabreTools.DatFiles/DepotInformation.cs @@ -11,25 +11,37 @@ namespace SabreTools.DatFiles /// /// Name or path of the Depot /// - public string? Name { get; private set; } + public string? Name { get; } /// /// Whether to use this Depot or not /// - public bool IsActive { get; private set; } + public bool IsActive { get; } /// /// Depot byte-depth /// - public int Depth { get; private set; } + public int Depth { get; } /// /// Constructor /// /// Set active state /// Set depth between 0 and SHA-1's byte length - public DepotInformation(bool isActive = false, int depth = 4) + public DepotInformation(bool isActive, int depth = 4) + : this(null, isActive, depth) { + } + + /// + /// Constructor + /// + /// Set active state + /// Set active state + /// Set depth between 0 and SHA-1's byte length + public DepotInformation(string? name, bool isActive, int depth = 4) + { + Name = name; IsActive = isActive; Depth = depth; @@ -47,15 +59,7 @@ namespace SabreTools.DatFiles /// /// Clone the current object /// - public object Clone() - { - return new DepotInformation - { - Name = this.Name, - IsActive = this.IsActive, - Depth = this.Depth, - }; - } + public object Clone() => new DepotInformation(Name, IsActive, Depth); #endregion } diff --git a/SabreTools.DatFiles/Formats/SabreJSON.cs b/SabreTools.DatFiles/Formats/SabreJSON.cs index a9e7f456..f1db9e4b 100644 --- a/SabreTools.DatFiles/Formats/SabreJSON.cs +++ b/SabreTools.DatFiles/Formats/SabreJSON.cs @@ -33,7 +33,7 @@ namespace SabreTools.DatFiles.Formats // Prepare all internal variables var sr = new StreamReader(System.IO.File.OpenRead(filename), new UTF8Encoding(false)); var jtr = new JsonTextReader(sr); - var source = new Source { Index = indexId, Name = filename }; + var source = new Source(indexId, filename); long sourceIndex = ItemsDB.AddSource(source); // If we got a null reader, just return diff --git a/SabreTools.DatFiles/Formats/SabreXML.cs b/SabreTools.DatFiles/Formats/SabreXML.cs index 895eb2e7..26bffbf4 100644 --- a/SabreTools.DatFiles/Formats/SabreXML.cs +++ b/SabreTools.DatFiles/Formats/SabreXML.cs @@ -38,7 +38,7 @@ namespace SabreTools.DatFiles.Formats ValidationFlags = XmlSchemaValidationFlags.None, ValidationType = ValidationType.None, }); - var source = new Source { Index = indexId, Name = filename }; + var source = new Source(indexId, filename); long sourceIndex = ItemsDB.AddSource(source); // If we got a null reader, just return diff --git a/SabreTools.DatItems/Source.cs b/SabreTools.DatItems/Source.cs index b8a107c0..9243e2b5 100644 --- a/SabreTools.DatItems/Source.cs +++ b/SabreTools.DatItems/Source.cs @@ -10,19 +10,19 @@ namespace SabreTools.DatItems /// /// Source index /// - public int Index { get; set; } + public int Index { get; } /// /// Source name /// - public string? Name { get; set; } + public string? Name { get; } /// /// Constructor /// - /// Source ID, default 0 - /// Source name, default null - public Source(int id = 0, string? source = null) + /// Source ID + /// Source name, optional + public Source(int id, string? source = null) { Index = id; Name = source; diff --git a/SabreTools.FileTypes/BaseFile.cs b/SabreTools.FileTypes/BaseFile.cs index 2a3009b0..0a6a4ad3 100644 --- a/SabreTools.FileTypes/BaseFile.cs +++ b/SabreTools.FileTypes/BaseFile.cs @@ -115,22 +115,22 @@ namespace SabreTools.FileTypes /// True if hashes for this file should be calculated (default), false otherwise public BaseFile(string filename, bool getHashes = true) { - this.Filename = filename; + Filename = filename; if (getHashes) { - BaseFile? temp = GetInfo(this.Filename, hashes: this.AvailableHashTypes); + BaseFile? temp = GetInfo(Filename, hashes: AvailableHashTypes); if (temp != null) { - this.Parent = temp.Parent; - this.Date = temp.Date; - this.CRC = temp.CRC; - this.MD5 = temp.MD5; - this.SHA1 = temp.SHA1; - this.SHA256 = temp.SHA256; - this.SHA384 = temp.SHA384; - this.SHA512 = temp.SHA512; - this.SpamSum = temp.SpamSum; + Parent = temp.Parent; + Date = temp.Date; + CRC = temp.CRC; + MD5 = temp.MD5; + SHA1 = temp.SHA1; + SHA256 = temp.SHA256; + SHA384 = temp.SHA384; + SHA512 = temp.SHA512; + SpamSum = temp.SpamSum; } } } @@ -143,22 +143,22 @@ namespace SabreTools.FileTypes /// True if hashes for this file should be calculated (default), false otherwise public BaseFile(string filename, Stream stream, bool getHashes = true) { - this.Filename = filename; + Filename = filename; if (getHashes) { - BaseFile temp = GetInfo(stream, hashes: this.AvailableHashTypes); + BaseFile temp = GetInfo(stream, hashes: AvailableHashTypes); if (temp != null) { - this.Parent = temp.Parent; - this.Date = temp.Date; - this.CRC = temp.CRC; - this.MD5 = temp.MD5; - this.SHA1 = temp.SHA1; - this.SHA256 = temp.SHA256; - this.SHA384 = temp.SHA384; - this.SHA512 = temp.SHA512; - this.SpamSum = temp.SpamSum; + Parent = temp.Parent; + Date = temp.Date; + CRC = temp.CRC; + MD5 = temp.MD5; + SHA1 = temp.SHA1; + SHA256 = temp.SHA256; + SHA384 = temp.SHA384; + SHA512 = temp.SHA512; + SpamSum = temp.SpamSum; } } diff --git a/SabreTools.FileTypes/Folder.cs b/SabreTools.FileTypes/Folder.cs index 77bb8f3f..6d57a0d1 100644 --- a/SabreTools.FileTypes/Folder.cs +++ b/SabreTools.FileTypes/Folder.cs @@ -32,7 +32,7 @@ namespace SabreTools.FileTypes /// /// Flag specific to Folder to omit Machine name from output path /// - private readonly bool writeToParent = false; + private readonly bool _writeToParent = false; #endregion @@ -45,7 +45,7 @@ namespace SabreTools.FileTypes public Folder(bool writeToParent = false) : base() { - this.writeToParent = writeToParent; + _writeToParent = writeToParent; logger = new Logger(this); } @@ -96,17 +96,17 @@ namespace SabreTools.FileTypes public virtual bool CopyAll(string outDir) { // If we have an invalid filename - if (this.Filename == null) + if (Filename == null) return false; // Copy all files from the current folder to the output directory recursively try { // Make sure the folders exist - Directory.CreateDirectory(this.Filename); + Directory.CreateDirectory(Filename); Directory.CreateDirectory(outDir); - DirectoryCopy(this.Filename, outDir, true); + DirectoryCopy(Filename, outDir, true); } catch (Exception ex) { @@ -167,18 +167,18 @@ namespace SabreTools.FileTypes string? realentry = null; // If we have an invalid filename - if (this.Filename == null) + if (Filename == null) return null; // Copy single file from the current folder to the output directory, if exists try { // Make sure the folders exist - Directory.CreateDirectory(this.Filename); + Directory.CreateDirectory(Filename); Directory.CreateDirectory(outDir); // Get all files from the input directory - List files = PathTool.GetFilesOrdered(this.Filename); + List files = PathTool.GetFilesOrdered(Filename); // Now sort through to find the first file that matches string? match = files.Where(s => s.EndsWith(entryName)).FirstOrDefault(); @@ -207,17 +207,17 @@ namespace SabreTools.FileTypes public virtual (Stream?, string?) GetEntryStream(string entryName) { // If we have an invalid filename - if (this.Filename == null) + if (Filename == null) return (null, null); // Copy single file from the current folder to the output directory, if exists try { // Make sure the folders exist - Directory.CreateDirectory(this.Filename); + Directory.CreateDirectory(Filename); // Get all files from the input directory - List files = PathTool.GetFilesOrdered(this.Filename); + List files = PathTool.GetFilesOrdered(Filename); // Now sort through to find the first file that matches string? match = files.Where(s => s.EndsWith(entryName)).FirstOrDefault(); @@ -249,27 +249,27 @@ namespace SabreTools.FileTypes public virtual List? GetChildren() { // If we have an invalid filename - if (this.Filename == null) + if (Filename == null) return null; if (_children == null || _children.Count == 0) { _children = []; #if NET20 || NET35 - foreach (string file in Directory.GetFiles(this.Filename, "*")) + foreach (string file in Directory.GetFiles(Filename, "*")) #else - foreach (string file in Directory.EnumerateFiles(this.Filename, "*", SearchOption.TopDirectoryOnly)) + foreach (string file in Directory.EnumerateFiles(Filename, "*", SearchOption.TopDirectoryOnly)) #endif { - BaseFile? nf = GetInfo(file, hashes: this.AvailableHashTypes); + BaseFile? nf = GetInfo(file, hashes: AvailableHashTypes); if (nf != null) _children.Add(nf); } #if NET20 || NET35 - foreach (string dir in Directory.GetDirectories(this.Filename, "*")) + foreach (string dir in Directory.GetDirectories(Filename, "*")) #else - foreach (string dir in Directory.EnumerateDirectories(this.Filename, "*", SearchOption.TopDirectoryOnly)) + foreach (string dir in Directory.EnumerateDirectories(Filename, "*", SearchOption.TopDirectoryOnly)) #endif { Folder fl = new(dir); @@ -287,7 +287,7 @@ namespace SabreTools.FileTypes /// List of empty folders in the folder public virtual List? GetEmptyFolders() { - return this.Filename.ListEmpty(); + return Filename.ListEmpty(); } #endregion @@ -331,7 +331,7 @@ namespace SabreTools.FileTypes // Get the output folder name from the first rebuild rom string fileName; - if (writeToParent) + if (_writeToParent) fileName = Path.Combine(outDir, TextHelper.RemovePathUnsafeCharacters(baseFile.Filename) ?? string.Empty); else #if NET20 || NET35 diff --git a/SabreTools.Filtering/ExtraIni.cs b/SabreTools.Filtering/ExtraIni.cs index 6d21cdc4..34681281 100644 --- a/SabreTools.Filtering/ExtraIni.cs +++ b/SabreTools.Filtering/ExtraIni.cs @@ -14,7 +14,7 @@ namespace SabreTools.Filtering /// /// List of extras to apply /// - public List Items { get; set; } = []; + public List Items { get; } = []; #endregion diff --git a/SabreTools.Reports/BaseReport.cs b/SabreTools.Reports/BaseReport.cs index 7637e67b..3ba40fd1 100644 --- a/SabreTools.Reports/BaseReport.cs +++ b/SabreTools.Reports/BaseReport.cs @@ -19,7 +19,7 @@ namespace SabreTools.Reports #endregion - public List Statistics { get; set; } + public List Statistics { get; } /// /// Create a new report from the filename diff --git a/SabreTools.Test/DatItems/DatItemTests.cs b/SabreTools.Test/DatItems/DatItemTests.cs index b31bd192..0eb7015d 100644 --- a/SabreTools.Test/DatItems/DatItemTests.cs +++ b/SabreTools.Test/DatItems/DatItemTests.cs @@ -45,13 +45,13 @@ namespace SabreTools.Test.DatItems var romA = new Rom(); romA.SetName("same-name"); romA.SetFieldValue(Models.Metadata.Rom.CRCKey, "DEADBEEF"); - romA.SetFieldValue(DatItem.SourceKey, new Source { Index = 0 }); + romA.SetFieldValue(DatItem.SourceKey, new Source(0)); romA.CopyMachineInformation(machineA); var romB = new Rom(); romB.SetName("same-name"); romB.SetFieldValue(Models.Metadata.Rom.CRCKey, "DEADBEEF"); - romB.SetFieldValue(DatItem.SourceKey, new Source { Index = 1 }); + romB.SetFieldValue(DatItem.SourceKey, new Source(1)); romB.CopyMachineInformation(machineB); var actual = romA.GetDuplicateStatus(romB); @@ -70,13 +70,13 @@ namespace SabreTools.Test.DatItems var romA = new Rom(); romA.SetName("same-name"); romA.SetFieldValue(Models.Metadata.Rom.CRCKey, "DEADBEEF"); - romA.SetFieldValue(DatItem.SourceKey, new Source { Index = 0 }); + romA.SetFieldValue(DatItem.SourceKey, new Source(0)); romA.CopyMachineInformation(machineA); var romB = new Rom(); romB.SetName("same-name"); romB.SetFieldValue(Models.Metadata.Rom.CRCKey, "DEADBEEF"); - romB.SetFieldValue(DatItem.SourceKey, new Source { Index = 1 }); + romB.SetFieldValue(DatItem.SourceKey, new Source(1)); romB.CopyMachineInformation(machineB); var actual = romA.GetDuplicateStatus(romB); @@ -95,13 +95,13 @@ namespace SabreTools.Test.DatItems var romA = new Rom(); romA.SetName("same-name"); romA.SetFieldValue(Models.Metadata.Rom.CRCKey, "DEADBEEF"); - romA.SetFieldValue(DatItem.SourceKey, new Source { Index = 0 }); + romA.SetFieldValue(DatItem.SourceKey, new Source(0)); romA.CopyMachineInformation(machineA); var romB = new Rom(); romB.SetName("same-name"); romB.SetFieldValue(Models.Metadata.Rom.CRCKey, "DEADBEEF"); - romB.SetFieldValue(DatItem.SourceKey, new Source { Index = 0 }); + romB.SetFieldValue(DatItem.SourceKey, new Source(0)); romB.CopyMachineInformation(machineB); var actual = romA.GetDuplicateStatus(romB); @@ -120,13 +120,13 @@ namespace SabreTools.Test.DatItems var romA = new Rom(); romA.SetName("same-name"); romA.SetFieldValue(Models.Metadata.Rom.CRCKey, "DEADBEEF"); - romA.SetFieldValue(DatItem.SourceKey, new Source { Index = 0 }); + romA.SetFieldValue(DatItem.SourceKey, new Source(0)); romA.CopyMachineInformation(machineA); var romB = new Rom(); romB.SetName("same-name"); romB.SetFieldValue(Models.Metadata.Rom.CRCKey, "DEADBEEF"); - romB.SetFieldValue(DatItem.SourceKey, new Source { Index = 0 }); + romB.SetFieldValue(DatItem.SourceKey, new Source(0)); romB.CopyMachineInformation(machineB); var actual = romA.GetDuplicateStatus(romB);