You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
GroBuf only respect primitive types, object[] and Hashtable when serializing a property of the object type, but does not respect, for example, Dictionary<TKey, TValue>.
[Test]
public void TestDictionaryInObject()
{
var a = new A {S = "zzz", Dict = new Dictionary<string, string> {["key"] = "value"}};
var data = serializer.Serialize(a);
var deserializedA = serializer.Deserialize<A>(data);
Assert.AreEqual("zzz", deserializedA.S);
Assert.NotNull(deserializedA.Dict);
Assert.That(deserializedA.Dict, Is.TypeOf<Dictionary<string, string>>());
Assert.AreEqual("value", ((Dictionary<string, string>)deserializedA.Dict)["key"]);
}
public class A
{
public object S { get; set; }
public object Dict { get; set; }
}
This test fails on Assert.NotNull operation.
The text was updated successfully, but these errors were encountered:
It seems to me that it may be hard to fix because GroBuf serialization considers types known at compile-time, but it has no mechanism to call a Writer for a runtime type.
This failing test proves that the problem is in serialization process.
[Test]
public void TestDictionaryInObjectSize()
{
var first = new A {S = "zzz", Z = new Dictionary<string, string> {["key"] = "value"}};
var firstBytes = serializer.Serialize(first);
var second = new A {S = "zzz", Z = null};
var secondBytes = serializer.Serialize(second);
Assert.AreNotEqual(firstBytes.Length, secondBytes.Length);
}
GroBuf only respect primitive types,
object[]
andHashtable
when serializing a property of theobject
type, but does not respect, for example,Dictionary<TKey, TValue>
.This test fails on
Assert.NotNull
operation.The text was updated successfully, but these errors were encountered: