Skip to content

Commit f04cadb

Browse files
authored
Merge pull request #110 from Logofile/sync
This update includes the following:
2 parents 2ffd719 + 57fee05 commit f04cadb

File tree

12 files changed

+245
-21
lines changed

12 files changed

+245
-21
lines changed

content/editions/features.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -507,8 +507,8 @@ option features.enum_type = CLOSED;
507507
option features.repeated_field_encoding = EXPANDED;
508508
option features.json_format = LEGACY_BEST_EFFORT;
509509
option features.utf8_validation = NONE;
510-
option features.(pb.cpp).legacy_enum_closed = true;
511-
option features.(pb.java).legacy_enum_closed = true;
510+
option features.(pb.cpp).legacy_closed_enum = true;
511+
option features.(pb.java).legacy_closed_enum = true;
512512
```
513513

514514
### Proto3 Behavior {#proto3-behavior}
@@ -526,8 +526,8 @@ option features.enum_type = OPEN;
526526
// features in Editions syntax
527527
option features.json_format = ALLOW;
528528
option features.utf8_validation = VERIFY;
529-
option features.(pb.cpp).legacy_enum_closed = false;
530-
option features.(pb.java).legacy_enum_closed = false;
529+
option features.(pb.cpp).legacy_closed_enum = false;
530+
option features.(pb.java).legacy_closed_enum = false;
531531
```
532532

533533
### Caveats and Exceptions {#caveats}

content/editions/overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ as it applies the file-level setting. The `Employment` `enum`, though, will be
252252
### Prototiller {#prototiller}
253253

254254
We provide both a migration guide and migration tooling that ease the migration
255-
to editions. The tool, called Prototiller, will enable you to:
255+
to and between editions. The tool, called Prototiller, will enable you to:
256256

257257
* convert proto2 and proto3 definition files to the new editions syntax, at
258258
scale

content/getting-started/gotutorial.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,6 @@ message Person {
113113
int32 id = 2; // Unique ID number for this person.
114114
string email = 3;
115115
116-
enum PhoneType {
117-
PHONE_TYPE_UNSPECIFIED = 0;
118-
PHONE_TYPE_MOBILE = 1;
119-
PHONE_TYPE_HOME = 2;
120-
PHONE_TYPE_WORK = 3;
121-
}
122-
123116
message PhoneNumber {
124117
string number = 1;
125118
PhoneType type = 2;
@@ -130,6 +123,13 @@ message Person {
130123
google.protobuf.Timestamp last_updated = 5;
131124
}
132125
126+
enum PhoneType {
127+
PHONE_TYPE_UNSPECIFIED = 0;
128+
PHONE_TYPE_MOBILE = 1;
129+
PHONE_TYPE_HOME = 2;
130+
PHONE_TYPE_WORK = 3;
131+
}
132+
133133
// Our address book file is just one of these.
134134
message AddressBook {
135135
repeated Person people = 1;

content/news/2023-12-05.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
+++
2+
title = "Changes announced on December 5, 2023"
3+
linkTitle = "December 5, 2023"
4+
toc_hide = "true"
5+
description = "Changes announced for Protocol Buffers on December 5, 2023."
6+
type = "docs"
7+
+++
8+
9+
## Java Breaking Changes
10+
11+
In v26, we are planning a major version bump for Java per our
12+
[breaking changes policy](/news/2022-07-06) and
13+
[version support policy](/support/version-support#java).
14+
15+
The following sections outline the set of breaking changes that we plan to
16+
include in the 26.0 release of protocol buffers. Note that plans can and do
17+
change. These are potential breaking changes to be aware of, but they may not
18+
happen in this particular release, or they may not happen at all.
19+
20+
### Poison Pilling Gencode / Runtime Mismatches
21+
22+
Per our
23+
[Cross-Version Runtime Guarantees](/support/cross-version-runtime-guarantee),
24+
Protobuf does not support mixing generated code and runtimes across major
25+
version boundaries, or mixing generated code from a newer version of protoc with
26+
older runtimes within a single major runtime version. We plan to introduce
27+
“poison pills” to detect and enforce these disallowed mismatches.
28+
29+
This is not considered a breaking change since this simply adds enforcement of
30+
existing policies, but may require users to update their generated code.
31+
32+
### Breaking Compatibility with Old Generated Code
33+
34+
v26.x will break compatibility with generated code from older major versions.
35+
Users should regenerate old generated code to be from the same version.
36+
37+
For example, `GeneratedMessageV3`, which was originally introduced for backwards
38+
compatibility with generated code from v2.x.x against v3.x.x runtime, will be
39+
renamed to `GeneratedMessage`. Runtimes will be updated to support
40+
[Editions](/editions/overview/), which will not be
41+
compatible with old generated code.
42+
43+
This is in accordance with our existing
44+
[Cross-Version Runtime Guarantees](/support/cross-version-runtime-guarantee)
45+
and is a breaking change.
46+
47+
### Removing Deprecated Methods/Variables
48+
49+
v26.x will remove access to deprecated methods and variables. These will
50+
generally have already been marked `@Deprecated` in a previous release.
51+
52+
This will remove access to the following non-exhaustive list:
53+
54+
* Descriptor syntax APIs, which should be replaced with corresponding feature
55+
accessors (such as `FieldDescriptor.hasPresence()`,
56+
`EnumDescriptor.isClosed()`)
57+
58+
* TextFormat print methods, which should be replaced by corresponding
59+
`TextFormat.printer()` methods.
60+
61+
* PARSER variable, which should be replaced by the `parser()` method.
62+
63+
* Runtime methods for old v2.x.x gencode compatibility. This is no longer
64+
supported, as per our
65+
[Cross Version Runtime Guarantees](/support/cross-version-runtime-guarantee).
66+
67+
More details will be available in the corresponding release notes.

content/news/2023-12-13.md

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
+++
2+
title = "Changes announced on December 13, 2023"
3+
linkTitle = "December 13, 2023"
4+
toc_hide = "true"
5+
description = "Changes announced for Protocol Buffers on December 13, 2023."
6+
type = "docs"
7+
+++
8+
9+
## C++ Breaking Changes
10+
11+
In v26, we are planning a major version bump for C++ as per our
12+
[breaking changes policy](/news/2022-07-06) and
13+
[version support policy](/support/version-support#python-support).
14+
15+
The following sections outline the set of breaking changes that we plan to
16+
include in the 26.0 release of protocol buffers. Note that plans can and do
17+
change. These are potential breaking changes to be aware of, but they may not
18+
happen in this particular release, or they may not happen at all.
19+
20+
### Remove deprecated clear APIs on repeated fields
21+
22+
The following deprecated methods are removed:
23+
24+
* `RepeatedPtrField::ReleaseCleared()`
25+
* `RepeatedPtrField::ClearedCount()`
26+
* `RepeatedPtrField::AddCleared()`
27+
28+
### Remove C++ legacy syntax descriptor APIs
29+
30+
With the release of [editions](/editions), syntax is no
31+
longer supported for business logic. Instead, use the various feature helpers
32+
defined in
33+
[`descriptor.h`](/reference/cpp/api-docs/google.protobuf.descriptor)
34+
to query more targeted behaviors, such as
35+
[`has_presence`](/reference/cpp/api-docs/google.protobuf.descriptor#FieldDescriptor.has_presence.details),
36+
to query features in C++.
37+
38+
### Remove deprecated syntax accessor
39+
40+
We plan to remove the deprecated syntax accessor, `FileDescriptor::Syntax`, in
41+
v26. We recommend using the getters from `FileDescriptor::edition` instead.
42+
43+
### Remove deprecated SupportsUnknownEnumValues method
44+
45+
The `SupportsUnknownEnumValues` method was
46+
[deprecated in March, 2023](https://github.com/protocolbuffers/protobuf/pull/12129).
47+
We plan to remove it in v26.
48+
49+
### Remove std::string error collector overrides
50+
51+
We are planning to remove the deprecated `std::string` methods in error
52+
collectors.
53+
54+
## Python Breaking Changes
55+
56+
In v26, we are planning a major version bump for Python as per our
57+
[breaking changes policy](/news/2022-07-06) and
58+
[version support policy](/support/version-support#python-support).
59+
60+
### Timestamps are checked for validity
61+
62+
In v26, the system will check if `Timestamp` values are valid. Seconds must be
63+
in the range [-62135596800, 253402300799] and nanos must be in range [0,
64+
999999999]. Values outside those ranges will raise an exception.
65+
66+
### Remove deprecated syntax accessor
67+
68+
We plan to remove the deprecated syntax accessor, `FileDescriptor.syntax`, in
69+
v26. We plan to add `FileDescriptor.edition` in its place.
70+
71+
### UnknownFields support removal
72+
73+
In v25
74+
[`message.UnknownFields()`](https://googleapis.dev/python/protobuf/latest/google/protobuf/message.html#google.protobuf.message.Message.UnknownFields)
75+
was deprecated in pure Python and C++ extensions. We plan to remove it v26. Use
76+
the new
77+
[`UnknownFieldSet(message)`](https://googleapis.dev/python/protobuf/latest/google/protobuf/unknown_fields.html)
78+
support in `unknown_fields.py` as a replacement.
79+
80+
More details about all of these changes will be available in the corresponding
81+
release notes.

content/news/_index.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ no_list = "true"
99
News topics provide information about past events and changes with Protocol
1010
Buffers, and plans for upcoming changes.
1111

12+
* [December 13, 2023](/news/2023-12-13) - Breaking
13+
Python and C++ changes in the 26.x line
14+
* [December 5, 2023](/news/2023-12-05) - Breaking Java
15+
changes in the 26.x line
1216
* [October 10, 2023](/news/2023-10-10) - Documentation
1317
for Protobuf Editions features is published
1418
* [September 15, 2023](/news/2023-09-15) - μpb Moving

content/programming-guides/dos-donts.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ and whether someone will be forced to fill in your required field with an empty
6060
string or zero in four years when it’s no longer logically required but the
6161
proto still says it is.
6262

63+
For proto3 there are no `required` fields, so this advice does not apply.
64+
6365
<a id="dont-make-a-message-with-lots-of-fields"></a>
6466

6567
## **Don't** Make a Message with Lots of Fields {#lots-of-fields}

content/programming-guides/field_presence.md

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ the serialization contains no information about not-present values.
3737
The generated API for a proto message includes (de)serialization definitions
3838
which translate between API types and a stream of definitionally *present* (tag,
3939
value) pairs. This translation is designed to be forward- and
40-
backward-compatibile across changes to the message definition; however, this
40+
backward-compatible across changes to the message definition; however, this
4141
compatibility introduces some (perhaps surprising) considerations when
4242
deserializing wire-formatted messages:
4343

@@ -566,7 +566,7 @@ if (m.hasFoo()) {
566566
}
567567
```
568568

569-
#### Objective C Example
569+
#### Objective-C Example
570570

571571
No presence:
572572

@@ -593,3 +593,38 @@ if (m.hasFoo()) {
593593
[m setFoo:1];
594594
}
595595
```
596+
597+
## Cheat sheet {#cheat}
598+
599+
**Proto2:**
600+
601+
Is field presence tracked?
602+
603+
Field type | Tracked?
604+
---------------------- | --------
605+
Singular field | yes
606+
Singular message field | yes
607+
Field in a oneof | yes
608+
Repeated field & map | no
609+
610+
**Proto3:**
611+
612+
Is field presence tracked?
613+
614+
Field type | Tracked?
615+
---------------------- | ------------------------
616+
Singular message field | yes
617+
Field in a oneof | yes
618+
*Other* singular field | if defined as `optional`
619+
Repeated field & map | no
620+
621+
**Edition 2023:**
622+
623+
Is field presence tracked?
624+
625+
Field type | Tracked?
626+
-------------------------------------------------- | --------
627+
Default | yes
628+
`features.field_presence` set to `LEGACY_REQUIRED` | yes
629+
`features.field_presence` set to `IMPLICIT` | no
630+
Repeated field & map | no

content/programming-guides/proto2.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,19 @@ different languages, see
620620
[Enum Behavior](/programming-guides/enum).
621621
{{% /alert %}}
622622

623+
Removing enum values is a breaking change for persisted protos. Instead of
624+
removing a value, mark the value with the `reserved` keyword to prevent the enum
625+
value from being code-generated:
626+
627+
```proto
628+
enum PhoneType {
629+
PHONE_TYPE_UNSPECIFIED = 0;
630+
PHONE_TYPE_MOBILE = 1;
631+
PHONE_TYPE_HOME = 2;
632+
PHONE_TYPE_WORK = 3 [deprecated=true];
633+
}
634+
```
635+
623636
For more information about how to work with message `enum`s in your
624637
applications, see the [generated code guide](/reference/)
625638
for your chosen language.

content/programming-guides/style.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,9 @@ enum FooBar {
9898
```
9999

100100
Each enum value should end with a semicolon, not a comma. Prefer prefixing enum
101-
values instead of surrounding them in an enclosing message.
101+
values instead of surrounding them in an enclosing message. Since some languages
102+
don't support an enum being defined inside a "struct" type, this ensures a
103+
consistent approach across binding languages.
102104

103105
The zero value enum should have the suffix `UNSPECIFIED`, because a server or
104106
application that gets an unexpected enum value will mark the field as unset in

0 commit comments

Comments
 (0)