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

Inconsistency: Using protobuf-net changes how dictionaries with nullable value types are deserialized #329

Open
helm100 opened this issue Jun 21, 2024 · 0 comments

Comments

@helm100
Copy link

helm100 commented Jun 21, 2024

I've found that for gRpc calls, the deserialization of dictionaries with nullable value types changes, purely by including/removing the protobuf-net.Grpc.AspNetCore.Reflection package.

Setup:

Data contract:

[DataContract]
public class TestDataContract
{
    [DataMember(Order = 1)]
    public IDictionary<string, string?> Test { get; set; } = new Dictionary<string, string?>();
}

Service:

[gRpcService]
public class TestGrpcService : ITestGrpc
{
    public async Task<TestDataContract> TestAsync(CallContext context = default)
    {
        return new TestDataContract {
            Test = new Dictionary<string, string?>() { { "test1", "blabla" }, { "test", null } }
        };
    }
}

Client:

...
var response = await testGrpcClient.Test();
...

WITH package, response = { { "test1", "blabla" }, { "test", "" } }
WITHOUT package, response = { { "test1", "blabla" }, { "test", null } }

I'm using protobuf-net.Grpc.AspNetCore.Reflection --version 1.1.1

@helm100 helm100 changed the title Inconsistency: Using package changes how dictionaries with nullable value types are deserialized Inconsistency: Using protobuf-net changes how dictionaries with nullable value types are deserialized Jun 21, 2024
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