-
Notifications
You must be signed in to change notification settings - Fork 45
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
[feature request] Orleans integration #385
Comments
Is this one up for grabs? I really like what this library is doing but am missing this piece and the Mongo BSON conversion. Happy to contribute! |
As a result, I choose to clone source code Vogen and choose option 4:remove fields from Vogen SG code like _value and _init and type them in my source code as below: [ValueObject<ulong>(conversions: Conversions.SystemTextJson)]
[GenerateSerializer]
[Immutable]
public readonly partial struct UserId
{
[Id(0)] private readonly bool _isInitialized;
[Id(1)] private readonly ulong _value;
private static Validation Validate(ulong input)
{
return Validation.Ok;
}
} Reason:Orleans.Sdk cannot generate serializer code from Vogen SG code, so option 2 & 3 do not work. So the best way I think to integrate Vogen and Orleans like projects, is to support for developer to type fields in their source code instead of generate code in SG. It need some detection to know there is or not self-type fields, if so, do not generate code in Vogen |
I think we should rename this issue back to Orleans support rather than the new name? I think instead of using Here's a string example, but you can see this could be compiled to support the other primitive types Vogen supports. [ValueObject<string>]
[Immutable, RegisterSerializer]
public readonly partial record struct ValueObjectTest : IValueSerializer<ValueObjectTest>, IFieldCodec<ValueObjectTest>
{
[GenerateSerializer]
public readonly record struct Surrogate(string Value);
public void WriteField<TBufferWriter>(ref Writer<TBufferWriter> writer, uint fieldIdDelta, Type expectedType, ValueObjectTest value)
where TBufferWriter : IBufferWriter<byte>
{
StringCodec.WriteField(ref writer, fieldIdDelta, value.Value);
}
public ValueObjectTest ReadValue<TInput>(ref Reader<TInput> reader, Field field)
{
var value = StringCodec.ReadValue(ref reader, field);
return From(value);
}
public void Serialize<TBufferWriter>(ref Writer<TBufferWriter> writer, scoped ref ValueObjectTest value) where TBufferWriter : IBufferWriter<byte>
{
StringCodec.WriteField(ref writer, 0, value.Value);
}
public void Deserialize<TInput>(ref Reader<TInput> reader, scoped ref ValueObjectTest value)
{
var header = reader.ReadFieldHeader();
var stringValue = StringCodec.ReadValue(ref reader, header);
value = From(stringValue);
}
} I think Vogen could support decorating the value object with |
|
It sounds like we have two separate issues to track here then:
Strictly for the Orleans use case, I prefer option 2, it results in cleaner, less duplicative code that doesn't "know" the internals of the ValueObject. |
Also, I can take this one on! |
Hi - sorry for the delay in replying. Very happy to accept any contributions. It would be great to enable everyone to use Vogen in Orleans while still having all of the current constraints that ensure safety. |
go to: #385 (comment)
Describe the feature
Support to be serialize with Microsoft/orleans
see: dotnet/orleans#8374
Option 1
Support to declare custom constructor, then GenerateSerializer can works well in orleans.
Option 2
if
then generate
Option 3
surrogates-for-serializing-foreign-types
<https://learn.microsoft.com/en-us/dotnet/orleans/host/configuration-guide/serialization?pivots=orleans-7-0#surrogates-for-serializing-foreign-types >
if
then generate
The text was updated successfully, but these errors were encountered: