Fix some external project analyzer warnings

This commit is contained in:
Morilli 2024-05-29 09:40:53 +02:00
parent bd786a0e95
commit 7a789fb853
13 changed files with 89 additions and 101 deletions

View File

@ -244,8 +244,8 @@ namespace Jellyfish.Virtu
return ret;
}
public static bool WhiteAppleDown;
public static bool BlackAppleDown;
public static bool WhiteAppleDown { get; private set; }
public static bool BlackAppleDown { get; private set; }
/// <summary>
/// Call this at 60hz with all of the currently pressed keys

View File

@ -373,7 +373,7 @@ namespace BizHawk.Experiment.AutoGenConfig
protected override string SerializeTValue(string? v) => v == null ? NULL_SERIALIZATION : $"\"{v}\"";
protected override bool TValueEquality(string? a, string? b) => string.Equals(a, b) || string.IsNullOrEmpty(a) && string.IsNullOrEmpty(b);
protected override bool TValueEquality(string? a, string? b) => a == b || string.IsNullOrEmpty(a) && string.IsNullOrEmpty(b);
}
public sealed class UnrepresentablePropEditorUIGen : ConfigPropEditorUIGen<GroupBox, object?>

View File

@ -3,7 +3,6 @@ using System.Drawing;
using System.Windows.Forms;
using BizHawk.Client.Common;
using BizHawk.Common;
using BizHawk.Client.EmuHawk;
namespace BizHawk.DATTool

View File

@ -1,5 +1,5 @@
#nullable disable
using System;
using System.Collections.Generic;
using System.Text;
@ -53,13 +53,13 @@ namespace BizHawk.DATTool
{
// hash
sb.Append(d.HASH);
sb.Append("\t");
sb.Append('\t');
// status
sb.Append(d.Status);
sb.Append("\t");
sb.Append('\t');
// name
sb.Append(d.Name);
sb.Append("\t");
sb.Append('\t');
// system
sb.Append(d.System);
@ -89,37 +89,37 @@ namespace BizHawk.DATTool
// notes
if (d.Notes != null)
{
sb.Append("\t");
sb.Append('\t');
sb.Append(d.Notes);
}
else if (cnt++ <= last)
{
sb.Append("\t");
sb.Append('\t');
}
// metadata
if (d.MetaData != null)
{
sb.Append("\t");
sb.Append('\t');
sb.Append(d.MetaData);
}
else if (cnt++ <= last)
{
sb.Append("\t");
sb.Append('\t');
}
// region
if (d.Region != null)
{
sb.Append("\t");
sb.Append('\t');
sb.Append(d.Region);
}
else if (cnt++ <= last)
{
sb.Append("\t");
sb.Append('\t');
}
// force core
if (d.ForcedCore != null)
{
sb.Append("\t");
sb.Append('\t');
sb.Append(d.ForcedCore);
}
@ -137,8 +137,8 @@ namespace BizHawk.DATTool
// COL0: Hash
public string SHA1 { get; set; }
public string MD5 { get; set; }
public string CRC32 { get; set; }
// COL1: Status code indicator
public string CRC32 { get; set; }
// COL1: Status code indicator
public string Status { get; set; }
// COL2: Game title
public string Name { get; set; }
@ -160,9 +160,9 @@ namespace BizHawk.DATTool
{
if (!string.IsNullOrWhiteSpace(SHA1))
return "SHA1:" + SHA1;
else if (!string.IsNullOrWhiteSpace(MD5))
return "MD5:" + MD5;
else if (!string.IsNullOrWhiteSpace(CRC32))
else if (!string.IsNullOrWhiteSpace(MD5))
return "MD5:" + MD5;
else if (!string.IsNullOrWhiteSpace(CRC32))
return "CRC32:" + CRC32;
throw new InvalidOperationException("No valid hash available?");

View File

@ -5,6 +5,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;
using System.Windows.Forms;
using BizHawk.Common.StringExtensions;
namespace BizHawk.DATTool
{
@ -69,9 +70,9 @@ namespace BizHawk.DATTool
{
GameDB item = new GameDB();
item.Name = g.Value;
item.SHA1 = g.Elements("rom").First().Attribute("sha1").Value.ToUpper();
item.MD5 = g.Elements("rom").First().Attribute("md5").Value.ToUpper();
item.CRC32 = g.Elements("rom").First().Attribute("crc").Value.ToUpper();
item.SHA1 = g.Elements("rom").First().Attribute("sha1").Value.ToUpperInvariant();
item.MD5 = g.Elements("rom").First().Attribute("md5").Value.ToUpperInvariant();
item.CRC32 = g.Elements("rom").First().Attribute("crc").Value.ToUpperInvariant();
item.System = GameDB.GetSystemCode(SysType);
ParseNOINTROFlags(item);
@ -99,7 +100,7 @@ namespace BizHawk.DATTool
AddCommentBlock("Translated");
AppendCSVData(trans);
var good = working.Where(st => st.Status == "" || st.Status == null).OrderBy(na => na.Name).ToList();
var good = working.Where(st => string.IsNullOrEmpty(st.Status)).OrderBy(na => na.Name).ToList();
AddCommentBlock("Believed Good");
AppendCSVData(good);
}
@ -146,7 +147,7 @@ namespace BizHawk.DATTool
string f = d[i].Trim();
// check for language
if (IsLanguageFlag(f) == true)
if (IsLanguageFlag(f))
{
g.Notes = f;
continue;
@ -155,26 +156,26 @@ namespace BizHawk.DATTool
// version - ignore
// check development status (not currently implemented)
if (IsDevelopmenttStatus(f) == true)
if (IsDevelopmenttStatus(f))
{
continue;
}
// check copyright status (not currently implemented)
if (IsCopyrightStatus(f) == true)
if (IsCopyrightStatus(f))
{
continue;
}
// country flag(s)
if (IsCountryFlag(f) == true)
if (IsCountryFlag(f))
{
g.Region = f;
continue;
}
// language - if present add to notes
if (IsLanguageFlag(f) == true)
if (IsLanguageFlag(f))
{
g.Notes = f;
continue;
@ -207,14 +208,14 @@ namespace BizHawk.DATTool
if (e.Where(str =>
// bad dump
str == "b" || str.StartsWith("b ")).ToList().Count > 0)
str == "b" || str.StartsWithOrdinal("b ")).ToList().Count > 0)
{
// RomStatus.BadDump
g.Status = "B";
}
else if (e.Where(str =>
// BIOS
str == "BIOS" || str.StartsWith("BIOS ")).ToList().Count > 0)
str == "BIOS" || str.StartsWithOrdinal("BIOS ")).ToList().Count > 0)
{
// RomStatus.BIOS
g.Status = "I";
@ -259,7 +260,7 @@ namespace BizHawk.DATTool
{
foreach (var x in LC)
{
if (s == x || s.StartsWith(x + ",") || s.EndsWith("," + x))
if (s == x || s.StartsWithOrdinal(x + ",") || s.EndsWithOrdinal("," + x))
{
b = true;
break;
@ -286,7 +287,7 @@ namespace BizHawk.DATTool
{
foreach (var x in CC)
{
if (s == x || s.StartsWith(x) || s.EndsWith(x))
if (s == x || s.StartsWithOrdinal(x) || s.EndsWithOrdinal(x))
{
b = true;
break;

View File

@ -6,6 +6,8 @@ using System.Linq;
using System.Xml.Linq;
using System.Windows.Forms;
using BizHawk.Common.StringExtensions;
namespace BizHawk.DATTool
{
public class TOSECParser : DATParser
@ -70,9 +72,9 @@ namespace BizHawk.DATTool
{
GameDB item = new GameDB();
item.Name = g.Value;
item.SHA1 = g.Elements("rom").First().Attribute("sha1").Value.ToUpper();
item.MD5 = g.Elements("rom").First().Attribute("md5").Value.ToUpper();
item.CRC32 = g.Elements("rom").First().Attribute("crc").Value.ToUpper();
item.SHA1 = g.Elements("rom").First().Attribute("sha1").Value.ToUpperInvariant();
item.MD5 = g.Elements("rom").First().Attribute("md5").Value.ToUpperInvariant();
item.CRC32 = g.Elements("rom").First().Attribute("crc").Value.ToUpperInvariant();
item.System = GameDB.GetSystemCode(SysType);
ParseTOSECFlags(item);
@ -104,7 +106,7 @@ namespace BizHawk.DATTool
AddCommentBlock("Home Brew");
AppendCSVData(pd);
var good = working.Where(st => st.Status == "" || st.Status == null).OrderBy(na => na.Name).ToList();
var good = working.Where(st => string.IsNullOrEmpty(st.Status)).OrderBy(na => na.Name).ToList();
AddCommentBlock("Believed Good");
AppendCSVData(good);
}
@ -171,27 +173,27 @@ namespace BizHawk.DATTool
}
// country flag(s)
if (IsCountryFlag(f) == true)
if (IsCountryFlag(f))
{
g.Region = f;
continue;
}
// language - if present add to notes
if (IsLanguageFlag(f) == true)
if (IsLanguageFlag(f))
{
g.Notes = f;
continue;
}
// check copyright status (not currently implemented)
if (IsCopyrightStatus(f) == true)
if (IsCopyrightStatus(f))
{
continue;
}
// check development status (not currently implemented)
if (IsDevelopmenttStatus(f) == true)
if (IsDevelopmenttStatus(f))
{
continue;
}
@ -225,28 +227,28 @@ namespace BizHawk.DATTool
if (e.Where(str =>
// bad dump
str == "b" || str.StartsWith("b ") ||
str == "b" || str.StartsWithOrdinal("b ") ||
// virus
str == "v" || str.StartsWith("v ") ||
str == "v" || str.StartsWithOrdinal("v ") ||
// under dump
str == "u" || str.StartsWith("u ")).ToList().Count > 0)
str == "u" || str.StartsWithOrdinal("u ")).ToList().Count > 0)
{
// RomStatus.BadDump
g.Status = "B";
}
else if (e.Where(str =>
// cracked
str == "cr" || str.StartsWith("cr ") ||
str == "cr" || str.StartsWithOrdinal("cr ") ||
// fixed
str == "f" || str.StartsWith("f ") ||
str == "f" || str.StartsWithOrdinal("f ") ||
// hack
str == "h" || str.StartsWith("h ") ||
str == "h" || str.StartsWithOrdinal("h ") ||
// modified
str == "m" || str.StartsWith("m ") ||
str == "m" || str.StartsWithOrdinal("m ") ||
// pirated
str == "p" || str.StartsWith("p ") ||
str == "p" || str.StartsWithOrdinal("p ") ||
// trained
str == "t" || str.StartsWith("t ")
str == "t" || str.StartsWithOrdinal("t ")
).ToList().Count > 0)
{
// RomStatus.Hack
@ -254,7 +256,7 @@ namespace BizHawk.DATTool
}
else if (e.Where(str =>
// over dump
str == "o" || str.StartsWith("o ")).ToList().Count > 0)
str == "o" || str.StartsWithOrdinal("o ")).ToList().Count > 0)
{
// RomStatus.Overdump
g.Status = "O";
@ -268,7 +270,7 @@ namespace BizHawk.DATTool
}
else if (e.Where(str =>
// translated
str == "tr" || str.StartsWith("tr ")).ToList().Count > 0)
str == "tr" || str.StartsWithOrdinal("tr ")).ToList().Count > 0)
{
// RomStatus.TranslatedRom
g.Status = "T";
@ -312,7 +314,7 @@ namespace BizHawk.DATTool
{
foreach (var x in LC)
{
if (s == x || s.StartsWith(x) || s.EndsWith(x))
if (s == x || s.StartsWithOrdinal(x) || s.EndsWithOrdinal(x))
{
b = true;
break;
@ -342,7 +344,7 @@ namespace BizHawk.DATTool
{
foreach (var x in CC)
{
if (s == x || s.StartsWith(x) || s.EndsWith(x))
if (s == x || s.StartsWithOrdinal(x) || s.EndsWithOrdinal(x))
{
b = true;
break;

View File

@ -3,7 +3,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BizHawk.Common.StringExtensions;
using Community.CsharpSqlite.SQLiteClient;
namespace BizHawk.DBManTool
@ -45,7 +45,7 @@ namespace BizHawk.DBManTool
{
get
{
if (!Name.EndsWith(", The")) return Name;
if (!Name.EndsWithOrdinal(", The")) return Name;
return "The "+Name.Substring(0, Name.Length-5);
}
}
@ -110,11 +110,11 @@ namespace BizHawk.DBManTool
public static class DB
{
public static List<Rom> Roms = new List<Rom>();
public static List<Game> Games = new List<Game>();
public static Dictionary<string, Game> GameMap = new Dictionary<string, Game>();
public static List<Rom> Roms { get; private set; } = new List<Rom>();
public static List<Game> Games { get; } = new List<Game>();
public static Dictionary<string, Game> GameMap { get; } = new Dictionary<string, Game>();
public static SqliteConnection Con;
public static SqliteConnection Con { get; set; }
public static void LoadDbForSystem(string system)
{
@ -455,4 +455,4 @@ namespace BizHawk.DBManTool
cmd.Dispose();
}
}
}
}

View File

@ -1,13 +1,8 @@
#nullable disable
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace BizHawk.DBManTool
@ -157,7 +152,7 @@ namespace BizHawk.DBManTool
void saveButton_Click(object sender, EventArgs e)
{
// Check if any changes were made
if (SelectedRom.New == false && RomChangesMade() == false)
if (!SelectedRom.New && !RomChangesMade())
return;
int saveMode = 0;
@ -197,7 +192,7 @@ namespace BizHawk.DBManTool
if (romListView.SelectedItems.Count > 0)
{
// Update the side listing
var romListItem = (ListViewItem)romListView.SelectedItems[0];
var romListItem = romListView.SelectedItems[0];
romListItem.SubItems[0] = new ListViewItem.ListViewSubItem(romListItem, SelectedRom.DisplayName);
romListItem.SubItems[1] = new ListViewItem.ListViewSubItem(romListItem, SelectedRom.Region);
romListItem.SubItems[2] = new ListViewItem.ListViewSubItem(romListItem, SelectedRom.VersionTags);
@ -303,14 +298,14 @@ namespace BizHawk.DBManTool
string regionStr = "";
if (rom.Region != null)
{
if (rom.Region.IndexOf("Japan") >= 0) regionStr += "J";
if (rom.Region.IndexOf("USA") >= 0) regionStr += "U";
if (rom.Region.IndexOf("Europe") >= 0) regionStr += "E";
if (rom.Region.IndexOf("Brazil") >= 0) regionStr += "B";
if (rom.Region.IndexOf("Taiwan") >= 0) regionStr += "T";
if (rom.Region.IndexOf("Korea") >= 0) regionStr += "K";
if (rom.Region.IndexOf("Australia") >= 0) regionStr += "Aus";
if (rom.Region.IndexOf("World") >= 0) regionStr += "W";
if (rom.Region.Contains("Japan")) regionStr += "J";
if (rom.Region.Contains("USA")) regionStr += "U";
if (rom.Region.Contains("Europe")) regionStr += "E";
if (rom.Region.Contains("Brazil")) regionStr += "B";
if (rom.Region.Contains("Taiwan")) regionStr += "T";
if (rom.Region.Contains("Korea")) regionStr += "K";
if (rom.Region.Contains("Australia")) regionStr += "Aus";
if (rom.Region.Contains("World")) regionStr += "W";
}
string romName = rom.NameWithTheFlipped;
@ -344,4 +339,4 @@ namespace BizHawk.DBManTool
loadRomsForSelectedSystem();
}
}
}
}

View File

@ -18,7 +18,7 @@ namespace BizHawk.DBManTool
foreach (var f in files)
{
if (IsRomFile(f.Extension, f.Length) == false)
if (!IsRomFile(f.Extension, f.Length))
continue;
romInfos.Add(RomHasher.Generate(f.FullName));
}
@ -56,11 +56,11 @@ namespace BizHawk.DBManTool
foreach (var rom in roms)
{
if (RomInDatabase(rom.MD5) == false)
if (!RomInDatabase(rom.MD5))
{
InsertRom(rom);
if (GameInDatabase(rom) == false)
if (!GameInDatabase(rom))
InsertGame(rom);
}
}

View File

@ -1,20 +1,16 @@
#nullable disable
using System;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using System.Linq;
using System.IO;
using System.Collections.Generic;
using BizHawk.Common;
using BizHawk.Emulation.DiscSystem;
namespace BizHawk.DBManTool
{
class DiscHash
{
static List<string> FindExtensionsRecurse(string dir, string extUppercaseWithDot)
{
List<string> ret = new List<string>();
@ -44,7 +40,6 @@ namespace BizHawk.DBManTool
public void Run(string[] args)
{
string indir = null;
string dpTemp = null;
string fpOutfile = null;
@ -109,10 +104,10 @@ namespace BizHawk.DBManTool
progress++;
Console.WriteLine("{0}/{1} [{2}] {3}", progress, todo.Count, bizHashId, Path.GetFileNameWithoutExtension(fiCue));
outf.WriteLine("bizhash:{0} datahash:{1:X8} //{2}", bizHashId, redumpHash, name);
if (FoundHashes.ContainsKey(bizHashId))
if (FoundHashes.TryGetValue(bizHashId, out string foundBizHashId))
{
Console.WriteLine("--> COLLISION WITH: {0}", FoundHashes[bizHashId]);
outf.WriteLine("--> COLLISION WITH: {0}", FoundHashes[bizHashId]);
Console.WriteLine("--> COLLISION WITH: {0}", foundBizHashId);
outf.WriteLine("--> COLLISION WITH: {0}", foundBizHashId);
}
else
FoundHashes[bizHashId] = name;
@ -130,4 +125,4 @@ namespace BizHawk.DBManTool
} //MyRun()
} //class PsxRedump
}
}

View File

@ -3,15 +3,11 @@
using System;
using System.Globalization;
using System.IO;
using System.Xml;
using System.Xml.Linq;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BizHawk.Common;
using BizHawk.Emulation.DiscSystem;
namespace BizHawk.DBManTool
{
@ -61,8 +57,7 @@ namespace BizHawk.DBManTool
Console.WriteLine("merging");
foreach (var rr in rdpsx.Records)
{
HashRecord hr;
if (!hashes.TryGetValue(rr.crc, out hr))
if (!hashes.TryGetValue(rr.crc, out var hr))
continue;
hr.matched = true;
//correct name to redump current
@ -109,8 +104,8 @@ namespace BizHawk.DBManTool
CRC32 spec_crc_calc = new() { Current = 0 }; //TODO is the current usage (invert initial state, don't invert final state) equivalent to only inverting the final state? --yoshi
foreach (var rom in game.Elements("rom"))
{
var ext = Path.GetExtension(rom.Attribute("name").Value).ToLower();
if (ext == ".cue") continue;
var ext = Path.GetExtension(rom.Attribute("name").Value);
if (ext.Equals(".cue", StringComparison.OrdinalIgnoreCase)) continue;
uint onecrc = uint.Parse(rom.Attribute("crc").Value, NumberStyles.HexNumber);
int size = int.Parse(rom.Attribute("size").Value);
spec_crc_calc.Incorporate(onecrc, size);
@ -125,4 +120,4 @@ namespace BizHawk.DBManTool
}
}
}
}
}

View File

@ -6,6 +6,7 @@ using System.IO;
using System.Text;
using BizHawk.Common;
using BizHawk.Common.StringExtensions;
using BizHawk.Emulation.DiscSystem;
namespace BizHawk.DBManTool
@ -48,7 +49,7 @@ namespace BizHawk.DBManTool
// Parse the filename to guess things about the rom
var name = Path.GetFileNameWithoutExtension(fileInfo.Name);
if (name.StartsWith("[BIOS] "))
if (name.StartsWithOrdinal("[BIOS] "))
name = name.Replace("[BIOS] ","") + " [BIOS]";
string modifiers = "";
@ -78,7 +79,7 @@ namespace BizHawk.DBManTool
if (info.VersionTags.Length != 0)
info.VersionTags += ";";
switch (mi.ToLower())
switch (mi.ToLowerInvariant())
{
case "j":
case "jp":
@ -260,4 +261,4 @@ namespace BizHawk.DBManTool
return false;
}
}
}
}

Binary file not shown.