Follow suggested cleanup from VS

This commit is contained in:
Matt Nadareski
2020-10-07 16:11:05 -07:00
parent b7db9f7f14
commit f3031fe5f9
20 changed files with 152 additions and 126 deletions

View File

@@ -28,7 +28,7 @@ namespace RombaSharp
/// <summary>
/// Logging object
/// </summary>
private static Logger logger = new Logger();
private static readonly Logger logger = new Logger();
#endregion

View File

@@ -136,48 +136,48 @@ namespace SabreTools.Library.DatFiles
switch (itemKey)
{
case "name":
Header.Name = (Header.Name == null ? itemVal : Header.Name);
Header.Name = Header.Name ?? itemVal;
superdat = superdat || itemVal.Contains(" - SuperDAT");
if (keep && superdat)
Header.Type = (Header.Type == null ? "SuperDAT" : Header.Type);
Header.Type = Header.Type ?? "SuperDAT";
break;
case "description":
Header.Description = (Header.Description == null ? itemVal : Header.Description);
Header.Description = Header.Description ?? itemVal;
break;
case "rootdir":
Header.RootDir = (Header.RootDir == null ? itemVal : Header.RootDir);
Header.RootDir = Header.RootDir ?? itemVal;
break;
case "category":
Header.Category = (Header.Category == null ? itemVal : Header.Category);
Header.Category = Header.Category ?? itemVal;
break;
case "version":
Header.Version = (Header.Version == null ? itemVal : Header.Version);
Header.Version = Header.Version ?? itemVal;
break;
case "date":
Header.Date = (Header.Date == null ? itemVal : Header.Date);
Header.Date = Header.Date ?? itemVal;
break;
case "author":
Header.Author = (Header.Author == null ? itemVal : Header.Author);
Header.Author = Header.Author ?? itemVal;
break;
case "email":
Header.Email = (Header.Email == null ? itemVal : Header.Email);
Header.Email = Header.Email ?? itemVal;
break;
case "homepage":
Header.Homepage = (Header.Homepage == null ? itemVal : Header.Homepage);
Header.Homepage = Header.Homepage ?? itemVal;
break;
case "url":
Header.Url = (Header.Url == null ? itemVal : Header.Url);
Header.Url = Header.Url ?? itemVal;
break;
case "comment":
Header.Comment = (Header.Comment == null ? itemVal : Header.Comment);
Header.Comment = Header.Comment ?? itemVal;
break;
case "header":
Header.HeaderSkipper = (Header.HeaderSkipper == null ? itemVal : Header.HeaderSkipper);
Header.HeaderSkipper = Header.HeaderSkipper ?? itemVal;
break;
case "type":
Header.Type = (Header.Type == null ? itemVal : Header.Type);
Header.Type = Header.Type ?? itemVal;
superdat = superdat || itemVal.Contains("SuperDAT");
break;
case "forcemerging":

View File

@@ -116,25 +116,25 @@ namespace SabreTools.Library.DatFiles
switch (itemKey)
{
case "name":
Header.Name = (Header.Name == null ? itemVal : Header.Name);
Header.Name = Header.Name ?? itemVal;
break;
case "description":
Header.Description = (Header.Description == null ? itemVal : Header.Description);
Header.Description = Header.Description ?? itemVal;
break;
case "dersion":
Header.Version = (Header.Version == null ? itemVal : Header.Version);
Header.Version = Header.Version ?? itemVal;
break;
case "date":
Header.Date = (Header.Date == null ? itemVal : Header.Date);
Header.Date = Header.Date ?? itemVal;
break;
case "author":
Header.Author = (Header.Author == null ? itemVal : Header.Author);
Header.Author = Header.Author ?? itemVal;
break;
case "homepage":
Header.Homepage = (Header.Homepage == null ? itemVal : Header.Homepage);
Header.Homepage = Header.Homepage ?? itemVal;
break;
case "comment":
Header.Comment = (Header.Comment == null ? itemVal : Header.Comment);
Header.Comment = Header.Comment ?? itemVal;
break;
}
}

View File

@@ -44,12 +44,12 @@ namespace SabreTools.Library.DatFiles
/// <summary>
/// Lock for statistics calculation
/// </summary>
private object statsLock = new object();
private readonly object statsLock = new object();
/// <summary>
/// Logging object
/// </summary>
private static Logger logger = new Logger();
private readonly static Logger logger = new Logger();
#endregion

View File

@@ -57,18 +57,18 @@ namespace SabreTools.Library.DatFiles
switch (xtr.Name)
{
case "mame":
Header.Name = (Header.Name == null ? xtr.GetAttribute("build") : Header.Name);
Header.Description = (Header.Description == null ? Header.Name : Header.Description);
Header.Debug = (Header.Debug == null ? xtr.GetAttribute("debug").AsYesNo() : Header.Debug);
Header.MameConfig = (Header.MameConfig == null ? xtr.GetAttribute("mameconfig") : Header.MameConfig);
Header.Name = Header.Name ?? xtr.GetAttribute("build");
Header.Description = Header.Description ?? Header.Name;
Header.Debug = Header.Debug ?? xtr.GetAttribute("debug").AsYesNo();
Header.MameConfig = Header.MameConfig ?? xtr.GetAttribute("mameconfig");
xtr.Read();
break;
// Handle M1 DATs since they're 99% the same as a SL DAT
case "m1":
Header.Name = (Header.Name == null ? "M1" : Header.Name);
Header.Description = (Header.Description == null ? "M1" : Header.Description);
Header.Version = (Header.Version == null ? xtr.GetAttribute("version") ?? string.Empty : Header.Version);
Header.Name = Header.Name ?? "M1";
Header.Description = Header.Description ?? "M1";
Header.Version = Header.Version ?? xtr.GetAttribute("version") ?? string.Empty;
xtr.Read();
break;
@@ -653,10 +653,12 @@ namespace SabreTools.Library.DatFiles
switch (reader.Name)
{
case "slotoption":
var slotOption = new SlotOption();
slotOption.Name = reader.GetAttribute("name");
slotOption.DeviceName = reader.GetAttribute("devname");
slotOption.Default = reader.GetAttribute("default").AsYesNo();
var slotOption = new SlotOption
{
Name = reader.GetAttribute("name"),
DeviceName = reader.GetAttribute("devname"),
Default = reader.GetAttribute("default").AsYesNo()
};
slot.SlotOptions.Add(slotOption);
@@ -760,11 +762,13 @@ namespace SabreTools.Library.DatFiles
switch (reader.Name)
{
case "condition":
var condition = new Condition();
condition.Tag = reader.GetAttribute("tag");
condition.Mask = reader.GetAttribute("mask");
condition.Relation = reader.GetAttribute("relation").AsRelation();
condition.Value = reader.GetAttribute("value");
var condition = new Condition
{
Tag = reader.GetAttribute("tag"),
Mask = reader.GetAttribute("mask"),
Relation = reader.GetAttribute("relation").AsRelation(),
Value = reader.GetAttribute("value")
};
dipSwitch.Conditions.Add(condition);
@@ -772,10 +776,12 @@ namespace SabreTools.Library.DatFiles
break;
case "diplocation":
var dipLocation = new Location();
dipLocation.Name = reader.GetAttribute("name");
dipLocation.Number = Sanitizer.CleanLong(reader.GetAttribute("number"));
dipLocation.Inverted = reader.GetAttribute("inverted").AsYesNo();
var dipLocation = new Location
{
Name = reader.GetAttribute("name"),
Number = Sanitizer.CleanLong(reader.GetAttribute("number")),
Inverted = reader.GetAttribute("inverted").AsYesNo()
};
dipSwitch.Locations.Add(dipLocation);
@@ -783,10 +789,12 @@ namespace SabreTools.Library.DatFiles
break;
case "dipvalue":
var dipValue = new Setting();
dipValue.Name = reader.GetAttribute("name");
dipValue.Value = reader.GetAttribute("value");
dipValue.Default = reader.GetAttribute("default").AsYesNo();
var dipValue = new Setting
{
Name = reader.GetAttribute("name"),
Value = reader.GetAttribute("value"),
Default = reader.GetAttribute("default").AsYesNo()
};
// Now read the internal tags
ReadDipValue(reader, dipValue);
@@ -834,11 +842,13 @@ namespace SabreTools.Library.DatFiles
switch (reader.Name)
{
case "condition":
var condition = new Condition();
condition.Tag = reader.GetAttribute("tag");
condition.Mask = reader.GetAttribute("mask");
condition.Relation = reader.GetAttribute("relation").AsRelation();
condition.Value = reader.GetAttribute("value");
var condition = new Condition
{
Tag = reader.GetAttribute("tag"),
Mask = reader.GetAttribute("mask"),
Relation = reader.GetAttribute("relation").AsRelation(),
Value = reader.GetAttribute("value")
};
dipValue.Conditions.Add(condition);
@@ -884,11 +894,13 @@ namespace SabreTools.Library.DatFiles
switch (reader.Name)
{
case "condition":
var condition = new Condition();
condition.Tag = reader.GetAttribute("tag");
condition.Mask = reader.GetAttribute("mask");
condition.Relation = reader.GetAttribute("relation").AsRelation();
condition.Value = reader.GetAttribute("value");
var condition = new Condition
{
Tag = reader.GetAttribute("tag"),
Mask = reader.GetAttribute("mask"),
Relation = reader.GetAttribute("relation").AsRelation(),
Value = reader.GetAttribute("value")
};
configuration.Conditions.Add(condition);
@@ -896,10 +908,12 @@ namespace SabreTools.Library.DatFiles
break;
case "conflocation":
var confLocation = new Location();
confLocation.Name = reader.GetAttribute("name");
confLocation.Number = Sanitizer.CleanLong(reader.GetAttribute("number"));
confLocation.Inverted = reader.GetAttribute("inverted").AsYesNo();
var confLocation = new Location
{
Name = reader.GetAttribute("name"),
Number = Sanitizer.CleanLong(reader.GetAttribute("number")),
Inverted = reader.GetAttribute("inverted").AsYesNo()
};
configuration.Locations.Add(confLocation);
@@ -907,10 +921,12 @@ namespace SabreTools.Library.DatFiles
break;
case "confsetting":
var confSetting = new Setting();
confSetting.Name = reader.GetAttribute("name");
confSetting.Value = reader.GetAttribute("value");
confSetting.Default = reader.GetAttribute("default").AsYesNo();
var confSetting = new Setting
{
Name = reader.GetAttribute("name"),
Value = reader.GetAttribute("value"),
Default = reader.GetAttribute("default").AsYesNo()
};
// Now read the internal tags
ReadConfSetting(reader, confSetting);
@@ -958,11 +974,13 @@ namespace SabreTools.Library.DatFiles
switch (reader.Name)
{
case "condition":
var condition = new Condition();
condition.Tag = reader.GetAttribute("tag");
condition.Mask = reader.GetAttribute("mask");
condition.Relation = reader.GetAttribute("relation").AsRelation();
condition.Value = reader.GetAttribute("value");
var condition = new Condition
{
Tag = reader.GetAttribute("tag"),
Mask = reader.GetAttribute("mask"),
Relation = reader.GetAttribute("relation").AsRelation(),
Value = reader.GetAttribute("value")
};
confSetting.Conditions.Add(condition);
@@ -1006,8 +1024,10 @@ namespace SabreTools.Library.DatFiles
switch (reader.Name)
{
case "analog":
var analog = new Analog();
analog.Mask = reader.GetAttribute("mask");
var analog = new Analog
{
Mask = reader.GetAttribute("mask")
};
port.Analogs.Add(analog);
@@ -1051,11 +1071,13 @@ namespace SabreTools.Library.DatFiles
switch (reader.Name)
{
case "condition":
var condition = new Condition();
condition.Tag = reader.GetAttribute("tag");
condition.Mask = reader.GetAttribute("mask");
condition.Relation = reader.GetAttribute("relation").AsRelation();
condition.Value = reader.GetAttribute("value");
var condition = new Condition
{
Tag = reader.GetAttribute("tag"),
Mask = reader.GetAttribute("mask"),
Relation = reader.GetAttribute("relation").AsRelation(),
Value = reader.GetAttribute("value")
};
adjuster.Conditions.Add(condition);

View File

@@ -150,68 +150,68 @@ namespace SabreTools.Library.DatFiles
switch (reader.Name)
{
case "name":
content = reader.ReadElementContentAsString(); ;
Header.Name = (Header.Name == null ? content : Header.Name);
content = reader.ReadElementContentAsString();
Header.Name = Header.Name ?? content;
superdat = superdat || content.Contains(" - SuperDAT");
if (keep && superdat)
{
Header.Type = (Header.Type == null ? "SuperDAT" : Header.Type);
Header.Type = Header.Type ?? "SuperDAT";
}
break;
case "description":
content = reader.ReadElementContentAsString();
Header.Description = (Header.Description == null ? content : Header.Description);
Header.Description = Header.Description ?? content;
break;
case "rootdir": // This is exclusive to TruRip XML
content = reader.ReadElementContentAsString();
Header.RootDir = (Header.RootDir == null ? content : Header.RootDir);
Header.RootDir = Header.RootDir ?? content;
break;
case "category":
content = reader.ReadElementContentAsString();
Header.Category = (Header.Category == null ? content : Header.Category);
Header.Category = Header.Category ?? content;
break;
case "version":
content = reader.ReadElementContentAsString();
Header.Version = (Header.Version == null ? content : Header.Version);
Header.Version = Header.Version ?? content;
break;
case "date":
content = reader.ReadElementContentAsString();
Header.Date = (Header.Date == null ? content.Replace(".", "/") : Header.Date);
Header.Date = Header.Date ?? content.Replace(".", "/");
break;
case "author":
content = reader.ReadElementContentAsString();
Header.Author = (Header.Author == null ? content : Header.Author);
Header.Author = Header.Author ?? content;
break;
case "email":
content = reader.ReadElementContentAsString();
Header.Email = (Header.Email == null ? content : Header.Email);
Header.Email = Header.Email ?? content;
break;
case "homepage":
content = reader.ReadElementContentAsString();
Header.Homepage = (Header.Homepage == null ? content : Header.Homepage);
Header.Homepage = Header.Homepage ?? content;
break;
case "url":
content = reader.ReadElementContentAsString();
Header.Url = (Header.Url == null ? content : Header.Url);
Header.Url = Header.Url ?? content;
break;
case "comment":
content = reader.ReadElementContentAsString();
Header.Comment = (Header.Comment == null ? content : Header.Comment);
Header.Comment = (Header.Comment ?? content);
break;
case "type": // This is exclusive to TruRip XML
content = reader.ReadElementContentAsString();
Header.Type = (Header.Type == null ? content : Header.Type);
Header.Type = Header.Type ?? content;
superdat = superdat || content.Contains("SuperDAT");
break;

View File

@@ -122,34 +122,34 @@ namespace SabreTools.Library.DatFiles
{
case "datname":
content = reader.ReadElementContentAsString();
Header.Name = (Header.Name == null ? content : Header.Name);
Header.Name = Header.Name ?? content;
superdat = superdat || content.Contains(" - SuperDAT");
if (keep && superdat)
{
Header.Type = (Header.Type == null ? "SuperDAT" : Header.Type);
Header.Type = Header.Type ?? "SuperDAT";
}
break;
case "datversion":
content = reader.ReadElementContentAsString();
Header.Version = (Header.Version == null ? content : Header.Version);
Header.Version = Header.Version ?? content;
break;
case "system":
content = reader.ReadElementContentAsString();
Header.System = (Header.System == null ? content : Header.System);
Header.System = Header.System ?? content;
break;
// TODO: Int32?
case "screenshotswidth":
content = reader.ReadElementContentAsString();
Header.ScreenshotsWidth = (Header.ScreenshotsWidth == null ? content : Header.ScreenshotsWidth);
Header.ScreenshotsWidth = Header.ScreenshotsWidth ?? content;
break;
// TODO: Int32?
case "screenshotsheight":
content = reader.ReadElementContentAsString();
Header.ScreenshotsHeight = (Header.ScreenshotsHeight == null ? content : Header.ScreenshotsHeight);
Header.ScreenshotsHeight = Header.ScreenshotsHeight ?? content;
break;
case "infos":
@@ -184,7 +184,7 @@ namespace SabreTools.Library.DatFiles
case "romtitle":
content = reader.ReadElementContentAsString();
Header.RomTitle = (Header.RomTitle == null ? content : Header.RomTitle);
Header.RomTitle = Header.RomTitle ?? content;
break;
default:
@@ -224,11 +224,13 @@ namespace SabreTools.Library.DatFiles
switch (reader.Name.ToLowerInvariant())
{
case "info":
var info = new OfflineListInfo();
info.Name = reader.Name.ToLowerInvariant();
info.Visible = reader.GetAttribute("visible").AsYesNo();
info.InNamingOption = reader.GetAttribute("inNamingOption").AsYesNo();
info.Default = reader.GetAttribute("default").AsYesNo();
var info = new OfflineListInfo
{
Name = reader.Name.ToLowerInvariant(),
Visible = reader.GetAttribute("visible").AsYesNo(),
InNamingOption = reader.GetAttribute("inNamingOption").AsYesNo(),
Default = reader.GetAttribute("default").AsYesNo()
};
Header.Infos.Add(info);

View File

@@ -56,9 +56,9 @@ namespace SabreTools.Library.DatFiles
switch (xtr.Name)
{
case "softwaredb":
Header.Name = (Header.Name == null ? "openMSX Software List" : Header.Name);
Header.Description = (Header.Description == null ? Header.Name : Header.Description);
Header.Date = (Header.Date == null ? xtr.GetAttribute("timestamp") : Header.Date);
Header.Name = Header.Name ?? "openMSX Software List";
Header.Description = Header.Description ?? Header.Name;
Header.Date = Header.Date ?? xtr.GetAttribute("timestamp");
xtr.Read();
break;
@@ -242,9 +242,11 @@ namespace SabreTools.Library.DatFiles
break;
case "original":
original = new Original();
original.Value = reader.GetAttribute("value").AsYesNo();
original.Content = reader.ReadElementContentAsString();
original = new Original
{
Value = reader.GetAttribute("value").AsYesNo(),
Content = reader.ReadElementContentAsString()
};
break;
default:

View File

@@ -203,12 +203,12 @@ namespace SabreTools.Library.DatFiles
switch (kvp?.Key.ToLowerInvariant())
{
case "version":
Header.RomCenterVersion = Header.RomCenterVersion ?? (kvp?.Value);
Header.RomCenterVersion = Header.RomCenterVersion ?? kvp?.Value;
reader.ReadNextLine();
break;
case "plugin":
Header.System = (Header.System == null ? kvp?.Value : Header.System);
Header.System = Header.System ?? kvp?.Value;
reader.ReadNextLine();
break;
@@ -267,12 +267,12 @@ namespace SabreTools.Library.DatFiles
switch (kvp?.Key.ToLowerInvariant())
{
case "refname":
Header.Name = Header.Name == null ? kvp?.Value : Header.Name;
Header.Name = Header.Name ?? kvp?.Value;
reader.ReadNextLine();
break;
case "version":
Header.Description = Header.Description == null ? kvp?.Value : Header.Description;
Header.Description = Header.Description ?? kvp?.Value;
reader.ReadNextLine();
break;

View File

@@ -58,8 +58,8 @@ namespace SabreTools.Library.DatFiles
switch (xtr.Name)
{
case "softwarelist":
Header.Name = (Header.Name == null ? xtr.GetAttribute("name") ?? string.Empty : Header.Name);
Header.Description = (Header.Description == null ? xtr.GetAttribute("description") ?? string.Empty : Header.Description);
Header.Name = Header.Name ?? xtr.GetAttribute("name") ?? string.Empty;
Header.Description = Header.Description ?? xtr.GetAttribute("description") ?? string.Empty;
xtr.Read();
break;

View File

@@ -21,7 +21,7 @@ namespace SabreTools.Library.Filtering
/// <summary>
/// Logging object
/// </summary>
private Logger logger = new Logger();
private readonly Logger logger = new Logger();
#endregion

View File

@@ -291,7 +291,7 @@ namespace SabreTools.Library.Filtering
/// <summary>
/// Logging object
/// </summary>
private Logger logger = new Logger();
private readonly Logger logger = new Logger();
#endregion

View File

@@ -18,7 +18,7 @@ namespace SabreTools.Library.Help
/// <summary>
/// Logging object
/// </summary>
private Logger logger = new Logger();
private readonly Logger logger = new Logger();
#endregion

View File

@@ -23,7 +23,7 @@ namespace SabreTools.Library.IO
/// <summary>
/// Logging object
/// </summary>
private static Logger logger = new Logger();
private static readonly Logger logger = new Logger();
#endregion

View File

@@ -11,7 +11,7 @@ namespace SabreTools.Library.Logging
/// Instance associated with this logger
/// </summary>
/// TODO: Derive class name for this object, if possible
private object instance;
private readonly object instance;
/// <summary>
/// Constructor

View File

@@ -43,7 +43,7 @@ namespace SabreTools.Library.Skippers
/// <summary>
/// Logging object
/// </summary>
private Logger logger = new Logger();
private readonly Logger logger = new Logger();
#endregion

View File

@@ -37,7 +37,7 @@ namespace SabreTools.Library.Skippers
/// <summary>
/// Logging object
/// </summary>
private static Logger logger = new Logger();
private static readonly Logger logger = new Logger();
#endregion

View File

@@ -18,7 +18,7 @@ namespace SabreTools.Library.Tools
/// <summary>
/// Logging object
/// </summary>
private static Logger logger = new Logger();
private static readonly Logger logger = new Logger();
#endregion

View File

@@ -11,7 +11,7 @@ namespace SabreTools.Library.Tools
{
private string _subject;
private DateTime _startTime;
private Logger _logger = new Logger();
private readonly Logger _logger = new Logger();
/// <summary>
/// Constructor that initalizes the stopwatch

View File

@@ -20,7 +20,7 @@ namespace SabreTools
/// <summary>
/// Logging object
/// </summary>
private static Logger logger = new Logger();
private static readonly Logger logger = new Logger();
#endregion