c# - Serializer is trying to serialize a property decorated with [ProtoIgnore] -
i have next class
[protocontract(implicitfields = implicitfields.allfields)] public class foo { public int foo { get; set; } [protoignore] public bar bar { get; set; } public int tomd5hash() { var md5 = md5cryptoserviceprovider.create(); using (memorystream ms = new memorystream()) { serializer.serialize<foo>(ms, this); var hash = md5.computehash(ms.toarray()); homecoming bitconverter.toint32(hash, 0); } } }
but getting exception when calling tomd5hash. says no serializer defined type: somenamespace.bar
if property decorated protoignore attribute.
note: if remove implicitfields , utilize protomember, serialization works.
am doing wrong?
you've told serialize fields. field not decorated [protoignore]
. property is, , there no way equate fields properties. utilize of term "fields" here specific , intentional: doesn't mean "members" - means "fields".
options:
tell serialize public members, not fields use manually implemented property , mark field[protoignore]
mark members manually it nice if automatically implemented properties allowed same syntax field-like events, i.e.
[field:protoignore] public int foo {get;set;}
however, i'm pretty sure not supported in language.
c# .net serialization protobuf-net
No comments:
Post a Comment