Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG/Feature Request] Serialization: Converters that convert to base types #9108

Open
icanhasjonas opened this issue Aug 8, 2024 · 0 comments

Comments

@icanhasjonas
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant