Does protobuf-net support nullable types?

前端 未结 3 1472
盖世英雄少女心
盖世英雄少女心 2021-01-04 02:31

Is it possible to generate nullable members in protobuf-net?

message ProtoBuf1 {
    optional Int32? databit = 1;
    optional Nullable databool          


        
3条回答
  •  一个人的身影
    2021-01-04 02:45

    Proto 3

    Import "wrappers.proto" supports nullable values:

    • string(StringValue),
    • int(Int32Value),
    • bool(BoolValue)
    • and etc

    Full list of supported types - https://docs.microsoft.com/en-us/dotnet/architecture/grpc-for-wcf-developers/protobuf-data-types#nullable-types

    Example:

    syntax = "proto3";
    import "google/protobuf/wrappers.proto";
    
    message ProtoPerson {
        google.protobuf.StringValue firstName = 1;
        google.protobuf.StringValue lastName = 2;
        google.protobuf.StringValue address1 = 3;
        google.protobuf.Int32Value age = 4;
    }
    

提交回复
热议问题