kevin-montrose / public-broadcasting Goto Github PK
View Code? Open in Web Editor NEWSelf describing wrapper around protobuf-net.
License: Microsoft Public License
Self describing wrapper around protobuf-net.
License: Microsoft Public License
System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
at System.Collections.Generic.Dictionary2.get_Item(TKey key) at PublicBroadcasting.Impl.Deserializer.IsExactMatch(Type type, TypeDescription description, Dictionary
2 backLookup) in Deserializer.cs: line 200
at PublicBroadcasting.Impl.Deserializer.IsExactMatch(Type type, TypeDescription description, Dictionary2 backLookup) in Deserializer.cs: line 231 at PublicBroadcasting.Impl.Deserializer.IsExactMatch(Type type, TypeDescription description, Dictionary
2 backLookup) in Deserializer.cs: line 174
at PublicBroadcasting.Impl.Deserializer.DeserializeCore(Stream stream, Type tryMakeType, ref Type type) in Deserializer.cs: line 68
at PublicBroadcasting.Impl.Deserializer.Deserialize(Stream stream) in Deserializer.cs: line 21
at PublicBroadcasting.Serializer.Deserialize(Stream stream) in Serializer.cs: line 765
at PublicBroadcasting.Serializer.Deserialize(Byte[] bytes) in Serializer.cs: line 734
When serializing 100.000 instances of the same type (with different values) public-broadcasting takes around 12 seconds. Using protobuf directly (with the classes annotated with [ProtoMember] and etc.) the same experiment takes 0.79 seconds. Deserialization follows the same pattern.
It doesn't seem like public-broadcasting is caching the envelopes it is creating and so it is recreating them every time (something that is expensive).
Not sure if this is publicbroadcasting or protobuf, but this is the stack trace:
[InvalidOperationException: Unexpected sub-type: System.String]
ProtoBuf.Meta.TypeModel.ThrowUnexpectedSubtype(Type expected, Type actual) in c:\Dev\protobuf-net\protobuf-net\Meta\TypeModel.cs:1335
proto_3(Object , ProtoWriter ) +47
ProtoBuf.Serializers.CompiledSerializer.ProtoBuf.Serializers.IProtoSerializer.Write(Object value, ProtoWriter dest) in c:\Dev\protobuf-net\protobuf-net\Serializers\CompiledSerializer.cs:53
ProtoBuf.Meta.RuntimeTypeModel.Serialize(Int32 key, Object value, ProtoWriter dest) in c:\Dev\protobuf-net\protobuf-net\Meta\RuntimeTypeModel.cs:760
ProtoBuf.ProtoWriter.WriteObject(Object value, Int32 key, ProtoWriter writer) in c:\Dev\protobuf-net\protobuf-net\ProtoWriter.cs:46
proto_5(Object , ProtoWriter ) +96
ProtoBuf.Serializers.CompiledSerializer.ProtoBuf.Serializers.IProtoSerializer.Write(Object value, ProtoWriter dest) in c:\Dev\protobuf-net\protobuf-net\Serializers\CompiledSerializer.cs:53
ProtoBuf.Meta.RuntimeTypeModel.Serialize(Int32 key, Object value, ProtoWriter dest) in c:\Dev\protobuf-net\protobuf-net\Meta\RuntimeTypeModel.cs:760
ProtoBuf.ProtoWriter.WriteObject(Object value, Int32 key, ProtoWriter writer) in c:\Dev\protobuf-net\protobuf-net\ProtoWriter.cs:46
proto_1(Object , ProtoWriter ) +564
ProtoBuf.Serializers.CompiledSerializer.ProtoBuf.Serializers.IProtoSerializer.Write(Object value, ProtoWriter dest) in c:\Dev\protobuf-net\protobuf-net\Serializers\CompiledSerializer.cs:53
ProtoBuf.Meta.RuntimeTypeModel.Serialize(Int32 key, Object value, ProtoWriter dest) in c:\Dev\protobuf-net\protobuf-net\Meta\RuntimeTypeModel.cs:760
ProtoBuf.Meta.TypeModel.SerializeCore(ProtoWriter writer, Object value) in c:\Dev\protobuf-net\protobuf-net\Meta\TypeModel.cs:186
ProtoBuf.Meta.TypeModel.Serialize(Stream dest, Object value, SerializationContext context) in c:\Dev\protobuf-net\protobuf-net\Meta\TypeModel.cs:217
ProtoBuf.Meta.TypeModel.Serialize(Stream dest, Object value) in c:\Dev\protobuf-net\protobuf-net\Meta\TypeModel.cs:201
PublicBroadcasting.Impl.Envelope.Get(TypeDescription desc, POCOBuilder mapper, Object payload) in c:\Users\kmontrose\Dropbox\PublicBroadcasting\PublicBroadcasting\Impl\Envelope.cs:45
PublicBroadcasting.Serializer.Serialize(Stream stream, T obj, IncludedMembers members, IncludedVisibility visibility) in c:\Users\kmontrose\Dropbox\PublicBroadcasting\PublicBroadcasting\Serializer.cs:248
PublicBroadcasting.Serializer.Serialize(T obj, IncludedMembers members, IncludedVisibility visibility) in c:\Users\kmontrose\Dropbox\PublicBroadcasting\PublicBroadcasting\Serializer.cs:119
PublicBroadcasting.Serializer.Serialize(T obj) in c:\Users\kmontrose\Dropbox\PublicBroadcasting\PublicBroadcasting\Serializer.cs:34
The object I'm trying to serialize looks like:
public class ActionSettings
{
public string ActionName { get; set; }
public string ControllerName { get; set; }
public RouteValueDictionary RouteValues { get; set; }
}
Hope this helps and please let me know if I can provide any other details
I'll try to work on a reliable reproduction, but in the mean time, this is the stack trace:
[ArgumentNullException: Value cannot be null.
Parameter name: type]
System.Reflection.Emit.FieldBuilder..ctor(TypeBuilder typeBuilder, String fieldName, Type type, Type[] requiredCustomModifiers, Type[] optionalCustomModifiers, FieldAttributes attributes) +10533905
System.Reflection.Emit.TypeBuilder.DefineFieldNoLock(String fieldName, Type type, Type[] requiredCustomModifiers, Type[] optionalCustomModifiers, FieldAttributes attributes) +146
System.Reflection.Emit.TypeBuilder.DefineField(String fieldName, Type type, Type[] requiredCustomModifiers, Type[] optionalCustomModifiers, FieldAttributes attributes) +98
System.Reflection.Emit.TypeBuilder.DefineField(String fieldName, Type type, FieldAttributes attributes) +17
PublicBroadcasting.Impl.ClassTypeDescription.Seal(TypeDescription existing) in c:\Dev\Forks\public-broadcasting\PublicBroadcasting\Impl\Describer.ClassTypeDescription.cs:248
PublicBroadcasting.Impl.Deserializer.DeserializeCore(Stream stream, Type& type) in c:\Dev\Forks\public-broadcasting\PublicBroadcasting\Impl\Deserializer.cs:65
PublicBroadcasting.Impl.Deserializer.Deserialize(Stream stream) in c:\Dev\Forks\public-broadcasting\PublicBroadcasting\Impl\Deserializer.cs:19
PublicBroadcasting.Serializer.Deserialize(Stream stream) in c:\Dev\Forks\public-broadcasting\PublicBroadcasting\Serializer.cs:631
PublicBroadcasting.Serializer.Deserialize(Byte[] bytes) in c:\Dev\Forks\public-broadcasting\PublicBroadcasting\Serializer.cs:614
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.