Skip to content

Commit 0681431

Browse files
Protocol Buffer TeamLogofile
authored andcommitted
This change includes the following:
* Updates links to `/programming-guides/proto2.md` throughout topics * Adds content to `editions/features.md` about group-like field behaviors. * Adds content to `editions/features.md` about the `features.(pb.cpp).string_type` feature. * Adds a new topic, `reference/go/size.md` * Updates guidance on releases in `support/version-support.md` PiperOrigin-RevId: 626374994 Change-Id: I1a43714f5aafd15acb2e80b1f900f42434eb11dd
1 parent b832d88 commit 0681431

File tree

18 files changed

+326
-53
lines changed

18 files changed

+326
-53
lines changed

content/editions/features.md

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,15 @@ This feature sets the behavior for encoding fields when serializing.
238238
This feature doesn't impact proto3 files, so this section doesn't have a before
239239
and after of a proto3 file.
240240

241+
Depending on the language, fields that are "group-like" may have some unexpected
242+
capitalization in generated code and in text-format, in order to provide
243+
backwards compatibility with proto2. Message fields are "group-like" if all of
244+
the following conditions are met:
245+
246+
* Has `DELIMITED` message encoding specified
247+
* Message type is defined in the same scope as the field
248+
* Field name is exactly the lowercased type name
249+
241250
**Values available:**
242251

243252
* `LENGTH_PREFIXED`: Fields are encoded using the LEN wire type described in
@@ -455,6 +464,78 @@ message Msg {
455464
}
456465
```
457466

467+
#### `features.(pb.cpp).string_type` {#string_type}
468+
469+
**Languages:** C++
470+
471+
This feature determines how generated code should treat string fields. This
472+
replaces the `ctype` option from proto2 and proto3, and offers a new
473+
`string_view` feature. In Edition 2023, either `ctype` or `string_view` may be
474+
specified on a field, but not both.
475+
476+
**Values available:**
477+
478+
* `VIEW`: Generates `string_view` accessors for the field. This will be the
479+
default in a future edition.
480+
* `CORD`: Generates `Cord` accessors for the field.
481+
* `STRING`: Generates `string` accessors for the field.
482+
483+
**Applicable to the following scopes:** File, Field
484+
485+
**Default behavior in Edition 2023:** `STRING`
486+
487+
**Behavior in proto2:** `STRING`
488+
489+
**Behavior in proto3:** `STRING`
490+
491+
The following code sample shows a proto2 file:
492+
493+
```proto
494+
syntax = "proto2";
495+
496+
message Foo {
497+
optional string bar = 6;
498+
optional string baz = 7 [ctype = CORD];
499+
}
500+
```
501+
502+
After running Prototiller, the equivalent code might look like this:
503+
504+
```proto
505+
edition = "2023";
506+
507+
import "google/protobuf/cpp_features.proto";
508+
509+
message Foo {
510+
optional string bar = 6;
511+
optional string baz = 7 [features.(pb.cpp).string_type = CORD];
512+
}
513+
```
514+
515+
The following shows a proto3 file:
516+
517+
```proto
518+
syntax = "proto3"
519+
520+
message Foo {
521+
string bar = 6;
522+
string baz = 7 [ctype = CORD];
523+
}
524+
```
525+
526+
After running Prototiller, the equivalent code might look like this:
527+
528+
```proto
529+
edition = "2023";
530+
531+
import "google/protobuf/cpp_features.proto";
532+
533+
message Foo {
534+
string bar = 6;
535+
string baz = 7 [features.(pb.cpp).string_type = CORD];
536+
}
537+
```
538+
458539
#### `features.(pb.java).utf8_validation` {#java-utf8_validation}
459540

460541
**Languages:** Java

content/getting-started/cpptutorial.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ shows you how to
1616

1717
This isn't a comprehensive guide to using protocol buffers in C++. For more
1818
detailed reference information, see the
19-
[Protocol Buffer Language Guide (proto2)](/programming-guides/proto),
19+
[Protocol Buffer Language Guide (proto2)](/programming-guides/proto2),
2020
the
2121
[Protocol Buffer Language Guide (proto3)](/programming-guides/proto3),
2222
the [C++ API Reference](/reference/cpp/api-docs), the
@@ -169,7 +169,7 @@ most messages defined in proto2 syntax use `optional` and `repeated` only.
169169

170170
You'll find a complete guide to writing `.proto` files -- including all the
171171
possible field types -- in the
172-
[Protocol Buffer Language Guide](/programming-guides/proto).
172+
[Protocol Buffer Language Guide](/programming-guides/proto2).
173173
Don't go looking for facilities similar to class inheritance, though -- protocol
174174
buffers don't do that.
175175

@@ -557,7 +557,7 @@ some rules you need to follow. In the new version of the protocol buffer:
557557
buffer, not even by deleted fields).
558558
559559
(There are
560-
[some exceptions](/programming-guides/proto#updating) to
560+
[some exceptions](/programming-guides/proto2#updating) to
561561
these rules, but they are rarely used.)
562562
563563
If you follow these rules, old code will happily read new messages and simply

content/getting-started/javatutorial.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ shows you how to
1616

1717
This isn't a comprehensive guide to using protocol buffers in Java. For more
1818
detailed reference information, see the
19-
[Protocol Buffer Language Guide (proto2)](/programming-guides/proto),
19+
[Protocol Buffer Language Guide (proto2)](/programming-guides/proto2),
2020
the
2121
[Protocol Buffer Language Guide (proto3)](/programming-guides/proto3),
2222
the
@@ -189,7 +189,7 @@ most messages defined in proto2 syntax use `optional` and `repeated` only.
189189

190190
You'll find a complete guide to writing `.proto` files -- including all the
191191
possible field types -- in the
192-
[Protocol Buffer Language Guide](/programming-guides/proto).
192+
[Protocol Buffer Language Guide](/programming-guides/proto2).
193193
Don't go looking for facilities similar to class inheritance, though -- protocol
194194
buffers don't do that.
195195

@@ -580,7 +580,7 @@ some rules you need to follow. In the new version of the protocol buffer:
580580
not even by deleted fields).
581581
582582
(There are
583-
[some exceptions](/programming-guides/proto#updating) to
583+
[some exceptions](/programming-guides/proto2#updating) to
584584
these rules, but they are rarely used.)
585585
586586
If you follow these rules, old code will happily read new messages and simply

content/getting-started/pythontutorial.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ shows you how to
1616

1717
This isn't a comprehensive guide to using protocol buffers in Python. For more
1818
detailed reference information, see the
19-
[Protocol Buffer Language Guide (proto2)](/programming-guides/proto),
19+
[Protocol Buffer Language Guide (proto2)](/programming-guides/proto2),
2020
the
2121
[Protocol Buffer Language Guide (proto3)](/programming-guides/proto3),
2222
the [Python API Reference](https://googleapis.dev/python/protobuf/latest/), the
@@ -167,7 +167,7 @@ most messages defined in proto2 syntax use `optional` and `repeated` only.
167167

168168
You'll find a complete guide to writing `.proto` files -- including all the
169169
possible field types -- in the
170-
[Protocol Buffer Language Guide](/programming-guides/proto).
170+
[Protocol Buffer Language Guide](/programming-guides/proto2).
171171
Don't go looking for facilities similar to class inheritance, though -- protocol
172172
buffers don't do that.
173173

@@ -443,7 +443,7 @@ some rules you need to follow. In the new version of the protocol buffer:
443443
not even by deleted fields).
444444
445445
(There are
446-
[some exceptions](/programming-guides/proto#updating) to
446+
[some exceptions](/programming-guides/proto2#updating) to
447447
these rules, but they are rarely used.)
448448
449449
If you follow these rules, old code will happily read new messages and simply

content/news/2022-08-03.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ changes that are being considered for the 22.x release line.
1212
## Platform Support Changes {#platform-changes}
1313

1414
We've added guidance about the platforms that we support in
15-
[this section](/programming-guides/proto#platforms) of
15+
[this section](/programming-guides/proto2#platforms) of
1616
the documentation. The section currently covers C++ and PHP, but may be expanded
1717
with information about other platforms in the future.
1818

1919
## Official C++ Support Matrix {#cpp-support-matrix}
2020

2121
With the policy, mentioned earlier in this announcement, of using Google's
2222
official
23-
[foundational C++ support policy](/programming-guides/proto#platforms),
23+
[foundational C++ support policy](/programming-guides/proto2#platforms),
2424
our
2525
[C++ compiler and toolchain support matrix will change](https://github.com/google/oss-policies-info/blob/8067c719150dfec6a836dd82230c5eb0ba11acd7/foundational-cxx-support-matrix.md).
2626

content/programming-guides/api.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Document the constraints, expectations and interpretation of each field in as
6161
few words as possible.
6262

6363
You can use custom proto annotations.
64-
See [Custom Options](/programming-guides/proto#options)
64+
See [Custom Options](/programming-guides/proto2#options)
6565
to define cross-language constants like `max_length` in the example above.
6666
Supported in proto2 and proto3.
6767

@@ -291,7 +291,7 @@ worse—write one.
291291

292292
More generally, choose the right primitive type. See the Scalar Value Types
293293
table in the
294-
[Protocol Buffer Language Guide](/programming-guides/proto#scalar).
294+
[Protocol Buffer Language Guide](/programming-guides/proto2#scalar).
295295

296296
### Returning HTML in a Front-End Proto {#returning-html}
297297

content/programming-guides/enum.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Enums behave differently in different language libraries. This topic covers the
99
different behaviors as well as the plans to move protobufs to a state where they
1010
are consistent across all languages. If you're looking for information on how to
1111
use enums in general, see the corresponding sections in the
12-
[proto2](/programming-guides/proto#enum) and
12+
[proto2](/programming-guides/proto2#enum) and
1313
[proto3](/programming-guides/proto3#enum) language guide
1414
topics.
1515

content/reference/cpp/arenas.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ buffer compiler generates in addition to the code described in the
1111
[C++ Generated Code Guide](/reference/cpp/cpp-generated)
1212
when arena allocation is enabled. It assumes that you are familiar with the
1313
material in the
14-
[language guide](/programming-guides/proto) and the
14+
[language guide](/programming-guides/proto2) and the
1515
[C++ Generated Code Guide](/reference/cpp/cpp-generated).
1616

1717
## Why Use Arena Allocation? {#why}

content/reference/csharp/csharp-generated.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ before reading this document.
1414
{{% alert title="Note" color="note" %}}
1515
The protobuf compiler can generate C\# interfaces for definitions using `proto2`
1616
syntax starting from release 3.10. Refer to the
17-
[proto2 language guide](/programming-guides/proto) for
17+
[proto2 language guide](/programming-guides/proto2) for
1818
details of the semantics of `proto2` definitions, and see
1919
`docs/csharp/proto2.md`
2020
([view on GitHub](https://github.com/protocolbuffers/protobuf/blob/master/docs/csharp/proto2.md))

content/reference/dart/dart-generated.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ Any differences between
1010
proto2 and proto3 generated code are highlighted - note that these differences
1111
are in the generated code as described in this document, not the base API, which
1212
are the same in both versions. You should read the
13-
[proto2 language guide](/programming-guides/proto) and/or
14-
the [proto3 language guide](/programming-guides/proto3)
13+
[proto2 language guide](/programming-guides/proto2)
14+
and/or the
15+
[proto3 language guide](/programming-guides/proto3)
1516
before reading this document.
1617

1718
## Compiler Invocation {#invocation}
@@ -129,7 +130,7 @@ The compiler will generate the following accessor methods in the message class:
129130

130131
For other simple field types, the corresponding Dart type is chosen according to
131132
the
132-
[scalar value types table](/programming-guides/proto#scalar).
133+
[scalar value types table](/programming-guides/proto2#scalar).
133134
For message and enum types, the value type is replaced with the message or enum
134135
class.
135136

@@ -394,7 +395,7 @@ The protocol buffer compiler will generate a class called `Bar`, which extends
394395
## Extensions (proto2 only) {#extension}
395396

396397
Given a file `foo_test.proto` including a message with an
397-
[extension range](/programming-guides/proto#extensions)
398+
[extension range](/programming-guides/proto2#extensions)
398399
and a top-level extension definition:
399400

400401
```proto

0 commit comments

Comments
 (0)