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

Wrong deserialization for dictionaries with Nullable<>-values #19

Open
evifox opened this issue Nov 5, 2019 · 0 comments
Open

Wrong deserialization for dictionaries with Nullable<>-values #19

evifox opened this issue Nov 5, 2019 · 0 comments

Comments

@evifox
Copy link

evifox commented Nov 5, 2019

I wrote simple unit test which check values after deserialization and I got exception on checking value with key [2]:

var incoming = new Dictionary<int, int?>
    {
        [0] = null,
        [1] = 123,
        [2] = null,
    };
var serializer = new GroBuf.Serializer(
    new GroBuf.DataMembersExtracters.AllPropertiesExtractor(),
    new GroBuf.DefaultGroBufCustomSerializerCollection(),
    GroBuf.GroBufOptions.MergeOnRead | GroBuf.GroBufOptions.WriteEmptyObjects);
var raw = serializer.Serialize(incoming);
var outgoing = serializer.Deserialize<Dictionary<int, int?>>(raw);
outgoing[0].Should().Be(null);
outgoing[1].Should().Be(123);
outgoing[2].Should().Be(null); // Expected <null>, but found 123.

When I use nullable-values by default such as "string" then deserialization work correct.

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

No branches or pull requests

1 participant