C#-prtocol缓冲区(生成.proto的C#代码)。 [英] C# -prtocol buffer (generate C# code to .proto ).
问题描述
如何从C#类生成.proto文件。
我的C#类代码包含超过3000行代码。
。所以想看看有没有简单的方法来做这个..转换C#(。cs)文件到.proto文件。
我尝试过:
基本上,给出:
消息人{
选项(my_message_option)= true;
可选字符串firstname = 1 [(my_field_option)= 42];
可选字符串lastname = 2 [(my_field_option)= 12];
可选int age = 3 ;
}
我想生成:
[ProtoContract,MyMessageOption(true)]
公共类人员
{
[ProtoMember(1),MyFieldOption(42)]
公共字符串名字;
[ProtoMember(2),MyFieldOption(12)]
公共字符串名字;
[ProtoMember(3)]
公共字符串名字;
}
我不知道.proto是什么,但一个简单的谷歌搜索的生成.proto文件c#想出了一堆东西。试试这些链接。
.net - 如何从带有属性的C#类生成.proto文件? - 堆栈溢出 [ ^ ]
c# - 从protobuf-net中的自定义RuntimeTypeModel生成.proto文件 - Stack Overflow [ ^ ]
c# - 如何从Protocol Buffers .NET代码生成.proto文件? - 堆栈溢出 [ ^ ]
How can I Generate a .proto file from a C# class.
My C# class code contains more than 3000 lines of code .
.so wanted to see is there any easy way to do this ..convert C# (.cs) files to .proto file.
What I have tried:
Basically, given:
message person {
option (my_message_option) = true;
optional string firstname = 1 [(my_field_option) = 42];
optional string lastname = 2 [(my_field_option) = 12];
optional int age = 3;
}
I want to generate:
[ProtoContract, MyMessageOption(true)]
public class Person
{
[ProtoMember(1), MyFieldOption(42)]
public string Firstname;
[ProtoMember(2), MyFieldOption(12)]
public string Firstname;
[ProtoMember(3)]
public string Firstname;
}
I have no idea what .proto is but a simple google search of "generate .proto file c#" came up with a bunch of stuff. Try these links.
.net - How do I generate a .proto file from a C# class decorated with attributes? - Stack Overflow[^]
c# - Generate .proto file from a custom RuntimeTypeModel in protobuf-net - Stack Overflow[^]
c# - How to generate .proto files from Protocol Buffers .NET code? - Stack Overflow[^]
这篇关于C#-prtocol缓冲区(生成.proto的C#代码)。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!