liuyi13-cpu / protobuf-3.16.0

修改protoc导出C#的命名规则

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

protoc编译

概述

lua中proto解析使用的lua-protobuf,命名规则使用默认proto文件里的,但是C#版本命名规则会自动转换成Camel命名,二边不一致。为了方便emmylua使用C#类来当提示,需要去掉生成C#代码的Camel命名,只有文件名字保留Camel命名

代码修改

版本:protobuf-csharp-3.6.1.zip

csharp_helpers.h新增

std::string UnderscoresToCamelCase1(const std::string& input,
                                   bool cap_next_letter,
                                   bool preserve_period);

csharp_helpers.cc

GetFileNameBase()
    return UnderscoresToCamelCase1(StripDotProto(base), true, false);
    // return UnderscoresToPascalCase(StripDotProto(base));

// 默认去掉转换
std::string UnderscoresToCamelCase(const std::string& input,
                                   bool cap_next_letter,
                                   bool preserve_period) {
    return input;                         
}

// UnderscoresToCamelCase1=原来的UnderscoresToCamelCase的实现
std::string UnderscoresToCamelCase1(const std::string& input,
                                   bool cap_next_letter,
                                   bool preserve_period) {
    ...
}

编译

mac

brew install autoconf automake libtool

git clone https://github.com/google/protobuf.git
cd protobuf
./autogen.sh
./configure --disable-shared
make
make install

win

使用cmake导出vs工程,使用vs2019编译protoc.exe

参考

https://www.jianshu.com/p/93aeae0d78e5
https://www.jianshu.com/p/f806faef245f
https://blog.csdn.net/dai_jing/article/details/83010324

About

修改protoc导出C#的命名规则

License:Other


Languages

Language:C++ 49.9%Language:C# 32.4%Language:Makefile 12.0%Language:Shell 2.5%Language:NASL 1.5%Language:CMake 0.4%Language:Starlark 0.4%Language:M4 0.4%Language:Java 0.1%Language:C 0.1%Language:Objective-C 0.1%Language:Python 0.1%Language:Emacs Lisp 0.0%Language:Ruby 0.0%Language:Pawn 0.0%Language:PHP 0.0%Language:Vim Script 0.0%Language:PowerShell 0.0%Language:Batchfile 0.0%