mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Enable nullability everywhere
This commit is contained in:
@@ -36,7 +36,7 @@ namespace SabreTools.Reports
|
||||
/// <param name="statReportFormat">Format of the Statistics Report to be created</param>
|
||||
/// <param name="statsList">List of statistics objects to set</param>
|
||||
/// <returns>BaseReport of the specific internal type that corresponds to the inputs</returns>
|
||||
public static BaseReport Create(StatReportFormat statReportFormat, List<DatStatistics> statsList)
|
||||
public static BaseReport? Create(StatReportFormat statReportFormat, List<DatStatistics> statsList)
|
||||
{
|
||||
return statReportFormat switch
|
||||
{
|
||||
@@ -58,7 +58,7 @@ namespace SabreTools.Reports
|
||||
/// <param name="nodumpCol">True if nodumps should be included in output, false otherwise</param>
|
||||
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
|
||||
/// <returns>True if the report was written correctly, false otherwise</returns>
|
||||
public abstract bool WriteToFile(string outfile, bool baddumpCol, bool nodumpCol, bool throwOnError = false);
|
||||
public abstract bool WriteToFile(string? outfile, bool baddumpCol, bool nodumpCol, bool throwOnError = false);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the human-readable file size for an arbitrary, 64-bit file size
|
||||
|
||||
@@ -10,12 +10,12 @@ namespace SabreTools.Reports
|
||||
/// <summary>
|
||||
/// ItemDictionary representing the statistics
|
||||
/// </summary>
|
||||
public ItemDictionary Statistics { get; set; }
|
||||
public ItemDictionary? Statistics { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Name to display on output
|
||||
/// </summary>
|
||||
public string DisplayName { get; set; }
|
||||
public string? DisplayName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Total machine count to use on output
|
||||
|
||||
@@ -25,14 +25,14 @@ namespace SabreTools.Reports.Formats
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool WriteToFile(string outfile, bool baddumpCol, bool nodumpCol, bool throwOnError = false)
|
||||
public override bool WriteToFile(string? outfile, bool baddumpCol, bool nodumpCol, bool throwOnError = false)
|
||||
{
|
||||
InternalStopwatch watch = new($"Writing statistics to '{outfile}");
|
||||
|
||||
try
|
||||
{
|
||||
// Try to create the output file
|
||||
FileStream fs = File.Create(outfile);
|
||||
FileStream fs = File.Create(outfile ?? string.Empty);
|
||||
if (fs == null)
|
||||
{
|
||||
logger.Warning($"File '{outfile}' could not be created for writing! Please check to see if the file is writable");
|
||||
@@ -211,7 +211,7 @@ body {
|
||||
/// <param name="nodumpCol">True if nodumps should be included in output, false otherwise</param>
|
||||
private void WriteIndividual(XmlTextWriter xtw, DatStatistics stat, bool baddumpCol, bool nodumpCol)
|
||||
{
|
||||
bool isDirectory = stat.DisplayName.StartsWith("DIR: ");
|
||||
bool isDirectory = stat.DisplayName!.StartsWith("DIR: ");
|
||||
|
||||
xtw.WriteStartElement("tr");
|
||||
if (isDirectory)
|
||||
@@ -221,7 +221,7 @@ body {
|
||||
|
||||
xtw.WriteStartElement("td");
|
||||
xtw.WriteAttributeString("align", "right");
|
||||
xtw.WriteString(GetBytesReadable(stat.Statistics.TotalSize));
|
||||
xtw.WriteString(GetBytesReadable(stat.Statistics!.TotalSize));
|
||||
xtw.WriteEndElement(); // td
|
||||
|
||||
xtw.WriteStartElement("td");
|
||||
|
||||
@@ -27,14 +27,14 @@ namespace SabreTools.Reports.Formats
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool WriteToFile(string outfile, bool baddumpCol, bool nodumpCol, bool throwOnError = false)
|
||||
public override bool WriteToFile(string? outfile, bool baddumpCol, bool nodumpCol, bool throwOnError = false)
|
||||
{
|
||||
InternalStopwatch watch = new($"Writing statistics to '{outfile}");
|
||||
|
||||
try
|
||||
{
|
||||
// Try to create the output file
|
||||
FileStream fs = File.Create(outfile);
|
||||
FileStream fs = File.Create(outfile ?? string.Empty);
|
||||
if (fs == null)
|
||||
{
|
||||
logger.Warning($"File '{outfile}' could not be created for writing! Please check to see if the file is writable");
|
||||
@@ -97,8 +97,8 @@ namespace SabreTools.Reports.Formats
|
||||
/// <param name="nodumpCol">True if nodumps should be included in output, false otherwise</param>
|
||||
private void WriteHeader(SeparatedValueWriter svw, bool baddumpCol, bool nodumpCol)
|
||||
{
|
||||
string[] headers = new string[]
|
||||
{
|
||||
string[] headers =
|
||||
[
|
||||
"File Name",
|
||||
"Total Size",
|
||||
"Games",
|
||||
@@ -112,7 +112,7 @@ namespace SabreTools.Reports.Formats
|
||||
"# with SHA-512",
|
||||
baddumpCol ? "BadDumps" : string.Empty,
|
||||
nodumpCol ? "Nodumps" : string.Empty,
|
||||
};
|
||||
];
|
||||
svw.WriteHeader(headers);
|
||||
svw.Flush();
|
||||
}
|
||||
@@ -126,10 +126,10 @@ namespace SabreTools.Reports.Formats
|
||||
/// <param name="nodumpCol">True if nodumps should be included in output, false otherwise</param>
|
||||
private void WriteIndividual(SeparatedValueWriter svw, DatStatistics stat, bool baddumpCol, bool nodumpCol)
|
||||
{
|
||||
string[] values = new string[]
|
||||
{
|
||||
stat.DisplayName,
|
||||
stat.Statistics.TotalSize.ToString(),
|
||||
string[] values =
|
||||
[
|
||||
stat.DisplayName!,
|
||||
stat.Statistics!.TotalSize.ToString(),
|
||||
stat.MachineCount.ToString(),
|
||||
stat.Statistics.RomCount.ToString(),
|
||||
stat.Statistics.DiskCount.ToString(),
|
||||
@@ -141,7 +141,7 @@ namespace SabreTools.Reports.Formats
|
||||
stat.Statistics.SHA512Count.ToString(),
|
||||
baddumpCol ? stat.Statistics.BaddumpCount.ToString() : string.Empty,
|
||||
nodumpCol ? stat.Statistics.NodumpCount.ToString() : string.Empty,
|
||||
};
|
||||
];
|
||||
svw.WriteValues(values);
|
||||
svw.Flush();
|
||||
}
|
||||
|
||||
@@ -25,14 +25,14 @@ namespace SabreTools.Reports.Formats
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool WriteToFile(string outfile, bool baddumpCol, bool nodumpCol, bool throwOnError = false)
|
||||
public override bool WriteToFile(string? outfile, bool baddumpCol, bool nodumpCol, bool throwOnError = false)
|
||||
{
|
||||
InternalStopwatch watch = new($"Writing statistics to '{outfile}");
|
||||
|
||||
try
|
||||
{
|
||||
// Try to create the output file
|
||||
Stream fs = _writeToConsole ? Console.OpenStandardOutput() : File.Create(outfile);
|
||||
Stream fs = _writeToConsole ? Console.OpenStandardOutput() : File.Create(outfile ?? string.Empty);
|
||||
if (fs == null)
|
||||
{
|
||||
logger.Warning($"File '{outfile}' could not be created for writing! Please check to see if the file is writable");
|
||||
@@ -91,7 +91,7 @@ namespace SabreTools.Reports.Formats
|
||||
{
|
||||
string line = @"'" + stat.DisplayName + @"':
|
||||
--------------------------------------------------
|
||||
Uncompressed size: " + GetBytesReadable(stat.Statistics.TotalSize) + @"
|
||||
Uncompressed size: " + GetBytesReadable(stat.Statistics!.TotalSize) + @"
|
||||
Games found: " + stat.MachineCount + @"
|
||||
Roms found: " + stat.Statistics.RomCount + @"
|
||||
Disks found: " + stat.Statistics.DiskCount + @"
|
||||
|
||||
Reference in New Issue
Block a user