[BUG/Feature Request] Serialization: Converters that convert to base types
icanhasjonas opened this issue · 0 comments
icanhasjonas commented
It would be great if we could have support for system type surrogates,
or (if this is not intentional behavior), there's a bug when using base/system types as surrogates
public readonly struct SomeId {
public Guid Value {get;init;}
}
[RegisterConverter]
public class SomeIdConverter : IConverter<SomeId, Guid>
{
public SomeId ConvertFromSurrogate(in Guid surrogate) => new SomeId { Value = surrogate };
public Guid ConvertToSurrogate(in SomeId id) => id.Value;
}
Currently the above code yields:
System.Collections.Generic.KeyNotFoundException: Could not find a value serializer for type System.Guid.
at Orleans.Serialization.Serializers.CodecProvider.ThrowValueSerializerNotFound(Type fieldType) in /_/src/Orleans.Serialization/Serializers/CodecProvider.cs:line 679
at Orleans.Serialization.Serializers.CodecProvider.GetValueSerializer[TField]() in /_/src/Orleans.Serialization/Serializers/CodecProvider.cs:line 280
at Orleans.Serialization.ServiceCollectionExtensions.ValueSerializerHolder`1.get_Value() in /_/src/Orleans.Serialization/Hosting/ServiceCollectionExtensions.cs:line 186
at Orleans.Serialization.ServiceCollectionExtensions.ValueSerializerHolder`1.Serialize[TBufferWriter](Writer`1& writer, TField& value) in /_/src/Orleans.Serialization/Hosting/ServiceCollectionExtensions.cs:line 182
at Orleans.Serialization.Serializers.ValueTypeSurrogateCodec`3.WriteField[TBufferWriter](Writer`1& writer, UInt32 fieldIdDelta, Type expectedType, TField value) in /_/src/Orleans.Serialization/Serializers/ValueTypeSurrogateCodec.cs:line 85