Skip to content

Commit 2851f9d

Browse files
Update Proto Best Practices to use the editions syntax for reserved field names and reserved enum names.
Also adds links to the documentation. PiperOrigin-RevId: 891886343
1 parent 0bcf3c5 commit 2851f9d

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

content/best-practices/dos-donts.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ somewhere. Or there could be old code in another server that will break.
2727
When you delete a field that's no longer used, reserve its tag number so that no
2828
one accidentally re-uses it in the future. Just `reserved 2, 3;` is enough. No
2929
type required (lets you trim dependencies!). You can also reserve names to avoid
30-
recycling now-deleted field names: `reserved "foo", "bar";`.
30+
recycling now-deleted field names: `reserved foo, bar;`. See the docs on
31+
[reserved field numbers](/programming-guides/editions#fieldreserved)
32+
and
33+
[reserved field names](/programming-guides/editions#reserved-field-names).
3134

3235
<a id="do-reserve-numbers-for-deleted-enum-values"></a>
3336

@@ -36,7 +39,8 @@ recycling now-deleted field names: `reserved "foo", "bar";`.
3639
When you delete an enum value that's no longer used, reserve its number so that
3740
no one accidentally re-uses it in the future. Just `reserved 2, 3;` is enough.
3841
You can also reserve names to avoid recycling now-deleted value names: `reserved
39-
"FOO", "BAR";`.
42+
FOO, BAR;`. See also
43+
[enum reserved values](/programming-guides/editions#reserved)
4044

4145
<a id="do-put-new-enum-aliases-last"></a>
4246

@@ -67,7 +71,7 @@ To safely remove the original name (if it's being used for interchange, which it
6771

6872
Almost never change the type of a field; it'll mess up deserialization, same as
6973
re-using a tag number. The
70-
[protobuf docs](/programming-guides/proto2#updating)
74+
[protobuf docs](/programming-guides/editions#updating)
7175
outline a small number of cases that are okay (for example, going between
7276
`int32`, `uint32`, `int64` and `bool`). However, changing a field’s message type
7377
**will break** unless the new message is a superset of the old one.
@@ -118,7 +122,7 @@ less code. Note that [proto enums][proto-enums] require the first value to be
118122
zero and can round-trip (deserialize, serialize) an unknown enum value.
119123

120124
[example-unspecified]: http://cs/#search/&q=file:proto%20%22_UNSPECIFIED%20=%200%22&type=cs
121-
[proto-enums]: /programming-guides/proto2#enum
125+
[proto-enums]: /programming-guides/editions#enum
122126

123127
<a id="dont-use-cc-macro-constants-for-enum-values"></a>
124128

0 commit comments

Comments
 (0)