# Netcore.ProtocolBuffer **Repository Path**: Tigerworm/Netcore.ProtocolBuffer ## Basic Information - **Project Name**: Netcore.ProtocolBuffer - **Description**: 在.netcore框架下使用google.protobuf序列化组件 - **Primary Language**: C# - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2019-03-27 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Netcore.ProtocolBuffer #### Description 在.netcore框架下使用google.protobuf序列化组件 #### Software Architecture Code by C# in .Netcore Platform #### Installation 1. 引用 `google.protobuf.3.7.0.nupkg` 2. 引用 `google.protobuf.tools.3.7.0.nupkg` 3. 下载上述两个nuget包,并将其引用至项目中。 4. Tools文件夹中的压缩包为 _google.protobuf.tools.3.7.0.nupkg_ 的解压缩文件,释放在当前文件夹中,并在当前文件夹中的 _google.protobuf.tools.3.7.0\tools_ 路径下,找到当前开发平台对应版本的文件夹,使用 _protoc.exe_ 对 _.proto_ 文件进行编译。 5. 编译命令为:`protoc.exe myProto.proto --csharp_out=C:\`。 其中`myProto.proto`为序列化实体描述文件,`C:\`编译后.cs实体文件的输出路径。 6. 将.cs的实体文件添加至项目内> 注意,实体文件代码为自动生成,请不要随意修改。 #### Instructions 1. 实体类中的基础字段注意定义序号。 2. 数组(集合)类型需要用`repeated`关键字修饰。 3. 对string类型数据,支持动态长度序列化,如`string name="hello"`,实体序列化后长度为5。 4. 对int,float,double等值类型数据,其长度不会减少,序列化后的byte数量仍是4,4,8。 5. 该组件并不会减少数据传输长度,与约束协议的byte拼接并无优势。 6. 如新增报文协议,则需要使用Protoc.exe对新定义的.proto文件进行编译生成实体文件。 #### Contribution Tigerworm