|
|
@@ -15,6 +15,7 @@ import (
|
|
|
protoV1 "github.com/golang/protobuf/proto"
|
|
|
descriptorV1 "github.com/golang/protobuf/protoc-gen-go/descriptor"
|
|
|
|
|
|
+ scalar "github.com/golang/protobuf/v2/internal/scalar"
|
|
|
pref "github.com/golang/protobuf/v2/reflect/protoreflect"
|
|
|
)
|
|
|
|
|
|
@@ -113,17 +114,17 @@ func TestFile(t *testing.T) {
|
|
|
Syntax: pref.Proto2,
|
|
|
Path: "path/to/file.proto",
|
|
|
Package: "test",
|
|
|
- Options: &descriptorV1.FileOptions{Deprecated: protoV1.Bool(true)},
|
|
|
+ Options: &descriptorV1.FileOptions{Deprecated: scalar.Bool(true)},
|
|
|
Messages: []Message{{
|
|
|
Name: "A", // "test.A"
|
|
|
Options: &descriptorV1.MessageOptions{
|
|
|
- MapEntry: protoV1.Bool(true),
|
|
|
- Deprecated: protoV1.Bool(true),
|
|
|
+ MapEntry: scalar.Bool(true),
|
|
|
+ Deprecated: scalar.Bool(true),
|
|
|
},
|
|
|
Fields: []Field{{
|
|
|
Name: "key", // "test.A.key"
|
|
|
Number: 1,
|
|
|
- Options: &descriptorV1.FieldOptions{Deprecated: protoV1.Bool(true)},
|
|
|
+ Options: &descriptorV1.FieldOptions{Deprecated: scalar.Bool(true)},
|
|
|
Cardinality: pref.Optional,
|
|
|
Kind: pref.StringKind,
|
|
|
}, {
|
|
|
@@ -170,7 +171,7 @@ func TestFile(t *testing.T) {
|
|
|
Number: 5,
|
|
|
Cardinality: pref.Repeated,
|
|
|
Kind: pref.Int32Kind,
|
|
|
- Options: &descriptorV1.FieldOptions{Packed: protoV1.Bool(true)},
|
|
|
+ Options: &descriptorV1.FieldOptions{Packed: scalar.Bool(true)},
|
|
|
}, {
|
|
|
Name: "field_six", // "test.B.field_six"
|
|
|
Number: 6,
|
|
|
@@ -204,19 +205,19 @@ func TestFile(t *testing.T) {
|
|
|
Number: 1000,
|
|
|
Cardinality: pref.Repeated,
|
|
|
Kind: pref.MessageKind,
|
|
|
- Options: &descriptorV1.FieldOptions{Packed: protoV1.Bool(false)},
|
|
|
+ Options: &descriptorV1.FieldOptions{Packed: scalar.Bool(false)},
|
|
|
MessageType: PlaceholderMessage("test.C"),
|
|
|
ExtendedType: PlaceholderMessage("test.B"),
|
|
|
}},
|
|
|
}},
|
|
|
Enums: []Enum{{
|
|
|
Name: "E1", // "test.E1"
|
|
|
- Options: &descriptorV1.EnumOptions{Deprecated: protoV1.Bool(true)},
|
|
|
+ Options: &descriptorV1.EnumOptions{Deprecated: scalar.Bool(true)},
|
|
|
Values: []EnumValue{
|
|
|
{
|
|
|
Name: "FOO",
|
|
|
Number: 0,
|
|
|
- Options: &descriptorV1.EnumValueOptions{Deprecated: protoV1.Bool(true)},
|
|
|
+ Options: &descriptorV1.EnumValueOptions{Deprecated: scalar.Bool(true)},
|
|
|
},
|
|
|
{Name: "BAR", Number: 1},
|
|
|
},
|
|
|
@@ -226,20 +227,20 @@ func TestFile(t *testing.T) {
|
|
|
Number: 1000,
|
|
|
Cardinality: pref.Repeated,
|
|
|
Kind: pref.MessageKind,
|
|
|
- Options: &descriptorV1.FieldOptions{Packed: protoV1.Bool(true)},
|
|
|
+ Options: &descriptorV1.FieldOptions{Packed: scalar.Bool(true)},
|
|
|
MessageType: PlaceholderMessage("test.C"),
|
|
|
ExtendedType: PlaceholderMessage("test.B"),
|
|
|
}},
|
|
|
Services: []Service{{
|
|
|
Name: "S", // "test.S"
|
|
|
- Options: &descriptorV1.ServiceOptions{Deprecated: protoV1.Bool(true)},
|
|
|
+ Options: &descriptorV1.ServiceOptions{Deprecated: scalar.Bool(true)},
|
|
|
Methods: []Method{{
|
|
|
Name: "M", // "test.S.M"
|
|
|
InputType: PlaceholderMessage("test.A"),
|
|
|
OutputType: PlaceholderMessage("test.C.A"),
|
|
|
IsStreamingClient: true,
|
|
|
IsStreamingServer: true,
|
|
|
- Options: &descriptorV1.MethodOptions{Deprecated: protoV1.Bool(true)},
|
|
|
+ Options: &descriptorV1.MethodOptions{Deprecated: scalar.Bool(true)},
|
|
|
}},
|
|
|
}},
|
|
|
}
|
|
|
@@ -249,147 +250,147 @@ func TestFile(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
f2 := &descriptorV1.FileDescriptorProto{
|
|
|
- Syntax: protoV1.String("proto2"),
|
|
|
- Name: protoV1.String("path/to/file.proto"),
|
|
|
- Package: protoV1.String("test"),
|
|
|
- Options: &descriptorV1.FileOptions{Deprecated: protoV1.Bool(true)},
|
|
|
+ Syntax: scalar.String("proto2"),
|
|
|
+ Name: scalar.String("path/to/file.proto"),
|
|
|
+ Package: scalar.String("test"),
|
|
|
+ Options: &descriptorV1.FileOptions{Deprecated: scalar.Bool(true)},
|
|
|
MessageType: []*descriptorV1.DescriptorProto{{
|
|
|
- Name: protoV1.String("A"),
|
|
|
+ Name: scalar.String("A"),
|
|
|
Options: &descriptorV1.MessageOptions{
|
|
|
- MapEntry: protoV1.Bool(true),
|
|
|
- Deprecated: protoV1.Bool(true),
|
|
|
+ MapEntry: scalar.Bool(true),
|
|
|
+ Deprecated: scalar.Bool(true),
|
|
|
},
|
|
|
Field: []*descriptorV1.FieldDescriptorProto{{
|
|
|
- Name: protoV1.String("key"),
|
|
|
- Number: protoV1.Int32(1),
|
|
|
- Options: &descriptorV1.FieldOptions{Deprecated: protoV1.Bool(true)},
|
|
|
+ Name: scalar.String("key"),
|
|
|
+ Number: scalar.Int32(1),
|
|
|
+ Options: &descriptorV1.FieldOptions{Deprecated: scalar.Bool(true)},
|
|
|
Label: descriptorV1.FieldDescriptorProto_Label(pref.Optional).Enum(),
|
|
|
Type: descriptorV1.FieldDescriptorProto_Type(pref.StringKind).Enum(),
|
|
|
}, {
|
|
|
- Name: protoV1.String("value"),
|
|
|
- Number: protoV1.Int32(2),
|
|
|
+ Name: scalar.String("value"),
|
|
|
+ Number: scalar.Int32(2),
|
|
|
Label: descriptorV1.FieldDescriptorProto_Label(pref.Optional).Enum(),
|
|
|
Type: descriptorV1.FieldDescriptorProto_Type(pref.MessageKind).Enum(),
|
|
|
- TypeName: protoV1.String(".test.B"),
|
|
|
+ TypeName: scalar.String(".test.B"),
|
|
|
}},
|
|
|
}, {
|
|
|
- Name: protoV1.String("B"),
|
|
|
+ Name: scalar.String("B"),
|
|
|
Field: []*descriptorV1.FieldDescriptorProto{{
|
|
|
- Name: protoV1.String("field_one"),
|
|
|
- Number: protoV1.Int32(1),
|
|
|
+ Name: scalar.String("field_one"),
|
|
|
+ Number: scalar.Int32(1),
|
|
|
Label: descriptorV1.FieldDescriptorProto_Label(pref.Optional).Enum(),
|
|
|
Type: descriptorV1.FieldDescriptorProto_Type(pref.StringKind).Enum(),
|
|
|
- DefaultValue: protoV1.String("hello, \"world!\"\n"),
|
|
|
- OneofIndex: protoV1.Int32(0),
|
|
|
+ DefaultValue: scalar.String("hello, \"world!\"\n"),
|
|
|
+ OneofIndex: scalar.Int32(0),
|
|
|
}, {
|
|
|
- Name: protoV1.String("field_two"),
|
|
|
- JsonName: protoV1.String("Field2"),
|
|
|
- Number: protoV1.Int32(2),
|
|
|
+ Name: scalar.String("field_two"),
|
|
|
+ JsonName: scalar.String("Field2"),
|
|
|
+ Number: scalar.Int32(2),
|
|
|
Label: descriptorV1.FieldDescriptorProto_Label(pref.Optional).Enum(),
|
|
|
Type: descriptorV1.FieldDescriptorProto_Type(pref.EnumKind).Enum(),
|
|
|
- DefaultValue: protoV1.String("BAR"),
|
|
|
- TypeName: protoV1.String(".test.E1"),
|
|
|
- OneofIndex: protoV1.Int32(1),
|
|
|
+ DefaultValue: scalar.String("BAR"),
|
|
|
+ TypeName: scalar.String(".test.E1"),
|
|
|
+ OneofIndex: scalar.Int32(1),
|
|
|
}, {
|
|
|
- Name: protoV1.String("field_three"),
|
|
|
- Number: protoV1.Int32(3),
|
|
|
+ Name: scalar.String("field_three"),
|
|
|
+ Number: scalar.Int32(3),
|
|
|
Label: descriptorV1.FieldDescriptorProto_Label(pref.Optional).Enum(),
|
|
|
Type: descriptorV1.FieldDescriptorProto_Type(pref.MessageKind).Enum(),
|
|
|
- TypeName: protoV1.String(".test.C"),
|
|
|
- OneofIndex: protoV1.Int32(1),
|
|
|
+ TypeName: scalar.String(".test.C"),
|
|
|
+ OneofIndex: scalar.Int32(1),
|
|
|
}, {
|
|
|
- Name: protoV1.String("field_four"),
|
|
|
- JsonName: protoV1.String("Field4"),
|
|
|
- Number: protoV1.Int32(4),
|
|
|
+ Name: scalar.String("field_four"),
|
|
|
+ JsonName: scalar.String("Field4"),
|
|
|
+ Number: scalar.Int32(4),
|
|
|
Label: descriptorV1.FieldDescriptorProto_Label(pref.Repeated).Enum(),
|
|
|
Type: descriptorV1.FieldDescriptorProto_Type(pref.MessageKind).Enum(),
|
|
|
- TypeName: protoV1.String(".test.A"),
|
|
|
+ TypeName: scalar.String(".test.A"),
|
|
|
}, {
|
|
|
- Name: protoV1.String("field_five"),
|
|
|
- Number: protoV1.Int32(5),
|
|
|
+ Name: scalar.String("field_five"),
|
|
|
+ Number: scalar.Int32(5),
|
|
|
Label: descriptorV1.FieldDescriptorProto_Label(pref.Repeated).Enum(),
|
|
|
Type: descriptorV1.FieldDescriptorProto_Type(pref.Int32Kind).Enum(),
|
|
|
- Options: &descriptorV1.FieldOptions{Packed: protoV1.Bool(true)},
|
|
|
+ Options: &descriptorV1.FieldOptions{Packed: scalar.Bool(true)},
|
|
|
}, {
|
|
|
- Name: protoV1.String("field_six"),
|
|
|
- Number: protoV1.Int32(6),
|
|
|
+ Name: scalar.String("field_six"),
|
|
|
+ Number: scalar.Int32(6),
|
|
|
Label: descriptorV1.FieldDescriptorProto_Label(pref.Required).Enum(),
|
|
|
Type: descriptorV1.FieldDescriptorProto_Type(pref.BytesKind).Enum(),
|
|
|
}},
|
|
|
OneofDecl: []*descriptorV1.OneofDescriptorProto{
|
|
|
{
|
|
|
- Name: protoV1.String("O1"),
|
|
|
+ Name: scalar.String("O1"),
|
|
|
Options: &descriptorV1.OneofOptions{
|
|
|
UninterpretedOption: []*descriptorV1.UninterpretedOption{
|
|
|
{StringValue: []byte("option")},
|
|
|
},
|
|
|
},
|
|
|
},
|
|
|
- {Name: protoV1.String("O2")},
|
|
|
+ {Name: scalar.String("O2")},
|
|
|
},
|
|
|
ExtensionRange: []*descriptorV1.DescriptorProto_ExtensionRange{
|
|
|
- {Start: protoV1.Int32(1000), End: protoV1.Int32(2000)},
|
|
|
- {Start: protoV1.Int32(3000), End: protoV1.Int32(3001)},
|
|
|
+ {Start: scalar.Int32(1000), End: scalar.Int32(2000)},
|
|
|
+ {Start: scalar.Int32(3000), End: scalar.Int32(3001)},
|
|
|
},
|
|
|
}, {
|
|
|
- Name: protoV1.String("C"),
|
|
|
+ Name: scalar.String("C"),
|
|
|
NestedType: []*descriptorV1.DescriptorProto{{
|
|
|
- Name: protoV1.String("A"),
|
|
|
+ Name: scalar.String("A"),
|
|
|
Field: []*descriptorV1.FieldDescriptorProto{{
|
|
|
- Name: protoV1.String("F"),
|
|
|
- Number: protoV1.Int32(1),
|
|
|
+ Name: scalar.String("F"),
|
|
|
+ Number: scalar.Int32(1),
|
|
|
Label: descriptorV1.FieldDescriptorProto_Label(pref.Required).Enum(),
|
|
|
Type: descriptorV1.FieldDescriptorProto_Type(pref.BytesKind).Enum(),
|
|
|
- DefaultValue: protoV1.String(`dead\276\357`),
|
|
|
+ DefaultValue: scalar.String(`dead\276\357`),
|
|
|
}},
|
|
|
}},
|
|
|
EnumType: []*descriptorV1.EnumDescriptorProto{{
|
|
|
- Name: protoV1.String("E1"),
|
|
|
+ Name: scalar.String("E1"),
|
|
|
Value: []*descriptorV1.EnumValueDescriptorProto{
|
|
|
- {Name: protoV1.String("FOO"), Number: protoV1.Int32(0)},
|
|
|
- {Name: protoV1.String("BAR"), Number: protoV1.Int32(1)},
|
|
|
+ {Name: scalar.String("FOO"), Number: scalar.Int32(0)},
|
|
|
+ {Name: scalar.String("BAR"), Number: scalar.Int32(1)},
|
|
|
},
|
|
|
}},
|
|
|
Extension: []*descriptorV1.FieldDescriptorProto{{
|
|
|
- Name: protoV1.String("X"),
|
|
|
- Number: protoV1.Int32(1000),
|
|
|
+ Name: scalar.String("X"),
|
|
|
+ Number: scalar.Int32(1000),
|
|
|
Label: descriptorV1.FieldDescriptorProto_Label(pref.Repeated).Enum(),
|
|
|
Type: descriptorV1.FieldDescriptorProto_Type(pref.MessageKind).Enum(),
|
|
|
- TypeName: protoV1.String(".test.C"),
|
|
|
- Extendee: protoV1.String(".test.B"),
|
|
|
+ TypeName: scalar.String(".test.C"),
|
|
|
+ Extendee: scalar.String(".test.B"),
|
|
|
}},
|
|
|
}},
|
|
|
EnumType: []*descriptorV1.EnumDescriptorProto{{
|
|
|
- Name: protoV1.String("E1"),
|
|
|
- Options: &descriptorV1.EnumOptions{Deprecated: protoV1.Bool(true)},
|
|
|
+ Name: scalar.String("E1"),
|
|
|
+ Options: &descriptorV1.EnumOptions{Deprecated: scalar.Bool(true)},
|
|
|
Value: []*descriptorV1.EnumValueDescriptorProto{
|
|
|
{
|
|
|
- Name: protoV1.String("FOO"),
|
|
|
- Number: protoV1.Int32(0),
|
|
|
- Options: &descriptorV1.EnumValueOptions{Deprecated: protoV1.Bool(true)},
|
|
|
+ Name: scalar.String("FOO"),
|
|
|
+ Number: scalar.Int32(0),
|
|
|
+ Options: &descriptorV1.EnumValueOptions{Deprecated: scalar.Bool(true)},
|
|
|
},
|
|
|
- {Name: protoV1.String("BAR"), Number: protoV1.Int32(1)},
|
|
|
+ {Name: scalar.String("BAR"), Number: scalar.Int32(1)},
|
|
|
},
|
|
|
}},
|
|
|
Extension: []*descriptorV1.FieldDescriptorProto{{
|
|
|
- Name: protoV1.String("X"),
|
|
|
- Number: protoV1.Int32(1000),
|
|
|
+ Name: scalar.String("X"),
|
|
|
+ Number: scalar.Int32(1000),
|
|
|
Label: descriptorV1.FieldDescriptorProto_Label(pref.Repeated).Enum(),
|
|
|
Type: descriptorV1.FieldDescriptorProto_Type(pref.MessageKind).Enum(),
|
|
|
- Options: &descriptorV1.FieldOptions{Packed: protoV1.Bool(true)},
|
|
|
- TypeName: protoV1.String(".test.C"),
|
|
|
- Extendee: protoV1.String(".test.B"),
|
|
|
+ Options: &descriptorV1.FieldOptions{Packed: scalar.Bool(true)},
|
|
|
+ TypeName: scalar.String(".test.C"),
|
|
|
+ Extendee: scalar.String(".test.B"),
|
|
|
}},
|
|
|
Service: []*descriptorV1.ServiceDescriptorProto{{
|
|
|
- Name: protoV1.String("S"),
|
|
|
- Options: &descriptorV1.ServiceOptions{Deprecated: protoV1.Bool(true)},
|
|
|
+ Name: scalar.String("S"),
|
|
|
+ Options: &descriptorV1.ServiceOptions{Deprecated: scalar.Bool(true)},
|
|
|
Method: []*descriptorV1.MethodDescriptorProto{{
|
|
|
- Name: protoV1.String("M"),
|
|
|
- InputType: protoV1.String(".test.A"),
|
|
|
- OutputType: protoV1.String(".test.C.A"),
|
|
|
- ClientStreaming: protoV1.Bool(true),
|
|
|
- ServerStreaming: protoV1.Bool(true),
|
|
|
- Options: &descriptorV1.MethodOptions{Deprecated: protoV1.Bool(true)},
|
|
|
+ Name: scalar.String("M"),
|
|
|
+ InputType: scalar.String(".test.A"),
|
|
|
+ OutputType: scalar.String(".test.C.A"),
|
|
|
+ ClientStreaming: scalar.Bool(true),
|
|
|
+ ServerStreaming: scalar.Bool(true),
|
|
|
+ Options: &descriptorV1.MethodOptions{Deprecated: scalar.Bool(true)},
|
|
|
}},
|
|
|
}},
|
|
|
}
|
|
|
@@ -430,7 +431,7 @@ func testFileAccessors(t *testing.T, fd pref.FileDescriptor) {
|
|
|
"Path": "path/to/file.proto",
|
|
|
"Package": pref.FullName("test"),
|
|
|
"IsPlaceholder": false,
|
|
|
- "Options": &descriptorV1.FileOptions{Deprecated: protoV1.Bool(true)},
|
|
|
+ "Options": &descriptorV1.FileOptions{Deprecated: scalar.Bool(true)},
|
|
|
"Messages": M{
|
|
|
"Len": 3,
|
|
|
"Get:0": M{
|
|
|
@@ -442,8 +443,8 @@ func testFileAccessors(t *testing.T, fd pref.FileDescriptor) {
|
|
|
"IsPlaceholder": false,
|
|
|
"IsMapEntry": true,
|
|
|
"Options": &descriptorV1.MessageOptions{
|
|
|
- MapEntry: protoV1.Bool(true),
|
|
|
- Deprecated: protoV1.Bool(true),
|
|
|
+ MapEntry: scalar.Bool(true),
|
|
|
+ Deprecated: scalar.Bool(true),
|
|
|
},
|
|
|
"Fields": M{
|
|
|
"Len": 2,
|
|
|
@@ -455,7 +456,7 @@ func testFileAccessors(t *testing.T, fd pref.FileDescriptor) {
|
|
|
"Number": pref.FieldNumber(1),
|
|
|
"Cardinality": pref.Optional,
|
|
|
"Kind": pref.StringKind,
|
|
|
- "Options": &descriptorV1.FieldOptions{Deprecated: protoV1.Bool(true)},
|
|
|
+ "Options": &descriptorV1.FieldOptions{Deprecated: scalar.Bool(true)},
|
|
|
"JSONName": "key",
|
|
|
"IsPacked": false,
|
|
|
"IsMap": false,
|
|
|
@@ -603,13 +604,13 @@ func testFileAccessors(t *testing.T, fd pref.FileDescriptor) {
|
|
|
"Len": 1,
|
|
|
"Get:0": M{
|
|
|
"Name": pref.Name("E1"),
|
|
|
- "Options": &descriptorV1.EnumOptions{Deprecated: protoV1.Bool(true)},
|
|
|
+ "Options": &descriptorV1.EnumOptions{Deprecated: scalar.Bool(true)},
|
|
|
"Values": M{
|
|
|
"Len": 2,
|
|
|
"ByName:Foo": nil,
|
|
|
"ByName:FOO": M{
|
|
|
"FullName": pref.FullName("test.FOO"),
|
|
|
- "Options": &descriptorV1.EnumValueOptions{Deprecated: protoV1.Bool(true)},
|
|
|
+ "Options": &descriptorV1.EnumValueOptions{Deprecated: scalar.Bool(true)},
|
|
|
},
|
|
|
"ByNumber:2": nil,
|
|
|
"ByNumber:1": M{"FullName": pref.FullName("test.BAR")},
|
|
|
@@ -626,7 +627,7 @@ func testFileAccessors(t *testing.T, fd pref.FileDescriptor) {
|
|
|
"IsPacked": true,
|
|
|
"MessageType": M{"FullName": pref.FullName("test.C"), "IsPlaceholder": false},
|
|
|
"ExtendedType": M{"FullName": pref.FullName("test.B"), "IsPlaceholder": false},
|
|
|
- "Options": &descriptorV1.FieldOptions{Packed: protoV1.Bool(true)},
|
|
|
+ "Options": &descriptorV1.FieldOptions{Packed: scalar.Bool(true)},
|
|
|
},
|
|
|
},
|
|
|
"Services": M{
|
|
|
@@ -636,7 +637,7 @@ func testFileAccessors(t *testing.T, fd pref.FileDescriptor) {
|
|
|
"Parent": M{"FullName": pref.FullName("test")},
|
|
|
"Name": pref.Name("S"),
|
|
|
"FullName": pref.FullName("test.S"),
|
|
|
- "Options": &descriptorV1.ServiceOptions{Deprecated: protoV1.Bool(true)},
|
|
|
+ "Options": &descriptorV1.ServiceOptions{Deprecated: scalar.Bool(true)},
|
|
|
"Methods": M{
|
|
|
"Len": 1,
|
|
|
"Get:0": M{
|
|
|
@@ -647,7 +648,7 @@ func testFileAccessors(t *testing.T, fd pref.FileDescriptor) {
|
|
|
"OutputType": M{"FullName": pref.FullName("test.C.A"), "IsPlaceholder": false},
|
|
|
"IsStreamingClient": true,
|
|
|
"IsStreamingServer": true,
|
|
|
- "Options": &descriptorV1.MethodOptions{Deprecated: protoV1.Bool(true)},
|
|
|
+ "Options": &descriptorV1.MethodOptions{Deprecated: scalar.Bool(true)},
|
|
|
},
|
|
|
},
|
|
|
},
|