protobuf 自动生成c# .cs文件 -protogen用法

    xiaoxiao2021-12-14  17

    usage: protogen -i:{infile2} [-i:{infile2}] [-o:{outfile}] [-t:{template}] [-p:{prop}[=value]] [-q] [-d]

    -i: Input file(s); proto definitions, either as text or pre-compiled binary (via protoc) -o: Output file; if none specified, writes to stdout -t: Template to use; defaults to csharp -p: Property for the template; value defaults to true; use -p:help to view available options -q: Quiet; suppresses header -d: Include all dependencies of the input files in the set so the set is self-contained. -ns: Default namespace; used in code generation when no package is specified

    C:\protobuf-net\ProtoGen>protogen -p:help protobuf-net:protogen - code generator for .proto         CSharp template for protobuf-net.         Options:         General:           "help" - this page         Additional serializer support:           "xml" - enable explicit xml support (XmlSerializer)           "datacontract" - enable data-contract support (DataContractSerializer; requires .NET 3.0)           "binary" - enable binary support (BinaryFormatter; not supported on Silverlight)         Other:           "protoRpc" - enable proto-rpc client           "observable" - change notification (observer pattern) support           "preObservable" - pre-change notification (observer pattern) support (requires .NET 3.5)           "partialMethods" - provide partial methods for changes (requires C# 3.0)           "detectMissing" - provide *Specified properties to indicate whether fields are present           "lightFramework" - omit additional attributes not included in CF/Silverlight           "asynchronous" - emit asynchronous methods for use with WCF           "clientProxy" - emit asynchronous client proxy class           "import" - additional namespaces to import (semicolon delimited)           "fixCase" - change type/member names (types/properties become PascalCase; fields become camelCase)   "observable" - change notification (observer pattern)  support 属性成员会继承 global::System.ComponentModel.INotifyPropertyChanged接口,并在set 方法中实现  set { OnPropertyChanged(@"***"); _*** = value; }   "preObservable" - pre-change notification (observer pattern) support (requires .NET 3.5) 属性成员会继承 global::System.ComponentModel.INotifyPropertyChanging,并在set方法中实现 OnProerthChanged   "detectMissing" - provide *Specified properties to indicate whether fields are present 对于option成员,添加 *Specified() 接口,判断该成员函数是否被赋值   注:使用detectMissing选项 和 不使用,如果有option成员为空,序列化时,字节长度会不一样 示例: cd C:\protobuf-net\ProtoGen protogen -i:apm\umi_msg_apm_enum.proto -o:umi_msg_apm_enum.cs  -p:detectMissing

    转载请注明原文地址: https://ju.6miu.com/read-962189.html

    最新回复(0)