mirror of
https://github.com/sampletext32/ParkanPlayground.git
synced 2025-06-20 00:18:02 +03:00
Update TestDataProvider to use CSV files directly from filesystem instead of embedded resources
This commit is contained in:
@ -1,15 +1,20 @@
|
||||
using System.Text.Json;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using CsvHelper;
|
||||
using CsvHelper.Configuration;
|
||||
using CsvHelper.TypeConversion;
|
||||
using X86Disassembler.X86;
|
||||
|
||||
namespace X86DisassemblerTests;
|
||||
|
||||
// ReSharper disable once ClassNeverInstantiated.Global
|
||||
public sealed class CsvJsonConverter<T> : DefaultTypeConverter
|
||||
{
|
||||
private static JsonSerializerOptions _options = new JsonSerializerOptions()
|
||||
// Configure JSON options with case-insensitive enum handling
|
||||
private static readonly JsonSerializerOptions _options = new JsonSerializerOptions
|
||||
{
|
||||
PropertyNameCaseInsensitive = true,
|
||||
Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
|
||||
};
|
||||
|
||||
public override object? ConvertFromString(string? text, IReaderRow row, MemberMapData memberMapData)
|
||||
@ -19,11 +24,11 @@ public sealed class CsvJsonConverter<T> : DefaultTypeConverter
|
||||
return null;
|
||||
}
|
||||
|
||||
return JsonSerializer.Deserialize<T>(text);
|
||||
return JsonSerializer.Deserialize<T>(text, _options);
|
||||
}
|
||||
|
||||
public override string? ConvertToString(object? value, IWriterRow row, MemberMapData memberMapData)
|
||||
{
|
||||
return JsonSerializer.Serialize(value);
|
||||
return JsonSerializer.Serialize(value, _options);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user