Skip to content

Commit 42986d0

Browse files
deploy: 4821406
1 parent e750513 commit 42986d0

1 file changed

Lines changed: 9 additions & 10 deletions

File tree

  • programming-guides/extension_declarations

programming-guides/extension_declarations/index.html

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@
4242
(<code>Foo</code>) with this name or number, we enforce that the number, type, and full
4343
name of the extension match what is forward-declared here.</li></ul><div class="alert alert-warning" role=alert><h4 class=alert-heading>Warning</h4>Avoid using declarations for extension range groups such as <code>extensions 4, 999</code>.
4444
It is unclear which extension range the declarations apply to, and it is
45-
currently
46-
unsupported.</div><p>The extension declarations expect two extension fields with different packages:</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-proto data-lang=proto><span style=display:flex><span><span style=color:#204a87;font-weight:700>package</span> <span style=color:#000>my</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>package</span><span style=color:#000;font-weight:700>;</span><span style=color:#a40000>
45+
currently unsupported.</div><p>The extension declarations expect two extension fields with different packages:</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-proto data-lang=proto><span style=display:flex><span><span style=color:#204a87;font-weight:700>package</span> <span style=color:#000>my</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>package</span><span style=color:#000;font-weight:700>;</span><span style=color:#a40000>
4746
</span></span></span><span style=display:flex><span><span style=color:#a40000></span><span style=color:#204a87;font-weight:700>extend</span> <span style=color:#000>Foo</span> <span style=color:#000;font-weight:700>{</span><span style=color:#a40000>
4847
</span></span></span><span style=display:flex><span><span style=color:#a40000></span> <span style=color:#204a87;font-weight:700>repeated</span> <span style=color:#000>logs.proto.ValidationAnnotations</span> <span style=color:#000>event_annotations</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#0000cf;font-weight:700>4</span><span style=color:#000;font-weight:700>;</span><span style=color:#a40000>
4948
</span></span></span><span style=display:flex><span><span style=color:#a40000></span><span style=color:#000;font-weight:700>}</span><span style=color:#a40000>
@@ -92,8 +91,8 @@
9291
declarations serve as a registry of all the parent message&rsquo;s extensions, and
9392
protoc will enforce that there are no field number conflicts. When you add a new
9493
extension, choose the next available number usually by just incrementing by one
95-
the previously added extension number.</p><p><strong>TIP:</strong> There is a <a href=#message-set>special guidance</a> for
96-
<code>MessageSet</code> which provides a script to help pick
94+
the previously added extension number.</p><p><strong>TIP:</strong> There is a <a href=#message-set>special guidance</a>
95+
for <code>MessageSet</code> which provides a script to help pick
9796
the next available number.</p><p>Whenever you delete an extension, make sure to mark the field number <code>reserved</code>
9897
to eliminate the risk of accidentally reusing
9998
it.</p><p>This convention is only a recommendation&ndash;the protobuf team does not have the
@@ -113,8 +112,8 @@
113112
proto should be decoded from the wire format. The protobuf wire format is lean
114113
and doesn’t provide a good way to detect fields encoded using one definition and
115114
decoded using another.</p><p>This ambiguity can manifest in a short time frame, such as a client using one
116-
extension definition and a server using another communicating
117-
.</p><p>This ambiguity can also manifest over a longer time frame, such as storing data
115+
extension definition and a server using another
116+
communicating .</p><p>This ambiguity can also manifest over a longer time frame, such as storing data
118117
encoded using one extension definition and later retrieving and decoding using
119118
the second extension definition. This long-term case can be difficult to
120119
diagnose if the first extension definition was deleted after the data was
@@ -124,10 +123,10 @@
124123
debugging at a minimum. It could also cause data leaks or corruption that takes
125124
months to clean up.</p><h2 id=usage-tips>Usage Tips</h2><h3 id=never-delete>Never Delete an Extension Declaration</h3><p>Deleting an extension declaration opens the door to accidental reuse in the
126125
future. If the extension is no longer processed and the definition is deleted,
127-
the extension declaration can be <a href=#reserved>marked reserved</a>.</p><h3 id=never-reuse-reserved>Never Use a Field Name or Number from the <code>reserved</code> List for a New Extension Declaration</h3><p>Reserved numbers may have been used for fields or other extensions in the past.</p><p>Using the <code>full_name</code> of a reserved field
128-
is not recommended
129-
due
130-
to the possibility of ambiguity when using textproto.</p><h3 id=never-change-type>Never change the type of an existing extension declaration</h3><p>Changing the extension field&rsquo;s type can result in data corruption.</p><p>If the extension field is of an enum or message type, and that enum or message
126+
the extension declaration can be <a href=#reserved>marked reserved</a>.</p><h3 id=never-reuse-reserved>Never Use a Field Name or Number from the <code>reserved</code> List for a New Extension Declaration</h3><p>Reserved numbers may have been used for fields or other extensions in the past.</p><p>Using the <code>full_name</code> of a reserved
127+
field is not
128+
recommended due to the possibility of ambiguity when using
129+
textproto.</p><h3 id=never-change-type>Never change the type of an existing extension declaration</h3><p>Changing the extension field&rsquo;s type can result in data corruption.</p><p>If the extension field is of an enum or message type, and that enum or message
131130
type is being renamed, updating the declaration name is required and safe. To
132131
avoid breakages, the update of the type, the extension field definition, and
133132
extension declaration should all happen in a single

0 commit comments

Comments
 (0)