mirror of
https://github.com/MoleskiCoder/EightBitNet.git
synced 2025-04-28 05:49:27 +00:00
.net 9 analysis
This commit is contained in:
parent
515c679e68
commit
c0a964fadb
@ -23,7 +23,7 @@ namespace Fuse
|
||||
while (!reader.EndOfStream)
|
||||
{
|
||||
var line = reader.ReadLine();
|
||||
Debug.Assert(line != null);
|
||||
Debug.Assert(line is not null);
|
||||
var ignored = line.StartsWith(';');
|
||||
if (!ignored)
|
||||
{
|
||||
|
@ -67,7 +67,7 @@
|
||||
this.Raise("Y", final.Y, cpu.Y);
|
||||
this.Raise("P", final.P, cpu.P);
|
||||
|
||||
if (test.Cycles == null)
|
||||
if (test.Cycles is null)
|
||||
{
|
||||
throw new InvalidOperationException("test cycles cannot be null");
|
||||
}
|
||||
@ -208,7 +208,7 @@
|
||||
this.Messages.Add($"Actual flags : {Disassembler.DumpFlags(cpu.P)}");
|
||||
}
|
||||
|
||||
if (final.RAM == null)
|
||||
if (final.RAM is null)
|
||||
{
|
||||
throw new InvalidOperationException("Expected RAM cannot be null");
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ namespace M6502.HarteTest
|
||||
var tests = opcode.TestsAsync;
|
||||
await foreach (var test in tests)
|
||||
{
|
||||
if (test == null)
|
||||
if (test is null)
|
||||
{
|
||||
throw new InvalidOperationException("Test cannot be null");
|
||||
}
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
public IEnumerable<Cycle> AvailableCycles()
|
||||
{
|
||||
if (this.Cycles == null)
|
||||
if (this.Cycles is null)
|
||||
{
|
||||
throw new InvalidOperationException("Cycles have not been initialised");
|
||||
}
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
private bool MaybeExtractFromParsed(string key, out string? value)
|
||||
{
|
||||
Debug.Assert(this._parsed != null);
|
||||
Debug.Assert(this._parsed is not null);
|
||||
var found = this._parsed.TryGetValue(key, out var extracted);
|
||||
value = extracted;
|
||||
return found;
|
||||
@ -23,14 +23,14 @@
|
||||
private bool MaybeExtractIntegerFromParsed(string key, out int value)
|
||||
{
|
||||
var available = this.MaybeExtractFromParsed(key, out var extracted);
|
||||
value = extracted == null ? 0 : ExtractInteger(extracted);
|
||||
value = extracted is null ? 0 : ExtractInteger(extracted);
|
||||
return available;
|
||||
}
|
||||
|
||||
protected bool MaybeExtractCompoundInteger(string key, out List<int> value)
|
||||
{
|
||||
var available = this.MaybeExtractFromParsed(key, out var extracted);
|
||||
value = extracted == null ? [] : ExtractCompoundInteger(extracted);
|
||||
value = extracted is null ? [] : ExtractCompoundInteger(extracted);
|
||||
return available;
|
||||
}
|
||||
|
||||
@ -38,7 +38,7 @@
|
||||
{
|
||||
var type = this.GetType();
|
||||
var property = type.GetProperty(name);
|
||||
Debug.Assert(property != null);
|
||||
Debug.Assert(property is not null);
|
||||
property.SetValue(this, obj);
|
||||
}
|
||||
|
||||
@ -66,23 +66,23 @@
|
||||
// The reference container in the parent class
|
||||
var referenceSectionProperties = GetSectionProperties(type);
|
||||
var referenceClassAttribute = referenceSectionProperties.ClassAttribute;
|
||||
Debug.Assert(referenceClassAttribute != null);
|
||||
Debug.Assert(referenceClassAttribute is not null);
|
||||
var referencingContainer = referenceClassAttribute.Referencing;
|
||||
|
||||
// Get the parent container field
|
||||
var containerType = this._container.GetType();
|
||||
Debug.Assert(referencingContainer != null);
|
||||
Debug.Assert(referencingContainer is not null);
|
||||
var containerField = containerType.GetField(referencingContainer);
|
||||
Debug.Assert(containerField != null);
|
||||
Debug.Assert(containerField is not null);
|
||||
var fieldValue = containerField.GetValue(this._container);
|
||||
var fieldList = fieldValue as IList;
|
||||
|
||||
// Now get the referenced object from the parent container field (via ID as an index)
|
||||
Debug.Assert(fieldList != null);
|
||||
Debug.Assert(fieldList is not null);
|
||||
var referencingObject = fieldList[id];
|
||||
|
||||
// Now set our reference field
|
||||
Debug.Assert(referencingObject != null);
|
||||
Debug.Assert(referencingObject is not null);
|
||||
this.SetProperty(name, referencingObject);
|
||||
}
|
||||
|
||||
@ -105,23 +105,23 @@
|
||||
// The reference container in the parent class
|
||||
//var referenceSectionProperties = GetSectionProperties(type);
|
||||
//var referenceClassAttribute = referenceSectionProperties.ClassAttribute;
|
||||
//Debug.Assert(referenceClassAttribute != null);
|
||||
//Debug.Assert(referenceClassAttribute is not null);
|
||||
//var referencingContainer = referenceClassAttribute.Referencing;
|
||||
|
||||
// Get the parent container field
|
||||
//var containerType = this._container.GetType();
|
||||
//Debug.Assert(referencingContainer != null);
|
||||
//Debug.Assert(referencingContainer is not null);
|
||||
//var containerField = containerType.GetField(referencingContainer);
|
||||
//Debug.Assert(containerField != null);
|
||||
//Debug.Assert(containerField is not null);
|
||||
//var fieldValue = containerField.GetValue(this._container);
|
||||
//var fieldList = fieldValue as IList;
|
||||
|
||||
// Now get the referenced object from the parent container field (via ID as an index)
|
||||
//Debug.Assert(fieldList != null);
|
||||
//Debug.Assert(fieldList is not null);
|
||||
//var referencingObject = fieldList[id];
|
||||
|
||||
//// Now set our reference field
|
||||
//Debug.Assert(referencingObject != null);
|
||||
//Debug.Assert(referencingObject is not null);
|
||||
//this.SetProperty(name, referencingObject);
|
||||
}
|
||||
}
|
||||
|
@ -97,7 +97,7 @@
|
||||
var scope = this.AddressableScopes[mid];
|
||||
|
||||
var symbol = scope.Symbol;
|
||||
Debug.Assert(symbol != null);
|
||||
Debug.Assert(symbol is not null);
|
||||
var start = symbol.Value;
|
||||
|
||||
if (address < start)
|
||||
@ -142,9 +142,9 @@
|
||||
|
||||
private static List<Scope> EvaluateScope(Scope? start)
|
||||
{
|
||||
Debug.Assert(start != null);
|
||||
Debug.Assert(start is not null);
|
||||
var returned = new List<Scope>();
|
||||
for (var current = start; current.Parent != null; current = current.Parent)
|
||||
for (var current = start; current.Parent is not null; current = current.Parent)
|
||||
{
|
||||
returned.Add(current);
|
||||
}
|
||||
@ -196,7 +196,7 @@
|
||||
{
|
||||
var symbol = this.LookupLabelByAddress(absolute);
|
||||
label = PrefixNamespace(symbol);
|
||||
return symbol != null;
|
||||
return symbol is not null;
|
||||
}
|
||||
|
||||
public string MaybeGetQualifiedLabelByAddress(ushort absolute) => this.TryGetQualifiedLabelByAddress(absolute, out var label) ? label : string.Empty;
|
||||
@ -205,7 +205,7 @@
|
||||
{
|
||||
var symbol = this.LookupEquateByValue(value);
|
||||
name = PrefixNamespace(symbol);
|
||||
return symbol != null;
|
||||
return symbol is not null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
@ -274,14 +274,14 @@
|
||||
private T ExtractEntry<T>(Dictionary<string, string> information) where T : Section
|
||||
{
|
||||
var entry = (T?)Activator.CreateInstance(typeof(T), this);
|
||||
Debug.Assert(entry != null);
|
||||
Debug.Assert(entry is not null);
|
||||
entry.Parse(information);
|
||||
return entry;
|
||||
}
|
||||
|
||||
private void VerifyInformationCount(string key, int actual)
|
||||
{
|
||||
Debug.Assert(this._information != null);
|
||||
Debug.Assert(this._information is not null);
|
||||
var expected = this._information.Count(key);
|
||||
if (expected != actual)
|
||||
{
|
||||
@ -302,7 +302,7 @@
|
||||
|
||||
private void BuildAddressableScopes()
|
||||
{
|
||||
var scopes = from scope in this.Scopes where scope.Symbol != null select scope;
|
||||
var scopes = from scope in this.Scopes where scope.Symbol is not null select scope;
|
||||
this.AddressableScopes.AddRange(scopes);
|
||||
}
|
||||
|
||||
@ -331,7 +331,7 @@
|
||||
while (!reader.EndOfStream)
|
||||
{
|
||||
var line = await reader.ReadLineAsync().ConfigureAwait(false);
|
||||
if (line == null)
|
||||
if (line is null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
@ -350,7 +350,7 @@
|
||||
|
||||
if (key is "version")
|
||||
{
|
||||
if (this._version != null)
|
||||
if (this._version is not null)
|
||||
{
|
||||
throw new InvalidOperationException("Version object has already been parsed");
|
||||
}
|
||||
@ -360,7 +360,7 @@
|
||||
}
|
||||
else if (key is "info")
|
||||
{
|
||||
if (this._information != null)
|
||||
if (this._information is not null)
|
||||
{
|
||||
throw new InvalidOperationException("Information object has already been parsed");
|
||||
}
|
||||
@ -403,7 +403,7 @@
|
||||
|
||||
private void VerifyVersion()
|
||||
{
|
||||
if (this._version == null)
|
||||
if (this._version is null)
|
||||
{
|
||||
throw new InvalidOperationException("Version has not yet been parsed");
|
||||
}
|
||||
|
@ -28,10 +28,10 @@
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(type);
|
||||
var sectionAttributes = type.GetCustomAttributes(typeof(SectionAttribute), true);
|
||||
Debug.Assert(sectionAttributes != null, "No section attributes available");
|
||||
Debug.Assert(sectionAttributes is not null, "No section attributes available");
|
||||
Debug.Assert(sectionAttributes.Length == 1, "Must be a single section attribute available");
|
||||
var sectionAttribute = sectionAttributes[0];
|
||||
Debug.Assert(sectionAttribute != null, "Section attribute cannot be null");
|
||||
Debug.Assert(sectionAttribute is not null, "Section attribute cannot be null");
|
||||
this.ClassAttribute = (SectionAttribute)sectionAttribute;
|
||||
|
||||
foreach (var property in type.GetProperties())
|
||||
@ -47,7 +47,7 @@
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(name), name, "Missing property mapping");
|
||||
}
|
||||
Debug.Assert(propertyName != null);
|
||||
Debug.Assert(propertyName is not null);
|
||||
return propertyName;
|
||||
}
|
||||
|
||||
@ -56,7 +56,7 @@
|
||||
var propertyName = this.GetPropertyNameFromEntryName(key);
|
||||
var propertyAvailable = this.Properties.TryGetValue(propertyName, out var property);
|
||||
Debug.Assert(propertyAvailable);
|
||||
Debug.Assert(property != null);
|
||||
Debug.Assert(property is not null);
|
||||
return property;
|
||||
}
|
||||
|
||||
@ -79,7 +79,7 @@
|
||||
public T GetValueT<T>(object? obj, string key)
|
||||
{
|
||||
var possible = this.MaybeGetValue<T>(obj, key);
|
||||
return possible != null ? possible : throw new ArgumentOutOfRangeException(nameof(key), key, "Property read issue");
|
||||
return possible is not null ? possible : throw new ArgumentOutOfRangeException(nameof(key), key, "Property read issue");
|
||||
}
|
||||
|
||||
private void ProcessPropertyAttributes(PropertyInfo property)
|
||||
|
@ -25,7 +25,7 @@
|
||||
{
|
||||
var obtained = SectionPropertiesCache.TryGetValue(type, out var properties);
|
||||
Debug.Assert(obtained, $"Section properties for {type.Name} have not been built");
|
||||
Debug.Assert(properties != null);
|
||||
Debug.Assert(properties is not null);
|
||||
return properties;
|
||||
}
|
||||
|
||||
@ -35,7 +35,7 @@
|
||||
{
|
||||
var type = this.GetType();
|
||||
var entry = new ReflectedSectionProperties();
|
||||
Debug.Assert(SectionPropertiesCache != null);
|
||||
Debug.Assert(SectionPropertiesCache is not null);
|
||||
if (SectionPropertiesCache.TryAdd(type, entry))
|
||||
{
|
||||
entry.Build(type);
|
||||
@ -65,7 +65,7 @@
|
||||
{
|
||||
throw new InvalidOperationException($"Unable to locate property name {propertyName} using reflection");
|
||||
}
|
||||
Debug.Assert(property != null);
|
||||
Debug.Assert(property is not null);
|
||||
this.Parse(property, key, value);
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ namespace M6502.Test
|
||||
|
||||
var programPath = this.configuration.RomDirectory + "/" + this.configuration.Program;
|
||||
var loadAddress = this.configuration.LoadAddress;
|
||||
this.ram.Load(programPath, loadAddress.Word);
|
||||
_ = this.ram.Load(programPath, loadAddress.Word);
|
||||
|
||||
if (this.configuration.DebugMode)
|
||||
{
|
||||
@ -171,7 +171,7 @@ namespace M6502.Test
|
||||
{
|
||||
var cycles = this.CPU.Cycles;
|
||||
this.cyclesPolled += cycles;
|
||||
Debug.Assert(cycles > 0, "Invalid pollingcycle count");
|
||||
Debug.Assert(cycles > 0, "Invalid polling cycle count");
|
||||
if (this.cyclesPolled > this.configuration.PollingTickInterval)
|
||||
{
|
||||
this.cyclesPolled = 0;
|
||||
@ -196,13 +196,13 @@ namespace M6502.Test
|
||||
|
||||
var output = new StringBuilder();
|
||||
|
||||
output.Append($"PC={Disassembler.DumpWordValue(address)}:");
|
||||
output.Append($"P={Disassembler.DumpFlags(this.CPU.P)}, ");
|
||||
output.Append($"A={Disassembler.DumpByteValue(this.CPU.A)}, ");
|
||||
output.Append($"X={Disassembler.DumpByteValue(this.CPU.X)}, ");
|
||||
output.Append($"Y={Disassembler.DumpByteValue(this.CPU.Y)}, ");
|
||||
output.Append($"S={Disassembler.DumpByteValue(this.CPU.S)}\t");
|
||||
output.Append(this.disassembler.Disassemble(address));
|
||||
_ = output.Append(CultureInfo.InvariantCulture, $"PC={Disassembler.DumpWordValue(address)}:");
|
||||
_ = output.Append(CultureInfo.InvariantCulture, $"P={Disassembler.DumpFlags(this.CPU.P)}, ");
|
||||
_ = output.Append(CultureInfo.InvariantCulture, $"A={Disassembler.DumpByteValue(this.CPU.A)}, ");
|
||||
_ = output.Append(CultureInfo.InvariantCulture, $"X={Disassembler.DumpByteValue(this.CPU.X)}, ");
|
||||
_ = output.Append(CultureInfo.InvariantCulture, $"Y={Disassembler.DumpByteValue(this.CPU.Y)}, ");
|
||||
_ = output.Append(CultureInfo.InvariantCulture, $"S={Disassembler.DumpByteValue(this.CPU.S)}\t");
|
||||
_ = output.Append(this.disassembler.Disassemble(address));
|
||||
|
||||
Console.Out.WriteLine(output.ToString());
|
||||
}
|
||||
@ -211,7 +211,7 @@ namespace M6502.Test
|
||||
{
|
||||
var proportion = (double)e.Cycles / this.profiler.TotalCycles;
|
||||
var scope = this.symbols.LookupScopeByID(e.ID);
|
||||
Debug.Assert(scope != null);
|
||||
Debug.Assert(scope is not null);
|
||||
Console.Out.Write(string.Format(CultureInfo.InvariantCulture, "\t[{0:P2}][{1:d9}][{2:d9}]\t{3}\n", proportion, e.Cycles, e.Count, scope.Name));
|
||||
}
|
||||
|
||||
@ -237,44 +237,20 @@ namespace M6502.Test
|
||||
Console.Out.Write(string.Format(CultureInfo.InvariantCulture, "\t[{0:P2}][{1:d9}][{2:d9}]\t{3:X2}\n", proportion, e.Cycles, e.Count, e.Instruction));
|
||||
}
|
||||
|
||||
private void Profiler_FinishedScopeOutput(object? sender, EventArgs e)
|
||||
{
|
||||
Console.Out.Write("Finished profiler scope output...\n");
|
||||
}
|
||||
private void Profiler_FinishedScopeOutput(object? sender, EventArgs e) => Console.Out.Write("Finished profiler scope output...\n");
|
||||
|
||||
private void Profiler_StartingScopeOutput(object? sender, EventArgs e)
|
||||
{
|
||||
Console.Out.Write("Starting profiler scope output...\n");
|
||||
}
|
||||
private void Profiler_StartingScopeOutput(object? sender, EventArgs e) => Console.Out.Write("Starting profiler scope output...\n");
|
||||
|
||||
private void Profiler_FinishedLineOutput(object? sender, EventArgs e)
|
||||
{
|
||||
Console.Out.Write("Finished profiler line output...\n");
|
||||
}
|
||||
private void Profiler_FinishedLineOutput(object? sender, EventArgs e) => Console.Out.Write("Finished profiler line output...\n");
|
||||
|
||||
private void Profiler_StartingLineOutput(object? sender, EventArgs e)
|
||||
{
|
||||
Console.Out.Write("Starting profiler line output...\n");
|
||||
}
|
||||
private void Profiler_StartingLineOutput(object? sender, EventArgs e) => Console.Out.Write("Starting profiler line output...\n");
|
||||
|
||||
private void Profiler_FinishedOutput(object? sender, EventArgs e)
|
||||
{
|
||||
Console.Out.Write("Finished profiler output...\n");
|
||||
}
|
||||
private void Profiler_FinishedOutput(object? sender, EventArgs e) => Console.Out.Write("Finished profiler output...\n");
|
||||
|
||||
private void Profiler_StartingOutput(object? sender, EventArgs e)
|
||||
{
|
||||
Console.Out.Write("Starting profiler output...\n");
|
||||
}
|
||||
private void Profiler_StartingOutput(object? sender, EventArgs e) => Console.Out.Write("Starting profiler output...\n");
|
||||
|
||||
private void Profiler_FinishedInstructionOutput(object? sender, EventArgs e)
|
||||
{
|
||||
Console.Out.Write("Finished instruction output...\n");
|
||||
}
|
||||
private void Profiler_FinishedInstructionOutput(object? sender, EventArgs e) => Console.Out.Write("Finished instruction output...\n");
|
||||
|
||||
private void Profiler_StartingInstructionOutput(object? sender, EventArgs e)
|
||||
{
|
||||
Console.Out.Write("Starting instruction output...\n");
|
||||
}
|
||||
private void Profiler_StartingInstructionOutput(object? sender, EventArgs e) => Console.Out.Write("Starting instruction output...\n");
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
namespace M6502.Test
|
||||
{
|
||||
public static class Program
|
||||
internal static class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
|
@ -102,7 +102,7 @@
|
||||
foreach (var (id, cycles) in this.scopeCycles)
|
||||
{
|
||||
var symbol = this.symbols.LookupLabelByID(id);
|
||||
Debug.Assert(symbol != null);
|
||||
Debug.Assert(symbol is not null);
|
||||
var available = this.ExtractCycleDistribution((ushort)symbol.Value, out var _, out var _, out var count);
|
||||
Debug.Assert(available);
|
||||
this.OnEmitScope(id, cycles, count);
|
||||
@ -128,7 +128,7 @@
|
||||
{
|
||||
// Dump a profile/disassembly line
|
||||
var source = this.disassembler.Disassemble(address);
|
||||
Debug.Assert(cycleDistributions != null);
|
||||
Debug.Assert(cycleDistributions is not null);
|
||||
this.OnEmitLine(address, source, cycles, count, cycleDistributions);
|
||||
}
|
||||
}
|
||||
@ -178,7 +178,7 @@
|
||||
|
||||
{
|
||||
var addressDistribution = this.addressCycleDistributions[this.executingAddress];
|
||||
if (addressDistribution == null)
|
||||
if (addressDistribution is null)
|
||||
{
|
||||
this.addressCycleDistributions[this.executingAddress] = addressDistribution = [];
|
||||
}
|
||||
@ -190,7 +190,7 @@
|
||||
|
||||
{
|
||||
var scope = this.symbols.LookupScopeByAddress(this.executingAddress);
|
||||
if (scope != null)
|
||||
if (scope is not null)
|
||||
{
|
||||
var id = scope.ID;
|
||||
// Current will be initialised to zero, if absent
|
||||
@ -203,7 +203,7 @@
|
||||
private bool ExtractCycleDistribution(ushort address, out Dictionary<int, long>? cycleDistribution, out long cycleCount, out long hitCount)
|
||||
{
|
||||
cycleDistribution = this.addressCycleDistributions[address];
|
||||
if (cycleDistribution == null)
|
||||
if (cycleDistribution is null)
|
||||
{
|
||||
cycleCount = -1;
|
||||
hitCount = -1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user