Commit Graph

1167 Commits

Author SHA1 Message Date
Michael Stapelberg
8878926ea7 internal/impl: fix WhichOneof() to work with synthetic oneofs
This is the equivalent of CL 638495, but for the Opaque API.

While the behavior is the same for non-synthetic oneofs between
the Open Struct API and Opaque API, the behavior for synthetic oneofs
is not the same: Because the Opaque API uses a bitfield to store
presence, we need to use the Opaque presence check in WhichOneof().

This CL extends the testproto generator to use the protoc
command-line flag for the test3 testproto (which specifies
syntax = "proto3";), as the in-file api_level is only available
in .proto files using editions (but editions does not use synthetic
oneofs for optional fields, only proto3 does).

For golang/protobuf#1659

Change-Id: I0a1fd6e5fc6f96eeab043f966728ce2a14dbd446
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/638515
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Chressie Himpel <chressie@google.com>
2024-12-23 05:33:29 -08:00
Michael Stapelberg
c0c814fc1b all: start v1.36.1-devel
Change-Id: I7c57fd7034f1a55e25fb0e5654c0e9fcde14d4c4
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/637938
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Chressie Himpel <chressie@google.com>
2024-12-23 04:48:38 -08:00
Michael Stapelberg
7fc5ff4e14 all: release v1.36.1
Change-Id: I551d270a4c0010bcdc87056715a1c38271ca2f5c
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/637937
Reviewed-by: Chressie Himpel <chressie@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-12-23 04:47:17 -08:00
Michael Stapelberg
575aebf635 internal/impl: revert IsSynthetic() check to fix panic
This reverts change https://go.dev/cl/632735, in which
I misunderstood what the Protobuf documentation wanted to convey:
The quoted docs in CL 632735 refer to reflection for proto3 optional
fields, not to reflection for proto3 synthetic oneofs.

Synthetic oneofs should remain visible through reflection.
For the Open API, this change restores the old behavior.
For the Opaque API, another fix is needed and will be sent
in a separate, follow-up CL (follow golang/protobuf#1659).

For golang/protobuf#1659

Thanks to Joshua Humphries for the report and reproducer!

Change-Id: I3a924eed6d2425581adc65651395a68fc1576f4d
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/638495
Reviewed-by: Chressie Himpel <chressie@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-12-23 04:34:27 -08:00
Michael Stapelberg
ce4fa196c4 internal/errors: delete compatibility code for Go before 1.13
Currently, Go Protobuf requires Go 1.21.

Change-Id: I0b923f4f7732d54628f84e93adccc12f74f14e8e
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/637475
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Chressie Himpel <chressie@google.com>
Auto-Submit: Michael Stapelberg <stapelberg@google.com>
2024-12-18 08:09:14 -08:00
Michael Stapelberg
607da3e581 all: start v1.36.0-devel
Change-Id: Id47a99eafd700576f84f31f5f1b585c7aef8b0b4
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/636676
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Chressie Himpel <chressie@google.com>
2024-12-16 08:48:44 -08:00
Michael Stapelberg
3b78ca86bd all: release v1.36.0
Change-Id: Ic27ded92dbbe7fad73c04e5dcc4ab16ab1fe40fd
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/636675
Reviewed-by: Chressie Himpel <chressie@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-12-16 08:46:32 -08:00
Michael Stapelberg
4cf3399ed2 src/google/protobuf: document UnmarshalJSON / API level behavior
For golang/protobuf#1657

Change-Id: Icdf7254bced1c0987ff2e969fd096d6eef3918f7
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/635139
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Cassondra Foesch <cfoesch@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-12-16 00:38:13 -08:00
Michael Stapelberg
8edf9401bb reflect/protoreflect: use [] syntax to reference method
While godoc does not render comments within interface definitions,
using the [] syntax regardless helps with the replacement rules
we use to import Go Protobuf back into Google.

Change-Id: I0287ec3df5ba74261f563ce1117ab1e1be1fc270
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/635138
Reviewed-by: Cassondra Foesch <cfoesch@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
2024-12-16 00:38:05 -08:00
Michael Stapelberg
5376513e4b proto: add reference to size semantics with lazy decoding to comment
For golang/protobuf#1657

Change-Id: I01007ed586d1833517735cf5f38cca302efb9801
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/635137
Reviewed-by: Cassondra Foesch <cfoesch@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
2024-12-16 00:37:46 -08:00
Michael Stapelberg
560503ec5d compiler/protogen: allow overriding API level from --go_opt
For golang/protobuf#1657

In order to change the default API level, one can now specify:

    protoc […] --go_opt=default_api_level=API_HYBRID

To override the default API level for a specific file, use
the apilevelM mapping flag (similar to the M flag for import paths):

    protoc […] --go_opt=apilevelMhello.proto=API_HYBRID

(Similar to the M option.)

Change-Id: I44590e9aa4c034a5bb9c93ae32f4b11188e684a0
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/634818
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
2024-12-11 03:23:13 -08:00
Michael Stapelberg
b64efdbc6e cmd/protoc-gen-go: generate _protoopaque variant for hybrid
For golang/protobuf#1657

Change-Id: I3c35fceeddedcd159a5adacec3113e12497ebd27
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/634817
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-12-11 03:23:02 -08:00
Michael Stapelberg
9eda3d5059 all: regenerate.bash for Opaque API
For golang/protobuf#1657

Change-Id: I8081e04050a38b0cb1b48ad674b683de61d36770
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/634816
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
2024-12-11 03:17:04 -08:00
Michael Stapelberg
eb7b468655 all: Release the Opaque API
For golang/protobuf#1657

Change-Id: I7b2b0c30506706015ce278e6054439c9ad9ef727
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/634815
TryBot-Bypass: Michael Stapelberg <stapelberg@google.com>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Damien Neil <dneil@google.com>
2024-12-11 03:16:51 -08:00
Josh Humphries
5f5de338ee types/descriptorpb: regenerate using latest protobuf v29.1 release
This updates all generated code to match the contents of the latest
v29.1 release of Protobuf. The main significant change is that
SourceCodeInfo is now extendable (though in a very limited way).

This release of Protobuf includes new conformance tests that do not
pass with the latest version of this protobuf-go module. These have
been added to the list of known-failing tests. However all of them
are marked "required" in the conformance suite so should be likely
be addressed as soon as possible. (This change makes no attempt to
fix any of them.)

Change-Id: Ib554d393d7742b7a616af998eeab84a080a85e0e
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/634015
Reviewed-by: Chressie Himpel <chressie@google.com>
Reviewed-by: Michael Stapelberg <stapelberg@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-12-06 14:51:30 +00:00
Michael Stapelberg
bdcc7adc94 internal/impl: skip synthetic oneofs in messageInfo
Calling WhichOneof should not be possible for synthetic oneofs;
on the reflection level, these fields should work as if they
were regular fields, not as if they were oneofs:

> Reflection for proto3 optional fields should work properly. For example, a
> method like Reflection::HasField() should know to look for the hasbit for a
> proto3 optional field. It should not be fooled by the synthetic oneof into
> thinking that there is a case member for the oneof.

From the Protobuf docs at:
https://github.com/protocolbuffers/protobuf/blob/main/docs/implementing_proto3_presence.md#updating-reflection

This change was tested Google-internally as CL 701866153.

Change-Id: Id9500d4aa492acf4ebc6d2d84be07ed81201d2aa
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/632735
Reviewed-by: Chressie Himpel <chressie@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-12-02 08:52:41 +00:00
Chressie Himpel
30f628eeb3 all: start v1.35.2-devel
Change-Id: I81e537e46e952d593ebd99dd80dad723a064477e
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/627876
Auto-Submit: Michael Stapelberg <stapelberg@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Stapelberg <stapelberg@google.com>
2024-11-14 09:41:35 +00:00
Chressie Himpel
c72053a906 all: release v1.35.2
Change-Id: I3e159766c6776efc92e93fca6d7b247d1bd3ece0
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/627875
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Stapelberg <stapelberg@google.com>
Auto-Submit: Michael Stapelberg <stapelberg@google.com>
2024-11-14 09:28:32 +00:00
Michael Stapelberg
b98563540c internal/impl: fix TestMarshalMessageSetLazyRace (was a no-op!)
This test was accidentally migrated from proto.GetExtension to
proto.HasExtension in a semi-automated change and nobody noticed.

proto.HasExtension does not actually trigger lazy extension decoding.
I verified this using the dlv debugger:

% go test -tags protolegacy -c -gcflags "all=-N -l"
% dlv exec ./impl.test
Type 'help' for list of commands.
(dlv) r -test.run=TestMarshalMessageSetLazyRace -test.v
Process restarted with PID 3586699
(dlv) b TestMarshalMessageSetLazyRace
Breakpoint 1 set at 0xac9bf6 for google.golang.org/protobuf/internal/impl_test.TestMarshalMessageSetLazyRace() ./lazy_test.go:500
(dlv) c
=== RUN   TestMarshalMessageSetLazyRace
> [Breakpoint 1] google.golang.org/protobuf/internal/impl_test.TestMarshalMessageSetLazyRace() ./lazy_test.go:500 (hits goroutine(32):1 total:1) (PC: 0xac9bf6)
=> 500:	func TestMarshalMessageSetLazyRace(t *testing.T) {
(dlv) b ExtensionField.lazyInit
Breakpoint 2 set at 0x8da076 for google.golang.org/protobuf/internal/impl.(*ExtensionField).lazyInit() ./codec_extension.go:123
(dlv) c
--- PASS: TestMarshalMessageSetLazyRace (4.07s)
PASS
Process 3586699 has exited with status 0
(dlv) exit

Note how breakpoint 2 is unexpectedly not hit!

Here is how the output changes with my fix:

% go test -tags protolegacy -c -gcflags "all=-N -l"
% dlv --check-go-version=false exec ./impl.test
Type 'help' for list of commands.
(dlv) r -test.run=TestMarshalMessageSetLazyRace -test.v
Process restarted with PID 3587344
(dlv) b TestMarshalMessageSetLazyRace
Breakpoint 1 set at 0xac9bf6 for google.golang.org/protobuf/internal/impl_test.TestMarshalMessageSetLazyRace() ./lazy_test.go:500
(dlv) c
=== RUN   TestMarshalMessageSetLazyRace
> [Breakpoint 1] google.golang.org/protobuf/internal/impl_test.TestMarshalMessageSetLazyRace() ./lazy_test.go:500 (hits goroutine(28):1 total:1) (PC: 0xac9bf6)
=> 500:	func TestMarshalMessageSetLazyRace(t *testing.T) {
(dlv) b ExtensionField.lazyInit
Breakpoint 2 set at 0x8da076 for google.golang.org/protobuf/internal/impl.(*ExtensionField).lazyInit() ./codec_extension.go:123
(dlv) c
> [Breakpoint 2] google.golang.org/protobuf/internal/impl.(*ExtensionField).lazyInit() ./codec_extension.go:123 (hits goroutine(68):1 total:4) (PC: 0x8da076)
> [Breakpoint 2] google.golang.org/protobuf/internal/impl.(*ExtensionField).lazyInit() ./codec_extension.go:123 (hits goroutine(70):1 total:4) (PC: 0x8da076)
> [Breakpoint 2] google.golang.org/protobuf/internal/impl.(*ExtensionField).lazyInit() ./codec_extension.go:123 (hits goroutine(58):1 total:4) (PC: 0x8da076)
> [Breakpoint 2] google.golang.org/protobuf/internal/impl.(*ExtensionField).lazyInit() ./codec_extension.go:123 (hits goroutine(54):1 total:4) (PC: 0x8da076)
=> 123:	func (f *ExtensionField) lazyInit() {
(dlv) bt
0  0x00000000008da076 in google.golang.org/protobuf/internal/impl.(*ExtensionField).lazyInit
   at ./codec_extension.go:123
1  0x00000000008dac3e in google.golang.org/protobuf/internal/impl.(*ExtensionField).Value
   at ./codec_extension.go:180
2  0x000000000094e5d9 in google.golang.org/protobuf/internal/impl.(*extensionMap).Get
   at ./message_reflect.go:276
3  0x000000000095a2ee in google.golang.org/protobuf/internal/impl.(*messageState).Get
   at ./message_reflect_gen.go:90
4  0x0000000000890099 in google.golang.org/protobuf/proto.GetExtension
   at /usr/local/google/home/stapelberg/protobuf/proto/extension.go:90
5  0x0000000000aca7d4 in google.golang.org/protobuf/internal/impl_test.TestMarshalMessageSetLazyRace.func2.1
   at ./lazy_test.go:545
6  0x0000000000aca625 in google.golang.org/protobuf/internal/impl_test.TestMarshalMessageSetLazyRace.func2
   at ./lazy_test.go:550
7  0x00000000006001c1 in runtime.goexit
   at /usr/lib/google-golang/src/runtime/asm_amd64.s:1700

Change-Id: Ie7a8621064af412a1db7efb3ad6b8473f9db58e8
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/624416
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Chressie Himpel <chressie@google.com>
2024-11-04 08:59:09 +00:00
Michael Stapelberg
76135f99d5 proto: switch messageset_test to use makeMessages() injection point
This required renaming the extension fields to have distinct names, as
makeMessages() uses the protobuild package, which works with field names.

The makeMessages() function can be centrally extended with other variants of
testprotos (e.g. editions).

Change-Id: I68ef28baee674c6b53da8629c5ff7b2e1b92d4ff
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/624415
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Chressie Himpel <chressie@google.com>
2024-11-04 08:58:59 +00:00
Michael Stapelberg
29947bbd16 internal/testprotos/test: add nested message field with [lazy=true]
This will be useful for a few different upcoming tests,
to be submitted in a follow-up CL.

Change-Id: I1fde9f4567b149141737a74c8448c2ee14946ae4
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/623117
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Chressie Himpel <chressie@google.com>
2024-10-30 12:39:37 +00:00
Michael Stapelberg
5c14d72191 encoding/prototext: use testmessages_test.go approach, too
With this change, we establish a similar mechanism in encoding/prototext as
already exists in the proto package: a testmessages_test.go which serves as an
extension point where one can inject more variants into the corpus of test
messages.

Change-Id: I9f83735a44e5fd2e4736f888aaca428e4cc8ed42
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/623116
Reviewed-by: Chressie Himpel <chressie@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-10-29 14:35:35 +00:00
Michael Stapelberg
496557b1d5 proto: refactor equal_test from explicit table to use makeMessages()
This is important for test coverage: the makeMessages() function is where we
declare the various different test message types. Using this central function is
better than explicitly having to spell out all the various cases in the test
table.

This CL is roughly neutral in terms of lines changed, but actually increases
coverage: in the existing table, not every group of tests had coverage for all
cases (proto2, proto3, editions). This was difficult to spot previously, but now
the different test message types are now clearly spelled out (allTypesNoProto3).

Also, the test now prints the description and message types as subtest name.
This makes it easy to verify coverage by just reading the test output.

Change-Id: I08f541548d087233cbb4686785c456674371c2a3
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/623115
Reviewed-by: Chressie Himpel <chressie@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-10-29 12:41:43 +00:00
Michael Stapelberg
0517e5afc7 testing/protocmp: document behavior when combining Ignore and Sort
fixes golang/protobuf#1652

Change-Id: I19af3714ec9fd9e54446bb0c3bd6815d90f11e10
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/622575
Reviewed-by: Christian Höppner <hoeppi@google.com>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Stapelberg <stapelberg@google.com>
2024-10-28 09:07:43 +00:00
Michael Stapelberg
d14ebce888 all: implement strip_enum_prefix editions feature
This change required updating editions_defaults.binpb with
--edition_defaults_maximum=2024 so that we can use edition 2024 in our
testdata/enumprefix.proto test file.

For end users, this feature will only be available once:
1. protoc declares support for edition 2024 (expected early 2025).
2. protoc-gen-go declares support for edition 2024.

related to golang/protobuf#513

Change-Id: Ib8daeecae39ef32eff942279707d256c312f2a53
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/618979
Reviewed-by: Lasse Folger <lassefolger@google.com>
Reviewed-by: Mike Kruskal <mkruskal@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
2024-10-23 09:04:58 +00:00
justinsb
fb995f184a encoding/protojson: allow missing value for Any of type Empty
Some other implementations do not send the value field when encoding
an Any representing a message of the Empty Well-Known-Type.

Fixes golang/protobuf#1620

Change-Id: I89bffd5f92656ba3ac462c0b6365ed4b49e6189d
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/618395
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Stapelberg <stapelberg@google.com>
2024-10-09 07:32:47 +00:00
Michael Stapelberg
d34023800d all: start v1.35.1-devel
Change-Id: I67979ea166a3fffba8c303fa1cc47f9eacb606b4
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/618198
Reviewed-by: Lasse Folger <lassefolger@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-10-07 12:53:17 +00:00
Michael Stapelberg
158d2b331a all: release v1.35.1
Change-Id: Ia6b809a10e6d4f59a87b88268952347b5e24f573
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/618197
Reviewed-by: Lasse Folger <lassefolger@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-10-07 12:51:58 +00:00
Michael Stapelberg
94e26c9ca9 all: start v1.35.0-devel
Change-Id: I094b4192fa383ae40f0d3f11050a570fda07fc15
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/618196
Reviewed-by: Lasse Folger <lassefolger@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-10-07 12:36:36 +00:00
Michael Stapelberg
ac9817722e all: release v1.35.0
Change-Id: Ic0597f57619ea1e1e0d9dc85f08f26fa7b2c3389
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/618195
Reviewed-by: Lasse Folger <lassefolger@google.com>
Reviewed-by: Nicolas Hillegeer <aktau@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-10-07 12:36:27 +00:00
Reno Reckling
03df6c145d proto: Implement proto.Equal fast-path
Also adds better benchmark cases for large message where some fields are
actually populated.

This change was previously done in Google internal cl/660848520.

Change-Id: I682aae0c9c2850bfe7638de29ab743ad7d7b119a
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/609035
Reviewed-by: Christian Höppner <hoeppi@google.com>
Reviewed-by: Cassondra Foesch <cfoesch@gmail.com>
Reviewed-by: Michael Stapelberg <stapelberg@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-09-06 16:39:44 +00:00
Michael Stapelberg
013dd178dc all: drop unnecessary import renames for consistency
Most of our imports already comply with the style, but this change makes it
consistent across the entire repository.

I suspect that these unnecessary imports are left-overs from differences between
Google-internal (where many imports are renamed) and Open Source.

Change-Id: Id5f6eabd22bcc72dd4e36dd018b6cc5138df7696
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/609875
Reviewed-by: Christian Höppner <hoeppi@google.com>
Auto-Submit: Michael Stapelberg <stapelberg@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-08-30 09:35:51 +00:00
Michael Stapelberg
1531843d1d internal/testprotos: declare the extension
This change was originally done by Mike Kruskal in Google-internal cl/520045664.

(Undeclared extensions are no longer accepted Google-internally.)

Change-Id: I24d24ff2c7dc85920bd5dbe86724186d98783a18
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/609555
Reviewed-by: Christian Höppner <hoeppi@google.com>
Auto-Submit: Michael Stapelberg <stapelberg@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-08-29 12:27:53 +00:00
Michael Stapelberg
9e047b83e6 internal/impl: skip unnecessary requiredField checks for oneofs
This change was originally done by Patrik Nyblom in Google-internal cl/308876443

(The corresponding test is TestDecodeFastCheckInitialized in methods_test.go.)

Change-Id: I312dff53db4d6f87decf152eb20ec4dd280f03c3
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/608256
Reviewed-by: Christian Höppner <hoeppi@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-08-28 08:50:43 +00:00
Michael Stapelberg
ed7b51feef proto: extend documentation of GetExtension, SetExtension
Document the type mapping and the recommended pattern for working with
extensions. This documentation was Google-internal (cl/335451491), presumably
because of the reference to static analysis tools that don’t exist outside.

Compared to the internal version, this CL uses “should” instead of “must”.

Change-Id: I9293c10b2f6f91c9546d145c94b52e84f3a7a9c9
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/607995
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Christian Höppner <hoeppi@google.com>
2024-08-27 10:59:06 +00:00
Michael Stapelberg
af06170887 all: set Go language version to Go 1.21
Go 1.23 was released a few weeks ago.

Change-Id: Ied9daddbe57b5f57993a31fd09fe1c8c47a42878
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/608316
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Stapelberg <stapelberg@google.com>
Reviewed-by: Christian Höppner <hoeppi@google.com>
2024-08-27 10:05:27 +00:00
Michael Stapelberg
cf4f382b27 encoding/prototext: capture current reserved field behavior
This change was originally done in Google-internal cl/512993970.

Change-Id: I66ea95cd975b160892ed9f931312f1767cbc9fc9
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/608315
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Stapelberg <stapelberg@google.com>
Reviewed-by: Christian Höppner <hoeppi@google.com>
2024-08-27 06:11:03 +00:00
Michael Stapelberg
5c1f700acc internal/encoding/json: remove duplicate test
This test was accidentally duplicated in CL 569356.

Change-Id: I0e2f81fbebe9b4c37bf6d28615e0bf51d28cfc4c
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/607777
Auto-Submit: Michael Stapelberg <stapelberg@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Christian Höppner <hoeppi@google.com>
2024-08-23 08:40:28 +00:00
Michael Stapelberg
66faac0c99 compiler/protogen: remove now-unnecessary UnsafeEnabled checks
This should have been part of CL 606755.

related to golang/protobuf#1640

Change-Id: Iae1bfb9e3bd440f879047d3a78e1bba364d7568c
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/607775
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Christian Höppner <hoeppi@google.com>
2024-08-23 08:11:43 +00:00
Michael Stapelberg
21d187aa53 compiler/protogen: support -experimental_strip_nonfunctional_codegen
This flag is used by the (Google-internal) editions codegen test.
Having the functionality in the open source repository reduces
our maintenance burden (fewer/smaller patches).

Change-Id: Idb9c95e9b2cb8922584bcb7ca13a8ddef4347af0
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/606735
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Lasse Folger <lassefolger@google.com>
2024-08-21 11:56:14 +00:00
Michael Stapelberg
e8b68559c4 internal/descopts,internal/impl: remove shorthand import aliases
Commit 784c482554 apparently missed a spot.

Change-Id: Id4e68569e83cc1429532f8178dfdd8b9872570d9
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/606995
Reviewed-by: Lasse Folger <lassefolger@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-08-20 12:08:45 +00:00
Michael Stapelberg
0946f97cdf all: remove unused purego support
fixes golang/protobuf#1640

Change-Id: I0e8f2df27c6b86a6f7325524d788c852a9266f1f
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/606755
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Lasse Folger <lassefolger@google.com>
Reviewed-by: Christian Höppner <hoeppi@google.com>
2024-08-20 08:15:14 +00:00
Michael Stapelberg
b643888146 encoding/protojson: use fd.HasPresence() for editions compatibility
This change was originally done by Mike Kruskal in Google-internal cl/515091827.

Change-Id: I5d1588193663249964cf8bc9b9fe9f61d29c98a6
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/606756
Reviewed-by: Christian Höppner <hoeppi@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-08-20 08:10:26 +00:00
Michael Stapelberg
94ecbc2616 internal/impl: remove unused ExtensionField.SetLazy method
This cleanup was done in June 2020 by Dan Scales,
but never upstreamed to the open source Go Protobuf repository.

Change-Id: I175d9588b5bb536fa276133f8fe6073278e6d3b0
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/605895
Reviewed-by: Christian Höppner <hoeppi@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-08-16 07:37:51 +00:00
luoyy
b36f8e04bd types/known/structpb: add support for more types and json.Number
Add support for additional primitive types such as int8, int16, uint8, uint16,
and the json.Number type in the conversion logic of the NewValue function.

This change ensures that the generated code can handle a wider range of Go types
when converting them to protobuf Value types, improving compatibility with JSON
data formats.

fixes golang/protobuf#1463

Change-Id: I6ea7b8f644f6c3dbe5e6c17e744be40c56846328
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/601775
Reviewed-by: Michael Stapelberg <stapelberg@google.com>
Reviewed-by: Lasse Folger <lassefolger@google.com>
Reviewed-by: Funda Secgin <fundasecgin32@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-08-07 16:51:14 +00:00
Michael Stapelberg
75479a36c9 internal: generate extension numbers, fix editions parsing
Before this commit, message-level Go editions features were not parsed
correctly.

Change-Id: I94ead5428fadae5fd70ed991fa405ce9388e9660
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/603015
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Stapelberg <stapelberg@google.com>
Reviewed-by: Lasse Folger <lassefolger@google.com>
2024-08-06 11:55:50 +00:00
Michael Stapelberg
2a82025330 internal/cmd/generate-protos: fix pkg check for editions features
go_features.proto apparently lived in package google.protobuf,
but was later moved to package pb, without updating generate-protos.

This change fixes the oversight and re-generates go_features_gen.go.

Change-Id: I6fd68fdb7b146f32dd610c0bad6ecf5ec940ae78
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/602055
Reviewed-by: Lasse Folger <lassefolger@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-07-31 13:29:53 +00:00
Michael Stapelberg
219bda23ff internal/conformance: update failing tests list, add comments
Change-Id: Iafac20dc4e29e635e05cfcab11c7a06178b99174
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/600395
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Christian Höppner <hoeppi@google.com>
2024-07-23 08:39:09 +00:00
Michael Stapelberg
b46f280f97 all: plumb the lazy option into filedesc.Field and .Extension
The IsLazy() method is intentionally not added to the
protoreflect.FieldDescriptor interface because users should not need it.
The Go Protobuf runtime will use type assertion to dynamically call the method.

There is no change in behavior, this is preparation only.

Change-Id: I4500c17f5edd1bdc40447eb89bff115b4e8eab06
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/596539
Reviewed-by: Chressie Himpel <chressie@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-07-08 07:49:25 +00:00
Lasse Folger
df3bd63b9c compiler/protogen: always report editions support level of the plugin
Change-Id: I11bb6c37ac9b15e2dfb11c38c4a68900dd63d327
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/597055
Auto-Submit: Lasse Folger <lassefolger@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Chressie Himpel <chressie@google.com>
2024-07-08 07:19:32 +00:00