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