CMertens / protobuf-net

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

Should not throw "unexpected sub-type" error when sub-type not marked for serialization #374

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago

What steps will reproduce the problem?
1. Declare classes A and B: A (and some public properties)
2. Mark A with [ProtoContract(ImplicitFields = ImplicitFields.AllPublic)]
3. Leave B unmarked.
4. Serialize B as A (or use List<A> filled with B instances)

What is the expected output? What do you see instead?
  This should work without error, as the fact that B is not marked for proto-buf serialization should signal the intention that B is not meant for serialization. However, I get an unexpected sub-type error.

What version of the product are you using? On what operating system?
  version 2.0.0.621, Windows 8

Use Case: I have OR mapping code where publicly shared models are subclassed 
for internal OR mapping purposes. This fact prevents serialization with 
protobuf-net (but works fine with Json.net).

My e-mail: karl@waclawek.net

Original issue reported on code.google.com by kwac...@gmail.com on 19 Apr 2013 at 2:32

GoogleCodeExporter commented 9 years ago
I have a separate - but similar issue - where I get an "unexpected type" error 
(not "unexpected sub-type"!), though it still is the same scenario. (it happens 
in method TrySerializeAuxiliaryType).

I have an external assembly that returns an IEnumerable<SomeClass>, however, 
the actual instances returned are of a type that is a sub-class of SomeClass. 
This derived type is private to the external assembly, so it looks like I have 
no way to get proto-buf-net to serialize these instances.

Original comment by kwac...@gmail.com on 12 Jul 2013 at 3:40