Skip to content
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

Values equal to 0 not serialized by ProtoBuf in .NET #32

Open
ghost opened this issue Mar 6, 2018 · 3 comments
Open

Values equal to 0 not serialized by ProtoBuf in .NET #32

ghost opened this issue Mar 6, 2018 · 3 comments
Labels

Comments

@ghost
Copy link

ghost commented Mar 6, 2018

I will show it basing on FeedHeader serialization:

new FeedHeader()
            {
                gtfs_realtime_version = "2.0",
                incrementality = FeedHeader.Incrementality.FULL_DATASET, // FeedHeader.Incrementality.FULL_DATASET == 0
                timestamp = Utils.ToUnixTime(DateTime.UtcNow)
            };

After serializing by ProtoBuf it seems that incrementality value (which is equal to 0) in FeedHeader class is not serialized, because when testing feed with https://github.com/CUTR-at-USF/gtfs-realtime-validator that validator shows me error "header incrementality not populated" and when I check (in that validator) protobuf file contents:

  "header": {
    "gtfs_realtime_version": "2.0",
    "timestamp": 1520343087
  }

Same problem is i.e. with:

  • ScheduleRelationship enums
  • delay in StopTimeEvent
  • etc.

Check also attached file.

screen

How to solve it? Can I control somehow which values should always be serialized even if they are null / zero / empty? I am using classess provided by Google:

@bugbiter
Copy link

bugbiter commented Oct 30, 2018

I have the same issue with FeedHeader.Incrementality. Workaround?

@barbeau barbeau added the bug label Mar 1, 2019
@barbeau
Copy link
Member

barbeau commented Mar 1, 2019

Looks like this is the underlying issue:
https://stackoverflow.com/questions/12295976/force-protobuf-net-to-serialize-all-default-values

@bugbiter @PiotrWojtowicz Are you able to try this workaround in your code to see if it works?

@adhunna
Copy link

adhunna commented Sep 11, 2019

Anyone found solution yet?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants