DerrickBrayanClayton / protobuf-net

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

protogen - deserializing constructor #52

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I've encountered problems when testing the protogen classes with standard
WCF soap/xml serialization.  Basically, repeated objects fail to work on
the server-side because the constructor is not called.  Therefore the
List<T> is not constructed.  Since the repeated properties only have
getters and not setters it fails badly.

Normally I'd prefer an explicit initializer but that would require
rewriting the xslt which is mildly painful.  Instead I use reflection to
invoke the standard constructor.

public CTor() { this.Initialize(); }
private void Initialize() { .... Do required initialization ... }
[OnDeserializing]
void OnDeserialization() { StreamingContext ctx ) { this.Initialize(); }

I suppose this code could be moved to a separate partial file but its
annoying to do so for every class that needs it.

Original issue reported on code.google.com by abbott.t...@gmail.com on 18 Mar 2009 at 4:19

Attachments:

GoogleCodeExporter commented 8 years ago
I suspect I can do this (or something similar) in the xslt without too much 
pain...

Original comment by marc.gravell on 18 Mar 2009 at 4:31

GoogleCodeExporter commented 8 years ago

Original comment by marc.gravell on 16 Jan 2013 at 2:09