[英]Get IMessage from Proto file without generating C sharp file
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.是否可以在不生成 cs 文件的情况下获取 IMessage、字段描述符等。 I am using google protobuff.我正在使用谷歌 protobuff。
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.我想,这曾经是仅适用于C ++和Java为每间可用此文章,但C#实现也得到了扩展使用此功能。 I think this stackoverflow post might be helpful to you: How to parse .proto file into a FileDescriptor in C#?我认为这篇 stackoverflow 帖子可能对您有所帮助: 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.此外,此应用程序在运行时解析 proto 文件并生成 C# 代码,因此我确定您尝试执行的操作是可能的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.