2025-04-15 22:20:46 +03:00
|
|
|
using System.Text.Json.Serialization;
|
2025-04-13 17:02:46 +03:00
|
|
|
using CsvHelper.Configuration;
|
2025-04-14 23:08:52 +03:00
|
|
|
using X86Disassembler.X86;
|
|
|
|
using X86Disassembler.X86.Operands;
|
2025-04-13 17:02:46 +03:00
|
|
|
|
|
|
|
namespace X86DisassemblerTests;
|
|
|
|
|
|
|
|
public class TestFromFileEntry
|
|
|
|
{
|
|
|
|
public string RawBytes { get; set; } = string.Empty;
|
|
|
|
public List<TestFromFileInstruction> Instructions { get; set; } = new();
|
|
|
|
|
|
|
|
public TestFromFileEntry()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public TestFromFileEntry(string rawBytes, List<TestFromFileInstruction> instructions)
|
|
|
|
{
|
|
|
|
RawBytes = rawBytes;
|
|
|
|
Instructions = instructions;
|
|
|
|
}
|
2025-04-15 22:20:46 +03:00
|
|
|
|
|
|
|
public override string ToString()
|
|
|
|
{
|
|
|
|
return $"{RawBytes}. {string.Join(";", Instructions)}";
|
|
|
|
}
|
2025-04-13 17:02:46 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
public class TestFromFileInstruction
|
|
|
|
{
|
2025-04-14 23:08:52 +03:00
|
|
|
// Keep the old properties for CSV deserialization
|
2025-04-15 22:20:46 +03:00
|
|
|
public string[] Operands { get; set; } = [];
|
|
|
|
|
|
|
|
// Mnemonic
|
|
|
|
[JsonConverter(typeof(JsonStringEnumConverter<InstructionType>))]
|
|
|
|
public InstructionType Type { get; set; }
|
|
|
|
|
2025-04-13 17:02:46 +03:00
|
|
|
// Parameterless constructor required by CsvHelper
|
|
|
|
public TestFromFileInstruction()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2025-04-15 22:20:46 +03:00
|
|
|
public override string ToString()
|
2025-04-14 23:08:52 +03:00
|
|
|
{
|
2025-04-15 22:20:46 +03:00
|
|
|
return $"{Type} {string.Join(",", Operands)}";
|
2025-04-14 23:08:52 +03:00
|
|
|
}
|
2025-04-13 17:02:46 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
public sealed class TestFromFileEntryMap : ClassMap<TestFromFileEntry>
|
|
|
|
{
|
|
|
|
public TestFromFileEntryMap()
|
|
|
|
{
|
|
|
|
Map(m => m.RawBytes)
|
|
|
|
.Name("RawBytes");
|
|
|
|
Map(m => m.Instructions)
|
|
|
|
.Name("Instructions")
|
|
|
|
.TypeConverter<CsvJsonConverter<List<TestFromFileInstruction>>>();
|
|
|
|
}
|
|
|
|
}
|