silentorbit / protobuf

C# code generator for reading and writing the protocol buffers format
https://silentorbit.com/protobuf/
MIT License
307 stars 105 forks source link

extensions dont create any code #37

Closed furesoft closed 2 years ago

hultqvist commented 9 years ago

Can you provide a sample .proto to show the functionality needed?

furesoft commented 9 years ago
package com.Furesoft;

message Uri {    
      optional string scheme = 1 [default = "http"];
      optional int32 port = 2 [default = 80];
      required string host = 3;

      optional Path path = 4;

      optional Credentials Credentials = 5;

      extensions 6 to max;

      message Credentials {
        required string username = 1;
        required string password = 2;
      }

      message Path  {
        optional string file = 1;
        optional string query = 2;
        optional string segment = 3;
        optional string folder = 4;
      }
}

extend Uri {
    required int32 id = 7;
}

but there is no code for the extended stuff

furesoft commented 9 years ago

here a sample usage

uri.SetExtension(Fields.id, 5);

uri.GetExtension(Fields.id);

hultqvist commented 9 years ago

At code generation time this is all statically known so one could have the property

uri.ExtensionId

or even more directly(assuming there are no name collisions)

uri.Id

Would the deserializer have to be more forgiving since some other implementation might have been using other wire-types with the same extension id?