handoutz / protobuf-net

Automatically exported from code.google.com/p/protobuf-net
Other
0 stars 0 forks source link

Mixing generic simple and array types #166

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
If you try to serialize a generic class that could contain simple types and 
array types and declare both types with "ProtoInclude" at the same time, you 
get an error while serializing: "Unexpected type found during serialization; 
types must be included with ProtoIncludeAttribute; found ValueObject`1 passed 
as ValueObject"

What steps will reproduce the problem?

public class ValueObject<T> : ValueObject {
   private T _Data;

   [ProtoMember(1)]
   public new T Data { get { return _Data; } set { _Data = value; } }
}

[ProtoContract]
[ProtoInclude(100, typeof(ValueObject<bool>))]
[ProtoInclude(101, typeof(ValueObject<bool[]>))] 
public abstract class ValueObject {
}

As long as I used only one of the ProtoInclude and use the defined type only 
every thing works fine.

Version is 1.0.0.282

Original issue reported on code.google.com by t.st...@eckelmann.de on 30 Mar 2011 at 7:21

GoogleCodeExporter commented 9 years ago
Reproduced on v1 and v2; will look at

Original comment by marc.gravell on 30 Mar 2011 at 9:06

GoogleCodeExporter commented 9 years ago
Hi Marc,

is there a chance to get this issue fixed?
Up to now I could work without it, but it's getting more and more difficult to 
work without having ValueTypes and ArrayTypes mixed.

Hope to here something (positive)

Regards
Thomas

Original comment by t.st...@eckelmann.de on 29 Jun 2012 at 1:05