Skip to content

Commit dcd08f3

Browse files
Protocol Buffer TeamLogofile
authored andcommitted
This documentation change includes the following:
* Adds a language guide for Edition 2023 * Updates the 2024-10-02 news topic with some APIs that were missed in the original release of that topic * Softens the title of 1-1-1.md from "Rule" to "Best Practice," and adds some additional context to the guidelines * Moves content about nullable getters/setters into its own topic from the kotlin-generated.md topic * Updates the language guide topics for proto2 and proto3 to include Editions-specific information, as well as to update some outdated content PiperOrigin-RevId: 684505087 Change-Id: I9d8ce3745a1aeb3825d64bd6a9da25b48964a680
1 parent 9bbf481 commit dcd08f3

File tree

7 files changed

+2769
-280
lines changed

7 files changed

+2769
-280
lines changed

content/news/2024-10-02.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,16 @@ and
157157
**Replacement:** `message_factory.GetMessageClass()` and
158158
`message_factory.GetMessageClassesForFiles()`.
159159

160+
#### GetDebugString
161+
162+
**APIs:**
163+
[`GetDebugString`](https://github.com/protocolbuffers/protobuf/blob/7f395af40e86e00b892e812beb67a03564884756/python/google/protobuf/pyext/descriptor.cc#L1510)
164+
165+
**Replacement:**
166+
167+
No replacement. It's only in Python C++ which is no longer released. It is not
168+
supported in pure Python or UPB.
169+
160170
## Changes in Objective-C {#objc}
161171

162172
**This will be the first breaking release for Objective-C**.
@@ -263,6 +273,37 @@ which includes any unknown fields.
263273
and
264274
[-[`GPBMessage clearUnknownFields`]](https://github.com/protocolbuffers/protobuf/blob/224573d66a0cc958c76cb43d8b2eb3aa7cdb89f2/objectivec/GPBMessage.h#L497-L504C9)
265275

276+
### Remove Deprecated Runtime APIs for Old Gencode {#objc-remove-apis-gencode}
277+
278+
This release will remove deprecated runtime methods that support the Objective-C
279+
gencode from before the 3.22.x release. The library will also issue a log
280+
message at runtime when old generated code is starting up.
281+
282+
**API:** [`+[GPBFileDescriptor
283+
allocDescriptorForClass:file:fields:fieldCount:storageSize:flags:]`](https://github.com/protocolbuffers/protobuf/blob/1b44ce0feef45a78ba99d09bd2e5ff5052a6541b/objectivec/GPBDescriptor_PackagePrivate.h#L213-L220)
284+
285+
**Replacement:** Regenerate with a current version of the library.
286+
287+
**API:** [`+[GPBFileDescriptor
288+
allocDescriptorForClass:rootClass:file:fields:fieldCount:storageSize:flags:]`](https://github.com/protocolbuffers/protobuf/blob/1b44ce0feef45a78ba99d09bd2e5ff5052a6541b/objectivec/GPBDescriptor_PackagePrivate.h#L221-L229)
289+
290+
**Replacement:** Regenerate with a current version of the library.
291+
292+
**API:** [`+[GPBEnumDescriptor
293+
allocDescriptorForName:valueNames:values:count:enumVerifier:]`](https://github.com/protocolbuffers/protobuf/blob/1b44ce0feef45a78ba99d09bd2e5ff5052a6541b/objectivec/GPBDescriptor_PackagePrivate.h#L285-L291)
294+
295+
**Replacement:** Regenerate with a current version of the library.
296+
297+
**API:** [`+[GPBEnumDescriptor
298+
allocDescriptorForName:valueNames:values:count:enumVerifier:extraTextFormatInfo:]`](https://github.com/protocolbuffers/protobuf/blob/1b44ce0feef45a78ba99d09bd2e5ff5052a6541b/objectivec/GPBDescriptor_PackagePrivate.h#L292-L299)
299+
300+
**Replacement:** Regenerate with a current version of the library.
301+
302+
**API:**
303+
[`-[GPBExtensionDescriptor initWithExtensionDescription:]`](https://github.com/protocolbuffers/protobuf/blob/1b44ce0feef45a78ba99d09bd2e5ff5052a6541b/objectivec/GPBDescriptor_PackagePrivate.h#L317-L320)
304+
305+
**Replacement:** Regenerate with a current version of the library.
306+
266307
## Other Changes {#non-breaking}
267308

268309
In addition to those breaking changes are some other changes worth noting. While

content/programming-guides/1-1-1.md

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,34 @@
11
+++
2-
title = "1-1-1 Rule"
2+
title = "1-1-1 Best Practice"
33
weight = 105
4-
linkTitle = "1-1-1 Rule"
4+
linkTitle = "1-1-1 Best Practice"
55
description = "All proto definitions should have one top-level element and build target per file."
66
type = "docs"
77
+++
88

9-
The 1-1-1 rule has the following elements:
9+
The 1-1-1 best practice is to keep every proto_library and .proto file as small
10+
as is reasonable, with the ideal being:
1011

11-
* One `proto_library` rule
12+
* One `proto_library` build rule
1213
* One source `.proto` file
1314
* One top-level entity (message, enum, or extension)
1415

15-
When defining a proto schema, you should have a single message, enum, extension,
16-
service, or group of cyclic dependencies per file. This makes refactoring
17-
easier. Moving files when they're separated is much easier than extracting
18-
messages from a file with other messages. Following this practice also helps to
19-
keep the proto schema files smaller, which enhances maintainability.
16+
Having the fewest number of message, enum, extension, and services as you
17+
reasonably can makes refactoring easier. Moving files when they're separated is
18+
much easier than extracting messages from a file with other messages.
19+
20+
Following this practice can help build times and binary size by reducing the
21+
size of your transitive dependencies in practice: when some code only needs to
22+
use one enum, under a 1-1-1 design it can depend just on the .proto file that
23+
defines that enum and avoid incidentally pulling in a large set of transitive
24+
dependencies that may only be used by another message defined in the same file.
25+
26+
There are cases where the 1-1-1 ideal is not possible (circular dependencies),
27+
not ideal (extremely conceptually coupled messages which have readability
28+
benefits by being co-located), or where the some of the downsides don't apply
29+
(when a .proto file has no imports, then there are no technical concerns about
30+
the size of transitive dependencies). As with any best practice, use good
31+
judgment for when to diverge from the guideline.
2032

2133
One place that modularity of proto schema files is important is when creating
2234
gRPC

0 commit comments

Comments
 (0)