New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Serialized proto not matching between Attribute
declaration vs RuntimeTypeModel
with missing set
on property
#964
Comments
OK; running this through https://protogen.marcgravell.com/decode, we see:
vs
so: the order of fields has inverted, we expect the order to be The immediate problem here is that it is inferring the member order as a tuple-like type - meaning: when it finds no attributes (in A library failure is that the As a side note - interestingly, if we have the protobuf-net.BuildTools package included, we see (against
However, the serializer does work, so: I would consider this a tertiary error in the analyzer package. |
PR added; thoughts welcome |
Thanks for getting back to me so quickly - really appreciate it! Makes sense what you've said and your PR looks good. For the project I'm using this in, I didn't catch this problem in time so now I've got users with both types of generated proto data (which is my own problem to resolve). As much as I'd rather not have hit this problem, it is great to know it isn't some major problem in protobuf-net and I can safely get around it by disabling that Keep building awesome things! 🙂 |
* Disable default behaviour of protobuf-net See issue: protobuf-net/protobuf-net#964 * Catch and log serialization exceptions * Remove obsolete service collection methods * Allow logging to be optional * Fix test compilation errors * Fix build errors in benchmarks * Fix service collection tests * Allow init properties for CacheEntry Makes Protobuf happy and is probably a better solution than making Protobuf skip any constructors
Not the most succinct title but it does more-or-less say what I mean. Basically I think I've discovered a problem between how declaring proto members via attributes vs via the
RuntimeTypeModel
works, particularly around properties that have setters or not.This is a sample of what I put together in LINQPad which triggers the problem:
Now for
TestClass
, make either of the properties have aset;
on it and run the code again - you'll see that it previously was not outputting byte-for-byte the same representation but actually applying a different order. The second attempt with theset;
will match but the first attempt without it won't.Am I missing some behavioural quirk with how this is meant to work? I've looked over my code a bunch of times but don't see anything I'm doing wrong.
The text was updated successfully, but these errors were encountered: