Fix some over-accessible fields

This commit is contained in:
Matt Nadareski
2024-10-19 23:17:37 -04:00
parent 16f173099d
commit 4d5ac92125
15 changed files with 142 additions and 154 deletions

View File

@@ -14,29 +14,17 @@ namespace SabreTools.Core.Filter
/// <summary>
/// Key name for the filter
/// </summary>
#if NETFRAMEWORK || NETCOREAPP3_1
public string[] Key { get; private set; }
#else
public string[] Key { get; init; }
#endif
public string[] Key { get; }
/// <summary>
/// Value to match in the filter
/// </summary>
#if NETFRAMEWORK || NETCOREAPP3_1
public string? Value { get; private set; }
#else
public string? Value { get; init; }
#endif
public string? Value { get; }
/// <summary>
/// Operation on how to match the filter
/// </summary>
#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
/// </summary>
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);
}
/// <summary>
@@ -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);
}
/// <summary>
@@ -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;
}

View File

@@ -13,11 +13,7 @@ namespace SabreTools.Core.Filter
/// <summary>
/// Set of filters to be run against an object
/// </summary>
#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)
{

View File

@@ -11,14 +11,14 @@ namespace SabreTools.Core
/// <summary>
/// Set of mapping strings
/// </summary>
public string[] Mappings { get; private set; }
public string[] Mappings { get; }
/// <summary>
/// Constructor
/// </summary>
public MappingAttribute(params string[] mappings)
{
this.Mappings = mappings;
Mappings = mappings;
}
}
}

View File

@@ -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

View File

@@ -172,7 +172,7 @@ namespace SabreTools.DatFiles
/// </summary>
public void ResetDictionary()
{
Items = [];
Items.Clear();
ItemsDB = new ItemDictionaryDB();
}

View File

@@ -30,7 +30,7 @@ namespace SabreTools.DatFiles
/// <summary>
/// Number of items for each item type
/// </summary>
public Dictionary<ItemType, long> ItemCounts { get; private set; } = [];
public Dictionary<ItemType, long> ItemCounts { get; } = [];
/// <summary>
/// Number of machines
@@ -46,12 +46,12 @@ namespace SabreTools.DatFiles
/// <summary>
/// Number of items for each hash type
/// </summary>
public Dictionary<HashType, long> HashCounts { get; private set; } = [];
public Dictionary<HashType, long> HashCounts { get; } = [];
/// <summary>
/// Number of items for each item status
/// </summary>
public Dictionary<ItemStatus, long> StatusCounts { get; private set; } = [];
public Dictionary<ItemStatus, long> StatusCounts { get; } = [];
/// <summary>
/// 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;
}

View File

@@ -11,25 +11,37 @@ namespace SabreTools.DatFiles
/// <summary>
/// Name or path of the Depot
/// </summary>
public string? Name { get; private set; }
public string? Name { get; }
/// <summary>
/// Whether to use this Depot or not
/// </summary>
public bool IsActive { get; private set; }
public bool IsActive { get; }
/// <summary>
/// Depot byte-depth
/// </summary>
public int Depth { get; private set; }
public int Depth { get; }
/// <summary>
/// Constructor
/// </summary>
/// <param name="isActive">Set active state</param>
/// <param name="depth">Set depth between 0 and SHA-1's byte length</param>
public DepotInformation(bool isActive = false, int depth = 4)
public DepotInformation(bool isActive, int depth = 4)
: this(null, isActive, depth)
{
}
/// <summary>
/// Constructor
/// </summary>
/// <param name="name">Set active state</param>
/// <param name="isActive">Set active state</param>
/// <param name="depth">Set depth between 0 and SHA-1's byte length</param>
public DepotInformation(string? name, bool isActive, int depth = 4)
{
Name = name;
IsActive = isActive;
Depth = depth;
@@ -47,15 +59,7 @@ namespace SabreTools.DatFiles
/// <summary>
/// Clone the current object
/// </summary>
public object Clone()
{
return new DepotInformation
{
Name = this.Name,
IsActive = this.IsActive,
Depth = this.Depth,
};
}
public object Clone() => new DepotInformation(Name, IsActive, Depth);
#endregion
}

View File

@@ -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

View File

@@ -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

View File

@@ -10,19 +10,19 @@ namespace SabreTools.DatItems
/// <summary>
/// Source index
/// </summary>
public int Index { get; set; }
public int Index { get; }
/// <summary>
/// Source name
/// </summary>
public string? Name { get; set; }
public string? Name { get; }
/// <summary>
/// Constructor
/// </summary>
/// <param name="id">Source ID, default 0</param>
/// <param name="source">Source name, default null</param>
public Source(int id = 0, string? source = null)
/// <param name="id">Source ID</param>
/// <param name="source">Source name, optional</param>
public Source(int id, string? source = null)
{
Index = id;
Name = source;

View File

@@ -115,22 +115,22 @@ namespace SabreTools.FileTypes
/// <param name="getHashes">True if hashes for this file should be calculated (default), false otherwise</param>
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
/// <param name="getHashes">True if hashes for this file should be calculated (default), false otherwise</param>
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;
}
}

View File

@@ -32,7 +32,7 @@ namespace SabreTools.FileTypes
/// <summary>
/// Flag specific to Folder to omit Machine name from output path
/// </summary>
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<string> files = PathTool.GetFilesOrdered(this.Filename);
List<string> 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<string> files = PathTool.GetFilesOrdered(this.Filename);
List<string> 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<BaseFile>? 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
/// <returns>List of empty folders in the folder</returns>
public virtual List<string>? 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

View File

@@ -14,7 +14,7 @@ namespace SabreTools.Filtering
/// <summary>
/// List of extras to apply
/// </summary>
public List<ExtraIniItem> Items { get; set; } = [];
public List<ExtraIniItem> Items { get; } = [];
#endregion

View File

@@ -19,7 +19,7 @@ namespace SabreTools.Reports
#endregion
public List<DatStatistics> Statistics { get; set; }
public List<DatStatistics> Statistics { get; }
/// <summary>
/// Create a new report from the filename

View File

@@ -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<Source?>(DatItem.SourceKey, new Source { Index = 0 });
romA.SetFieldValue<Source?>(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<Source?>(DatItem.SourceKey, new Source { Index = 1 });
romB.SetFieldValue<Source?>(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<Source?>(DatItem.SourceKey, new Source { Index = 0 });
romA.SetFieldValue<Source?>(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<Source?>(DatItem.SourceKey, new Source { Index = 1 });
romB.SetFieldValue<Source?>(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<Source?>(DatItem.SourceKey, new Source { Index = 0 });
romA.SetFieldValue<Source?>(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<Source?>(DatItem.SourceKey, new Source { Index = 0 });
romB.SetFieldValue<Source?>(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<Source?>(DatItem.SourceKey, new Source { Index = 0 });
romA.SetFieldValue<Source?>(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<Source?>(DatItem.SourceKey, new Source { Index = 0 });
romB.SetFieldValue<Source?>(DatItem.SourceKey, new Source(0));
romB.CopyMachineInformation(machineB);
var actual = romA.GetDuplicateStatus(romB);