0

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 1 state.
    State state = 2;

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

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

  enum BaudRate {
        // Slow rate (250 KBPS).
        LOW = 0;

        // Fast rate (500 KBPS).
        HIGH = 1;
    };

    enum Pdu1 {
        // Enable the Pdu1 PGN Mask.
        ENABLE = 0;

        // Disable the Pdu1 PGN Mask.
        DISABLE = 1;

        TEST = 2;
    };

    // The profile's 3 state.
    Profile profiles = 1;

    // Protocol Data Units message format.
    Pdu1 pdu = 2;
};

Is it possible to get IMessage, Field Descriptor etc without generating a cs file. I am using google protobuff.

Gauravsa
  • 6,330
  • 2
  • 21
  • 30

1 Answers1

1

I think this used to be available only for C++ and Java as per this article, but the C# implementation has also been extended with this feature. I think this stackoverflow post might be helpful to you: How to parse .proto file into a FileDescriptor in C#?

Also, this app parses proto files on runtime and generates C# code so I'm sure what you're trying to do is possible.

Ivan Ivković
  • 417
  • 3
  • 14