protocolbuffers / protobuf

Protocol Buffers - Google's data interchange format
http://protobuf.dev
Other
64.57k stars 15.37k forks source link

descriptor.proto using not official syntax #16943

Open oldergod opened 1 month ago

oldergod commented 1 month ago

Hello, a change has been done to descriptor.proto recently defining declarations on extensions

https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/descriptor.proto#L1074-L1091

  extensions 1000 to 9994 [
    declaration = {
      number: 1000,
      full_name: ".pb.cpp",
      type: ".pb.CppFeatures"
    },

The doc doesn't have any info about it here https://protobuf.dev/reference/protobuf/proto2-spec/#extensions_and_reserved

extensions = "extensions" ranges ";"
ranges = range { "," range }
range =  intLit [ "to" ( intLit | "max" ) ]
zhangskz commented 1 month ago

This reserves the extension number 1000 exclusively for cpp features, and errors if the extension number is used for a different extension.

Looks like we do have this documented in https://protobuf.dev/programming-guides/extension_declarations/ but should probably consolidate or link from https://protobuf.dev/reference/protobuf/proto2-spec/#extensions_and_reserved? @Logofile Could you take a look?

IIRC we haven't fully open-sourced extension declarations for custom options yet, since we need to add a way for users to pass this to protoc in OSS. (@shaod2 is working on this, but is out for a bit)

Logofile commented 1 month ago

Thanks for raising this issue. I'll work on getting the docs current.