@@ -185,9 +185,48 @@ service TestService {
185
185
fds , err := pa .ParseFiles ("test.proto" )
186
186
testutil .Ok (t , err )
187
187
188
+ // Sanity check that this resulted in unrecognized options
189
+ unk := fds [0 ].FindSymbol ("TestService.Get" ).(* desc.MethodDescriptor ).GetMethodOptions ().ProtoReflect ().GetUnknown ()
190
+ testutil .Require (t , len (unk ) > 0 )
191
+
188
192
checkFile (t , & Printer {}, fds [0 ], "test-unrecognized-options.proto" )
189
193
}
190
194
195
+ func TestPrintUninterpretedOptions (t * testing.T ) {
196
+ files := map [string ]string {"test.proto" : `
197
+ syntax = "proto2";
198
+ package pkg;
199
+ option go_package = "some.pkg";
200
+ import "google/protobuf/descriptor.proto";
201
+ message Options {
202
+ optional bool some_option_value = 1;
203
+ }
204
+ extend google.protobuf.MessageOptions {
205
+ optional Options my_some_option = 11964;
206
+ }
207
+ message SomeMessage {
208
+ option (.pkg.my_some_option) = {some_option_value : true};
209
+ }
210
+ ` }
211
+
212
+ pa := & protoparse.Parser {
213
+ Accessor : protoparse .FileContentsFromMap (files ),
214
+ }
215
+ fds , err := pa .ParseFilesButDoNotLink ("test.proto" )
216
+ testutil .Ok (t , err )
217
+
218
+ // Sanity check that this resulted in uninterpreted options
219
+ unint := fds [0 ].MessageType [1 ].Options .UninterpretedOption
220
+ testutil .Require (t , len (unint ) > 0 )
221
+
222
+ descFd , err := desc .WrapFile ((* descriptorpb .FileDescriptorProto )(nil ).ProtoReflect ().Descriptor ().ParentFile ())
223
+ testutil .Ok (t , err )
224
+ fd , err := desc .CreateFileDescriptor (fds [0 ], descFd )
225
+ testutil .Ok (t , err )
226
+
227
+ checkFile (t , & Printer {}, fd , "test-uninterpreted-options.proto" )
228
+ }
229
+
191
230
func TestPrintNonFileDescriptors (t * testing.T ) {
192
231
pa := protoparse.Parser {ImportPaths : []string {"../../internal/testprotos" }, IncludeSourceCodeInfo : true }
193
232
fds , err := pa .ParseFiles ("desc_test_comments.proto" )
0 commit comments