mirror of
https://github.com/MoleskiCoder/EightBitNet.git
synced 2025-09-27 02:16:55 +00:00
Apply all .net 9 analysis suggestions
This commit is contained in:
@@ -3,22 +3,22 @@
|
|||||||
// </copyright>
|
// </copyright>
|
||||||
namespace Fuse
|
namespace Fuse
|
||||||
{
|
{
|
||||||
|
using EightBit;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using EightBit;
|
|
||||||
|
|
||||||
public abstract class AbstractRegisterState
|
public abstract class AbstractRegisterState
|
||||||
{
|
{
|
||||||
private readonly List<Register16> registers = new List<Register16>();
|
|
||||||
|
|
||||||
public ReadOnlyCollection<Register16> Registers => this.MutableRegisters.AsReadOnly();
|
public ReadOnlyCollection<Register16> Registers => this.MutableRegisters.AsReadOnly();
|
||||||
|
|
||||||
public bool Halted { get; protected set; } = false;
|
public bool Halted { get; protected set; } = false;
|
||||||
|
|
||||||
public int TStates { get; protected set; } = -1;
|
public int TStates { get; protected set; } = -1;
|
||||||
|
|
||||||
protected List<Register16> MutableRegisters => this.registers;
|
protected List<Register16> MutableRegisters { get; } = [];
|
||||||
|
|
||||||
|
private static readonly char[] separator = [' ', '\t'];
|
||||||
|
|
||||||
public void Parse(Lines lines)
|
public void Parse(Lines lines)
|
||||||
{
|
{
|
||||||
@@ -30,7 +30,7 @@ namespace Fuse
|
|||||||
|
|
||||||
protected virtual void ParseInternalState(string line)
|
protected virtual void ParseInternalState(string line)
|
||||||
{
|
{
|
||||||
var tokens = line.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
|
var tokens = line.Split(separator, StringSplitOptions.RemoveEmptyEntries);
|
||||||
this.ParseInternalState(tokens);
|
this.ParseInternalState(tokens);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,9 +39,9 @@ namespace Fuse
|
|||||||
protected virtual void ParseExternalState(Lines lines)
|
protected virtual void ParseExternalState(Lines lines)
|
||||||
{
|
{
|
||||||
var line = lines.ReadLine();
|
var line = lines.ReadLine();
|
||||||
foreach (var token in line.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries))
|
foreach (var token in line.Split(separator, StringSplitOptions.RemoveEmptyEntries))
|
||||||
{
|
{
|
||||||
this.registers.Add(new Register16(Convert.ToUInt16(token, 16)));
|
this.MutableRegisters.Add(new Register16(Convert.ToUInt16(token, 16)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -3,8 +3,8 @@
|
|||||||
// </copyright>
|
// </copyright>
|
||||||
namespace Fuse
|
namespace Fuse
|
||||||
{
|
{
|
||||||
using System.Collections.ObjectModel;
|
|
||||||
using EightBit;
|
using EightBit;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
|
||||||
public interface IRegisterState
|
public interface IRegisterState
|
||||||
{
|
{
|
||||||
|
@@ -8,14 +8,12 @@ namespace Fuse
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
public class Lines
|
public class Lines(string path)
|
||||||
{
|
{
|
||||||
private readonly string path;
|
private readonly string path = path;
|
||||||
private readonly List<string> lines = new List<string>();
|
private readonly List<string> lines = [];
|
||||||
private int position = -1;
|
private int position = -1;
|
||||||
|
|
||||||
public Lines(string path) => this.path = path;
|
|
||||||
|
|
||||||
public bool EndOfFile => this.position == this.lines.Count;
|
public bool EndOfFile => this.position == this.lines.Count;
|
||||||
|
|
||||||
public void Read()
|
public void Read()
|
||||||
|
@@ -9,16 +9,18 @@ namespace Fuse
|
|||||||
|
|
||||||
public class MemoryDatum
|
public class MemoryDatum
|
||||||
{
|
{
|
||||||
private readonly List<byte> bytes = new List<byte>();
|
private readonly List<byte> bytes = [];
|
||||||
|
|
||||||
public ushort Address { get; private set; } = (ushort)EightBit.Mask.Sixteen;
|
public ushort Address { get; private set; } = (ushort)EightBit.Mask.Sixteen;
|
||||||
|
|
||||||
public ReadOnlyCollection<byte> Bytes => this.bytes.AsReadOnly();
|
public ReadOnlyCollection<byte> Bytes => this.bytes.AsReadOnly();
|
||||||
|
|
||||||
|
private static readonly char[] separator = [' ', '\t'];
|
||||||
|
|
||||||
public void Parse(string line)
|
public void Parse(string line)
|
||||||
{
|
{
|
||||||
ArgumentNullException.ThrowIfNullOrWhiteSpace(line);
|
ArgumentNullException.ThrowIfNullOrWhiteSpace(line);
|
||||||
var tokens = line.Split(new char[] { ' ', '\t' });
|
var tokens = line.Split(separator);
|
||||||
this.Parse(tokens);
|
this.Parse(tokens);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -10,14 +10,13 @@ namespace Fuse
|
|||||||
public class Result<T>
|
public class Result<T>
|
||||||
where T : Fuse.IRegisterState, new()
|
where T : Fuse.IRegisterState, new()
|
||||||
{
|
{
|
||||||
private readonly TestEvents events = new TestEvents();
|
private readonly List<MemoryDatum> memoryData = [];
|
||||||
private readonly List<MemoryDatum> memoryData = new List<MemoryDatum>();
|
|
||||||
|
|
||||||
public string Description { get; private set; }
|
public string? Description { get; private set; }
|
||||||
|
|
||||||
public T RegisterState { get; } = new T();
|
public T RegisterState { get; } = new T();
|
||||||
|
|
||||||
public TestEvents Events => this.events;
|
public TestEvents Events { get; } = new();
|
||||||
|
|
||||||
public ReadOnlyCollection<MemoryDatum> MemoryData => this.memoryData.AsReadOnly();
|
public ReadOnlyCollection<MemoryDatum> MemoryData => this.memoryData.AsReadOnly();
|
||||||
|
|
||||||
@@ -35,7 +34,7 @@ namespace Fuse
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.events.Parse(lines);
|
this.Events.Parse(lines);
|
||||||
this.RegisterState.Parse(lines);
|
this.RegisterState.Parse(lines);
|
||||||
|
|
||||||
bool finished;
|
bool finished;
|
||||||
|
@@ -4,15 +4,14 @@
|
|||||||
namespace Fuse
|
namespace Fuse
|
||||||
{
|
{
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
public class Results<T>
|
public class Results<T>(string path)
|
||||||
where T : Fuse.IRegisterState, new()
|
where T : Fuse.IRegisterState, new()
|
||||||
{
|
{
|
||||||
private readonly Lines lines;
|
private readonly Lines lines = new(path);
|
||||||
|
|
||||||
public Results(string path) => this.lines = new Lines(path);
|
public Dictionary<string, Result<T>> Container { get; } = [];
|
||||||
|
|
||||||
public Dictionary<string, Result<T>> Container { get; } = new Dictionary<string, Result<T>>();
|
|
||||||
|
|
||||||
public void Read() => this.lines.Read();
|
public void Read() => this.lines.Read();
|
||||||
|
|
||||||
@@ -23,6 +22,7 @@ namespace Fuse
|
|||||||
var result = new Result<T>();
|
var result = new Result<T>();
|
||||||
if (result.TryParse(this.lines))
|
if (result.TryParse(this.lines))
|
||||||
{
|
{
|
||||||
|
Debug.Assert(result.Description is not null);
|
||||||
this.Container.Add(result.Description, result);
|
this.Container.Add(result.Description, result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -9,9 +9,9 @@ namespace Fuse
|
|||||||
public class Test<T>
|
public class Test<T>
|
||||||
where T : Fuse.IRegisterState, new()
|
where T : Fuse.IRegisterState, new()
|
||||||
{
|
{
|
||||||
private readonly List<MemoryDatum> memoryData = new List<MemoryDatum>();
|
private readonly List<MemoryDatum> memoryData = [];
|
||||||
|
|
||||||
public string Description { get; private set; }
|
public string? Description { get; private set; }
|
||||||
|
|
||||||
public T RegisterState { get; } = new T();
|
public T RegisterState { get; } = new T();
|
||||||
|
|
||||||
|
@@ -3,8 +3,8 @@
|
|||||||
// </copyright>
|
// </copyright>
|
||||||
namespace Fuse
|
namespace Fuse
|
||||||
{
|
{
|
||||||
using System;
|
|
||||||
using EightBit;
|
using EightBit;
|
||||||
|
using System;
|
||||||
|
|
||||||
public class TestEvent
|
public class TestEvent
|
||||||
{
|
{
|
||||||
@@ -27,7 +27,7 @@ namespace Fuse
|
|||||||
|
|
||||||
public int Cycles => this.cycles;
|
public int Cycles => this.cycles;
|
||||||
|
|
||||||
public string Specifier { get; private set; }
|
public string? Specifier { get; private set; }
|
||||||
|
|
||||||
public ushort Address { get; private set; } = (ushort)EightBit.Mask.Sixteen;
|
public ushort Address { get; private set; } = (ushort)EightBit.Mask.Sixteen;
|
||||||
|
|
||||||
@@ -35,6 +35,8 @@ namespace Fuse
|
|||||||
|
|
||||||
private bool ContentionEvent { get; set; } = false;
|
private bool ContentionEvent { get; set; } = false;
|
||||||
|
|
||||||
|
private static readonly char[] separator = [' ', '\t'];
|
||||||
|
|
||||||
public bool TryParse(Lines lines)
|
public bool TryParse(Lines lines)
|
||||||
{
|
{
|
||||||
ArgumentNullException.ThrowIfNull(lines);
|
ArgumentNullException.ThrowIfNull(lines);
|
||||||
@@ -61,7 +63,7 @@ namespace Fuse
|
|||||||
|
|
||||||
private bool TryParseLine(string line)
|
private bool TryParseLine(string line)
|
||||||
{
|
{
|
||||||
var split = line.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
|
var split = line.Split(separator, StringSplitOptions.RemoveEmptyEntries);
|
||||||
return this.TryParseLine(split);
|
return this.TryParseLine(split);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -8,7 +8,7 @@ namespace Fuse
|
|||||||
|
|
||||||
public class TestEvents
|
public class TestEvents
|
||||||
{
|
{
|
||||||
private readonly List<TestEvent> container = new List<TestEvent>();
|
private readonly List<TestEvent> container = [];
|
||||||
|
|
||||||
public ReadOnlyCollection<TestEvent> Container => this.container.AsReadOnly();
|
public ReadOnlyCollection<TestEvent> Container => this.container.AsReadOnly();
|
||||||
|
|
||||||
|
@@ -4,15 +4,14 @@
|
|||||||
namespace Fuse
|
namespace Fuse
|
||||||
{
|
{
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
public class Tests<T>
|
public class Tests<T>(string path)
|
||||||
where T : Fuse.IRegisterState, new()
|
where T : Fuse.IRegisterState, new()
|
||||||
{
|
{
|
||||||
private readonly Lines lines;
|
private readonly Lines lines = new(path);
|
||||||
|
|
||||||
public Tests(string path) => this.lines = new Lines(path);
|
public Dictionary<string, Test<T>> Container { get; } = [];
|
||||||
|
|
||||||
public Dictionary<string, Test<T>> Container { get; } = new Dictionary<string, Test<T>>();
|
|
||||||
|
|
||||||
public void Read() => this.lines.Read();
|
public void Read() => this.lines.Read();
|
||||||
|
|
||||||
@@ -23,6 +22,7 @@ namespace Fuse
|
|||||||
var test = new Test<T>();
|
var test = new Test<T>();
|
||||||
if (test.TryParse(this.lines))
|
if (test.TryParse(this.lines))
|
||||||
{
|
{
|
||||||
|
Debug.Assert(test.Description is not null);
|
||||||
this.Container.Add(test.Description, test);
|
this.Container.Add(test.Description, test);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user