Provides an abstraction for creating the JavaScriptEncoder used in SystemTextConfigurationEditorJsonSerializer (#19849)

* Provides an abstraction for creating the JavaScriptEncoder used in SystemTextConfigurationEditorJsonSerializer.

* Generalised JSON serialization encoder factory to work for all System.Tex.Json serializers.
Added the serializer's name as a parameter to allow for different encodings per serializer if required.

* Fixed tests by removing use of obsolete constructors.

* Removed name parameter and used a generic type instead.
This commit is contained in:
Andy Butland
2025-08-07 09:08:09 +02:00
committed by GitHub
parent 3a4e0b0654
commit 44aa5dcf1c
50 changed files with 194 additions and 87 deletions

View File

@@ -138,7 +138,7 @@ public class DataTypeBuilder
var creatorId = _creatorId ?? 1;
var databaseType = _databaseType ?? ValueStorageType.Ntext;
var sortOrder = _sortOrder ?? 0;
var serializer = new SystemTextConfigurationEditorJsonSerializer();
var serializer = new SystemTextConfigurationEditorJsonSerializer(new DefaultJsonSerializerEncoderFactory());
var dataType = new DataType(editor, serializer, parentId)
{

View File

@@ -136,7 +136,7 @@ public abstract class TestHelperBase
}
}
public IJsonSerializer JsonSerializer { get; } = new SystemTextJsonSerializer();
public IJsonSerializer JsonSerializer { get; } = new SystemTextJsonSerializer(new DefaultJsonSerializerEncoderFactory());
public IVariationContextAccessor VariationContextAccessor { get; } = new TestVariationContextAccessor();

View File

@@ -17,7 +17,7 @@ public class MockedValueEditors
return new DataValueEditor(
Mock.Of<IShortStringHelper>(),
new SystemTextJsonSerializer(),
new SystemTextJsonSerializer(new DefaultJsonSerializerEncoderFactory()),
Mock.Of<IIOHelper>(),
new DataEditorAttribute(name) { ValueType = valueType });
}