-
Notifications
You must be signed in to change notification settings - Fork 421
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gofeatures: allow setting legacy_unmarshal_json_enum feature at file …
…level All of the other features, including custom features for C++ and Java, allow setting a file-wide default. This makes it easier to migrate proto2 files, so that the feature can be set at the file level instead of needing to manually annotate each enum element. This adds the same convenience to the (pb.go).legacy_unmarshal_json_enum feature that is defined in this repo. Change-Id: If3a925674a9daeed464b589747b7f78a0200118b Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/589336 Auto-Submit: Lasse Folger <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Lasse Folger <[email protected]> Reviewed-by: Michael Stapelberg <[email protected]>
- Loading branch information
Showing
4 changed files
with
379 additions
and
20 deletions.
There are no files selected for viewing
320 changes: 320 additions & 0 deletions
320
cmd/protoc-gen-go/testdata/protoeditions/legacy_enum.pb.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
38 changes: 38 additions & 0 deletions
38
cmd/protoc-gen-go/testdata/protoeditions/legacy_enum.proto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright 2024 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
edition = "2023"; | ||
|
||
package goproto.protoc.protoeditions; | ||
|
||
import "google/protobuf/go_features.proto"; | ||
|
||
option go_package = "google.golang.org/protobuf/cmd/protoc-gen-go/testdata/protoeditions"; | ||
option features.(pb.go).legacy_unmarshal_json_enum = true; | ||
|
||
// EnumTypeWithLegacyUnmarshalJSON comment. | ||
enum EnumTypeWithLegacyUnmarshalJSON { | ||
option features.enum_type = CLOSED; | ||
|
||
// EnumTypeWithLegacyUnmarshalJSON_ONE comment. | ||
FIRST = 1; | ||
// EnumTypeWithLegacyUnmarshalJSON_TWO comment. | ||
SECOND = 2; | ||
} | ||
|
||
message ContainerForNestedEnum { | ||
// NestedEnumType1A comment. | ||
enum NestedEnum { | ||
// NestedEnum_VALUE comment. | ||
VALUE = 0; | ||
} | ||
} | ||
|
||
enum EnumWithoutUnmarshalJSON { | ||
option features.(pb.go).legacy_unmarshal_json_enum = false; | ||
|
||
WITHOUT_UNMARSHAL_JSON_FOO = 0; | ||
WITHOUT_UNMARSHAL_JSON_BAR = 1; | ||
WITHOUT_UNMARSHAL_JSON_BAZ = 2; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.