Skip to content

Commit 354da49

Browse files
authored
Merge pull request protocolbuffers#251 from Logofile/sync
Documentation change
2 parents 016ec10 + 8d8904f commit 354da49

File tree

10 files changed

+79
-26
lines changed

10 files changed

+79
-26
lines changed

content/getting-started/pythontutorial.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,6 @@ edition = "2023";
8080
8181
package tutorial;
8282
83-
option features.field_presence = EXPLICIT;
84-
8583
message Person {
8684
string name = 1;
8785
int32 id = 2;

content/news/_index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ New news topics will also be published to the
2020
The following news topics provide information in the reverse order in which it
2121
was released.
2222

23+
* [March 18, 2025](/news/2025-03-18) - Dropping support
24+
for Ruby 3.0
2325
* [January 23, 2025](/news/2025-01-23) - Poison Java
2426
gencode
2527
* [December 18, 2024](/news/2024-12-18) - Go Protobuf:

content/programming-guides/editions.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2022,6 +2022,20 @@ protoc --proto_path=IMPORT_PATH --cpp_out=DST_DIR --java_out=DST_DIR --python_ou
20222022
Multiple import directories can be specified by passing the `--proto_path`
20232023
option multiple times; they will be searched in order. `-I=_IMPORT_PATH_`
20242024
can be used as a short form of `--proto_path`.
2025+
2026+
**Note:** File paths relative to their `proto_path` must be globally unique in a
2027+
given binary. For example, if you have `proto/lib1/data.proto` and
2028+
`proto/lib2/data.proto`, those two files cannot be used together with
2029+
`-I=proto/lib1 -I=proto/lib2` because it would be ambiguous which file `import
2030+
"data.proto"` will mean. Instead `-Iproto/` should be used and the global names
2031+
will be `lib1/data.proto` and `lib2/data.proto`.
2032+
2033+
If you are publishing a library and other users may use your messages directly,
2034+
you should include a unique library name in the path that they are expected to
2035+
be used under to avoid file name collisions. If you have multiple directories in
2036+
one project, it is best practice to prefer setting one `-I` to a top level
2037+
directory of the project.
2038+
20252039
* You can provide one or more *output directives*:
20262040

20272041
* `--cpp_out` generates C++ code in `DST_DIR`. See the

content/programming-guides/enum.md

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ There are two options for moving to conformant behavior:
161161
> exception when passed `Enum.UNRECOGNIZED`, whereas `setNameValue` will accept
162162
> `2`.
163163
164-
### Kotlin {#java}
164+
### Kotlin {#kotlin}
165165
166166
All known Kotlin releases are out of conformance. When a `proto2` file imports
167167
an enum defined in a `proto3` file, Kotlin treats that field as a **closed**
@@ -184,17 +184,11 @@ PHP is conformant.
184184
185185
### Python {#python}
186186
187-
After [4.22.0](https://pypi.org/project/protobuf/4.22.0/) which was released
188-
~2023-02-16, Python is conformant.
187+
Python is conformant in versions above 4.22.0 (released 2023 Q1).
189188
190-
In 4.21.x, Python is conformant by default, but setting
191-
`PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python` will cause it to be out of
192-
conformance.
193-
194-
Before 4.21.0, Python is out of conformance.
195-
196-
When a `proto2` file imports an enum defined in a `proto3` file, non-conformant
197-
Python versions treat that field as a **closed** enum.
189+
Older versions which are no longer supported are out of conformance. When a
190+
`proto2` file imports an enum defined in a `proto3` file, non-conformant Python
191+
versions treat that field as a **closed** enum.
198192
199193
### Ruby {#ruby}
200194
@@ -203,11 +197,11 @@ All known Ruby releases are out of conformance. Ruby treats all enums as
203197
204198
### Objective-C {#obj-c}
205199
206-
After 22.0, Objective-C is conformant.
200+
Objective-C is conformant in versions above 3.22.0 (released 2023 Q1).
207201
208-
Prior to 22.0, Objective-C was out of conformance. When a `proto2` file imported
209-
an enum defined in a `proto3` file, it would treat that field as a **closed**
210-
enum.
202+
Older versions which are no longer supported and are out of conformance. When a
203+
`proto2` file imports an enum defined in a `proto3` file, non-conformant ObjC
204+
versions treat that field as a **closed** enum.
211205
212206
### Swift {#swift}
213207

content/programming-guides/json.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ topic.
2121

2222
When parsing JSON-encoded data into a protocol buffer, if a value is missing or
2323
if its value is `null`, it will be interpreted as the corresponding
24-
[default value](/programming-guides/editions#default). Multiple values for
25-
singular fields (using duplicate or equivalent JSON keys) are accepted and the
26-
last value is retained, as with binary format parsing. Note that not all
27-
protobuf JSON parser implementations are conformant, and some nonconformant
28-
implementations may reject duplicate keys instead.
24+
[default value](/programming-guides/editions#default).
25+
Multiple values for singular fields (using duplicate or equivalent JSON keys)
26+
are accepted and the last value is retained, as with binary format parsing. Note
27+
that not all protobuf JSON parser implementations are conformant, and some
28+
nonconformant implementations may reject duplicate keys instead.
2929

3030
When generating JSON-encoded output from a protocol buffer, if a protobuf field
3131
has the default value and if the field doesn't support field presence, it will

content/programming-guides/proto2.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2359,6 +2359,20 @@ protoc --proto_path=IMPORT_PATH --cpp_out=DST_DIR --java_out=DST_DIR --python_ou
23592359
Multiple import directories can be specified by passing the `--proto_path`
23602360
option multiple times; they will be searched in order. `-I=_IMPORT_PATH_`
23612361
can be used as a short form of `--proto_path`.
2362+
2363+
**Note:** File paths relative to their `proto_path` must be globally unique in a
2364+
given binary. For example, if you have `proto/lib1/data.proto` and
2365+
`proto/lib2/data.proto`, those two files cannot be used together with
2366+
`-I=proto/lib1 -I=proto/lib2` because it would be ambiguous which file `import
2367+
"data.proto"` will mean. Instead `-Iproto/` should be used and the global names
2368+
will be `lib1/data.proto` and `lib2/data.proto`.
2369+
2370+
If you are publishing a library and other users may use your messages directly,
2371+
you should include a unique library name in the path that they are expected to
2372+
be used under to avoid file name collisions. If you have multiple directories in
2373+
one project, it is best practice to prefer setting one `-I` to a top level
2374+
directory of the project.
2375+
23622376
* You can provide one or more *output directives*:
23632377

23642378
* `--cpp_out` generates C++ code in `DST_DIR`. See the

content/programming-guides/proto3.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1700,8 +1700,22 @@ protoc --proto_path=IMPORT_PATH --cpp_out=DST_DIR --java_out=DST_DIR --python_ou
17001700
* `IMPORT_PATH` specifies a directory in which to look for `.proto` files when
17011701
resolving `import` directives. If omitted, the current directory is used.
17021702
Multiple import directories can be specified by passing the `--proto_path`
1703-
option multiple times; they will be searched in order. `-I=_IMPORT_PATH_`
1704-
can be used as a short form of `--proto_path`.
1703+
option multiple times. `-I=_IMPORT_PATH_` can be used as a short form of
1704+
`--proto_path`.
1705+
1706+
**Note:** File paths relative to their `proto_path` must be globally unique in a
1707+
given binary. For example, if you have `proto/lib1/data.proto` and
1708+
`proto/lib2/data.proto`, those two files cannot be used together with
1709+
`-I=proto/lib1 -I=proto/lib2` because it would be ambiguous which file `import
1710+
"data.proto"` will mean. Instead `-Iproto/` should be used and the global names
1711+
will be `lib1/data.proto` and `lib2/data.proto`.
1712+
1713+
If you are publishing a library and other users may use your messages directly,
1714+
you should include a unique library name in the path that they are expected to
1715+
be used under to avoid file name collisions. If you have multiple directories in
1716+
one project, it is best practice to prefer setting one `-I` to a top level
1717+
directory of the project.
1718+
17051719
* You can provide one or more *output directives*:
17061720

17071721
* `--cpp_out` generates C++ code in `DST_DIR`. See the

content/reference/cpp/cpp-generated.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,15 @@ In addition to these methods, the `Foo` class defines the following methods:
127127
`option optimize_for = LITE_RUNTIME` is specified in the `.proto` file, then
128128
the return type changes to `std::string*`.
129129

130+
**Note:** The copy constructor and assignment operator perform a deep copy of
131+
the message data. This ensures that each message object owns and manages its own
132+
copy of the data, preventing issues like double frees or use-after-free errors.
133+
This behavior is consistent with standard C++ practice for objects that own
134+
their data, such as `std::vector`. For developers coming from languages with
135+
different copy semantics (such as JavaScript or TypeScript, where shallow copies
136+
might be more common), it is important to note that modifications to a copied
137+
message will not affect the original message, and vice-versa.
138+
130139
The class also defines the following static methods:
131140

132141
- `static const Descriptor* descriptor()`: Returns the type's descriptor. This

content/reference/dart/dart-generated.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,14 @@ The compiler will generate the following accessor methods in the message class:
160160

161161
- `bool hasFoo()`: Returns `true` if the field is set.
162162

163+
{{% alert title="Note" color="note" %}} This
164+
value cannot really be trusted if the proto was serialized in another
165+
language that supports implicit presence (for example, Java). Even though
166+
Dart tracks presence, other languages do not, and round-tripping a
167+
zero-valued implicit presence field will make it "disappear" from Dart's
168+
perspective.
169+
{{% /alert %}}
170+
163171
- `void clearFoo()`: Clears the value of the field. After calling this,
164172
`hasFoo()` will return `false` and `get foo` will return the default value.
165173

content/reference/rust/rust-generated.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ The compiler will generate the following accessor methods:
191191
value.
192192

193193
For other numeric field types (including `bool`), `int32` is replaced with the
194-
corresponding C++ type according to the
194+
corresponding Rust type according to the
195195
[scalar value types table](/programming-guides/proto3#scalar).
196196

197197
### Implicit Presence Numeric Fields (proto3) {#implicit-presence-numeric}
@@ -208,7 +208,7 @@ int32 foo = 1;
208208
calling this, `foo()` will return value.
209209

210210
For other numeric field types (including `bool`), `int32` is replaced with the
211-
corresponding C++ type according to the
211+
corresponding Rust type according to the
212212
[scalar value types table](/programming-guides/proto3#scalar).
213213

214214
### Optional String/Bytes Fields (proto2 and proto3) {#optional-string-byte}

0 commit comments

Comments
 (0)