You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- this is (strangely?) a case-insensitive check, just like protoc enforces
- this enforces *default* JSON names don't conflict for proto3 files (even for fields that define a custom JSON name)
- this also adds checks that custom JSON names don't conflict (unlike protoc)
- this will only warn for proto2 files unless the issue is between conflicting *custom* names (JSON mapping was introduced in proto3, so not backwards compatible to fail due to default JSON names in proto2 files)
"foo.proto:4:3: field Foo.e: google.protobuf.Struct.FieldsEntry is a synthetic map entry and may not be referenced explicitly",
1008
1008
},
1009
+
{
1010
+
map[string]string{
1011
+
"foo.proto": "syntax = \"proto3\";\n"+
1012
+
"message Foo {\n"+
1013
+
" string foo = 1;\n"+
1014
+
" string bar = 2 [json_name=\"foo\"];\n"+
1015
+
"}\n",
1016
+
},
1017
+
"foo.proto:4:3: field Foo.bar: custom JSON name \"foo\" conflicts with default JSON name of field foo, defined at foo.proto:3:3",
1018
+
},
1019
+
{
1020
+
map[string]string{
1021
+
"foo.proto": "syntax = \"proto3\";\n"+
1022
+
"message Foo {\n"+
1023
+
" string foo = 1 [json_name=\"foo_bar\"];\n"+
1024
+
" string bar = 2 [json_name=\"Foo_Bar\"];\n"+
1025
+
"}\n",
1026
+
},
1027
+
"foo.proto:4:3: field Foo.bar: custom JSON name \"Foo_Bar\" conflicts with custom JSON name \"foo_bar\" of field foo, defined at foo.proto:3:3",
1028
+
},
1029
+
{
1030
+
map[string]string{
1031
+
"foo.proto": "syntax = \"proto3\";\n"+
1032
+
"message Foo {\n"+
1033
+
" string fooBar = 1;\n"+
1034
+
" string foo_bar = 2;\n"+
1035
+
"}\n",
1036
+
},
1037
+
"foo.proto:4:3: field Foo.foo_bar: default JSON name \"fooBar\" conflicts with default JSON name of field fooBar, defined at foo.proto:3:3",
1038
+
},
1039
+
{
1040
+
map[string]string{
1041
+
"foo.proto": "syntax = \"proto3\";\n"+
1042
+
"message Foo {\n"+
1043
+
" string fooBar = 1;\n"+
1044
+
" string foo_bar = 2 [json_name=\"fuber\"];\n"+
1045
+
"}\n",
1046
+
},
1047
+
"foo.proto:4:3: field Foo.foo_bar: default JSON name \"fooBar\" conflicts with default JSON name of field fooBar, defined at foo.proto:3:3",
1048
+
}, {
1049
+
map[string]string{
1050
+
"foo.proto": "syntax = \"proto3\";\n"+
1051
+
"message Foo {\n"+
1052
+
" string fooBar = 1;\n"+
1053
+
" string FOO_BAR = 2;\n"+
1054
+
"}\n",
1055
+
},
1056
+
"foo.proto:4:3: field Foo.FOO_BAR: default JSON name \"FOOBAR\" conflicts with default JSON name \"fooBar\" of field fooBar, defined at foo.proto:3:3",
1057
+
},
1058
+
{
1059
+
map[string]string{
1060
+
"foo.proto": "syntax = \"proto3\";\n"+
1061
+
"message Foo {\n"+
1062
+
" string fooBar = 1;\n"+
1063
+
" string __foo_bar = 2;\n"+
1064
+
"}\n",
1065
+
},
1066
+
"foo.proto:4:3: field Foo.__foo_bar: default JSON name \"FooBar\" conflicts with default JSON name \"fooBar\" of field fooBar, defined at foo.proto:3:3",
" optional string bar = 2 [json_name=\"foo\"];\n"+
1303
+
"}\n",
1304
+
warning: "test.proto:4:3: field Foo.bar: custom JSON name \"foo\" conflicts with default JSON name of field foo, defined at test.proto:3:3",
1305
+
},
1306
+
{
1307
+
source: "syntax = \"proto2\";\n"+
1308
+
"message Foo {\n"+
1309
+
" optional string foo_bar = 1;\n"+
1310
+
" optional string fooBar = 2;\n"+
1311
+
"}\n",
1312
+
warning: "test.proto:4:3: field Foo.fooBar: default JSON name \"fooBar\" conflicts with default JSON name of field foo_bar, defined at test.proto:3:3",
1313
+
},
1314
+
{
1315
+
source: "syntax = \"proto2\";\n"+
1316
+
"message Foo {\n"+
1317
+
" optional string foo_bar = 1;\n"+
1318
+
" optional string fooBar = 2;\n"+
1319
+
"}\n",
1320
+
warning: "test.proto:4:3: field Foo.fooBar: default JSON name \"fooBar\" conflicts with default JSON name of field foo_bar, defined at test.proto:3:3",
0 commit comments