silentorbit / protobuf

C# code generator for reading and writing the protocol buffers format
https://silentorbit.com/protobuf/
MIT License
307 stars 105 forks source link

Issue with a proto file #55

Closed gauravsaxenais closed 2 years ago

gauravsaxenais commented 4 years ago

Hi

I have a proto file like this:

syntax = "proto3";

package _abbbd3832ad747a0a1b0cd1b3c6d6579;

enum Allocator { // This needs to be here as a zero value. DO_NOT_REMOVE = 0; VALUE = 1; };

enum StandardEventCodes { // Signal: N/A POWER_UP = 0;

// Signal: N/A WAKE_UP = 1;

// Signal: N/A POWER_OR_WAKE_UP = 2; };

enum StandardFilterCodes { // Signal: The current profile. IS_CURRENT_PROFILE = 0;

// Signal: The restricted mode // 0 - unrestricted // 1 - restricted // 2 - transport // 3 - invalid IS_RESTRICTED_MODE = 1; };

enum StandardActionCodes { // Signal: The profile to apply. APPLY_PROFILE = 0; };

message Config { message Profile { enum State { ACTIVE = 0; SLEEP = 1; HIBERNATE = 2; };

// The profile's state.
State state = 1;

// What will wake the device up (input, adc_threshold, cell, etc).
uint32 wakeup_mask = 2;

// How long to wait before applying this profile in seconds.
uint32 delay_s = 3;

};

repeated Profile profiles = 1; };

If I add required or optional in front of uint32 it generates a cs file else it doesnot. Is there any way to fix this?

hultqvist commented 4 years ago

The code generator only support proto2 syntax which requires one of the prefixes: required/optional/repeated.

Making it compatible with proto3 syntax in this regard would be quite easy by tracking where the exception is thrown and modify the code there. Such a contribution would be gladly accepted.