Class GenericValueObjectJsonConverterFactory
Namespace: AdCodicem.ValueObjects.Metadata
Assembly: AdCodicem.ValueObjects.Abstractions.dll
Supplies the System.Text.Json converter of each construction of a generic value object.
public sealed class GenericValueObjectJsonConverterFactory : JsonConverterFactory
Inheritance
object ← JsonConverter ← JsonConverterFactory ← GenericValueObjectJsonConverterFactory
Inherited Members
JsonConverterFactory.CreateConverter(Type, JsonSerializerOptions), JsonConverterFactory.Type, JsonConverter.CanConvert(Type), JsonConverter.Type, object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.ReferenceEquals(object?, object?), object.ToString()
Remarks
The generator puts this factory in the [JsonConverter] attribute of a generic value object, where a value
object that is not generic names its own converter. An attribute cannot name a type through a type parameter, and
System.Text.Json does not close an open generic converter over the type it converts, so the attribute names this
factory, which hands out the converter the generator wrote, closed over the construction it is asked for.
It is reached through the attribute, which only the serializer resolving types by reflection reads. A
source-generated serializer context reaches the value object through ValueObjectJsonConverterFactory
instead, which hands out the same converter.
Methods
CanConvert(Type)
When overridden in a derived class, determines whether the converter instance can convert the specified object type.
public override bool CanConvert(Type typeToConvert)
Parameters
typeToConvert Type
The type of the object to check whether it can be converted by this converter instance.
Returns
true if the instance can convert the specified object type; otherwise, false.
CreateConverter(Type, JsonSerializerOptions)
Creates a converter for a specified type.
[UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "Reached through the [JsonConverter] attribute of a generic value object, which only the serializer resolving types by reflection reads, and which the source generator never sees, since another generator writes it.")]
[UnconditionalSuppressMessage("AOT", "IL3050", Justification = "Reached through the [JsonConverter] attribute of a generic value object, which only the serializer resolving types by reflection reads, and which the source generator never sees, since another generator writes it.")]
public override JsonConverter? CreateConverter(Type typeToConvert, JsonSerializerOptions options)
Parameters
typeToConvert Type
The type handled by the converter.
options JsonSerializerOptions
The serialization options to use.
Returns
A converter for which T is compatible with typeToConvert.
Exceptions
The construction carries no generated converter.