Open GoogleCodeExporter opened 8 years ago
I had a similar problem where code like
class TestClass
{
[ProtoMember(3,IsRequired=true)]
TestObject myObj;
}
class TestObj
{
[ProtoMember(1)]
double Value1;
[ProtoMember(2)]
double Value2;
}
would not end up sending the object in the case of default values, because the
IsRequired value doesn't flow down to the TestObject. If you set IsRequired to
true in the object, it works as expected.
It can be a little odd if you use TestObj everywhere, like it's a base type
that is common throughout your application because the IsRequired = true seems
to flow up. Setting it on the TestObject will override whatever declaration
you put on the instantiated object itself.
So, this will always serialize the object and send it even though the object is
not required:
class TestClass
{
[ProtoMember(3,IsRequired=false)]
TestObject myObj;
}
class TestObj
{
[ProtoMember(1,IsRequired=true)]
double Value1;
[ProtoMember(2,IsRequired=true)]
double Value2;
}
v480, Win7.
Original comment by mikepe...@gmail.com
on 3 Feb 2012 at 9:14
Any further developments with this? I can't find any documentation on the
IsRequired option? Thanks.
Original comment by p...@mac.gen.nz
on 24 Feb 2012 at 11:42
Currently, IsRequired primarily impacts **serialization**, forcing it to ignore
some default rules. It is perhaps a little too forgiving at deserialization;
enforcing this data at the point of deserialization is on the list for
attention at some point (on an opt-in basis).
Original comment by marc.gravell
on 24 Feb 2012 at 12:14
Original issue reported on code.google.com by
lu...@kabrt.cz
on 2 Jan 2012 at 10:37Attachments: