Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deprecated as a message-level option / annotation #1734

Closed
licarth opened this issue Jul 1, 2016 · 9 comments
Closed

deprecated as a message-level option / annotation #1734

licarth opened this issue Jul 1, 2016 · 9 comments

Comments

@licarth
Copy link

licarth commented Jul 1, 2016

There is currently no way of marking a whole message as deprecated.

My current workaround of doing this is to deprecate all fields.

message MyMessage {
    uint32 id = 1 [deprecated=true];
    string name = 2 [deprecated=true];
}

... but it does not exactly mean the same thing, right ?

It would be great to be able to either mark the message with an option (does that even exist ?)

message MyMessage [deprecated=true] {
    uint32 id = 1;
    string name = 2;
}

or an annotation ?

@deprecated
message MyMessage {
    uint32 id = 1;
    string name = 2;
}

The other nice thing about deprecating the message itself would be that one would not need to find all its usages as field and mark all of them as deprecated fields.

@thomasvl
Copy link
Contributor

thomasvl commented Jul 1, 2016

Drive by - Your last comment in the interesting part. It's sorta harder to say a message can be deprecated without looking at all of the uses. Deprecating it usually means there is something that should be used instead. If you can mark the message as deprecated without ensuring all uses have the alternate way, aren't you likely to create situations where the other messages are basically broken because they don't have the new way?

@xfxyjwf
Copy link
Contributor

xfxyjwf commented Jul 22, 2016

You can already mark a message as deprecated by doing this:

message MyMessage {
  option deprecated = true;
  ...
}

Actually you can pretty much use the deprecation annotation on all proto constructs:

option deprecated = true; // file-level option
message MyMessage {
  option deprecated = true; // message level
  enum MyEnum {
    option deprecated = true; // enum level
    MY_ENUM_FOO = 1 [deprecated = true]; // enum-value
  }
}

This doesn't do anything useful in most implementations though (i.e., nothing is generated for this deprecated annotation), but if you can file separate requests per language if there is a standard way to do deprecation in that language.

@xfxyjwf xfxyjwf closed this as completed Jul 22, 2016
@sarnobat
Copy link

This one gives me a compile-error:

option deprecated = true; // enum level

Option "deprecated" unknown.

@Siddhant
Copy link

Siddhant commented Jan 9, 2019

Does enum value deprecation:
MY_ENUM_FOO = 1 [deprecated = true]; // enum-value
actually work in any protobuf version?
I don't think so. It's also not documented explicitly anywhere.

@Siddhant
Copy link

Siddhant commented Jan 9, 2019

The new reserved keyword might be of interest here (both proto2 and proto3).
(First introduced in 3.0.0-alpha-3.)

@nycdotnet
Copy link

Wanted to note that option deprecated = true; works on proto messages as of latest protoc in March 2019, and when compiling to C# will apply the System.ObsoleteAttribute to the generated class.

@roman-lemko
Copy link

roman-lemko commented Apr 18, 2019

Another note to the note above:
This, unfortunately, isn't true for rpcs.
Adding an option deprecated=true; to an rpc doesn't seem to have effect on generated C# methods.

@hypnoglow
Copy link

Note for Go: adding option deprecated = true to an rpc effectively adds // Deprecated: Do not use. comment to the generated service client/server interfaces and client method implementation.

@runtugen
Copy link

Note for Java: adds @java.lang.Deprecated to generated source with "option deprecated = true;"

adellahlou pushed a commit to adellahlou/protobuf that referenced this issue Apr 20, 2023
adellahlou pushed a commit to adellahlou/protobuf that referenced this issue Apr 20, 2023
* feat: proto3 optional support

* chore: pre-release v6.11.0-pre

* fix: rebuild

* fix: fromObject should not initialize oneof members (protocolbuffers#1597)

* test: adding test for pbjs static code generation

* fix: fromObject should not initialize oneof members

* chore: release v6.11.0

* chore: rebuild

* feat: add --no-service option for pbjs static target (protocolbuffers#1577)

This option skips generation of service clients.

Co-authored-by: Alexander Fenster <fenster@google.com>

* deps: set @types/node to >= (protocolbuffers#1575)

* deps: set @types/node to star version

When using `protobuf.js` as a dependency in a project it is important
that `@types/node` package gets de-duped and has the same version as for
the rest of the modules in the project. Otherwise, typing conflicts
could happen as they do between v13 and v14 node types.

* fix: use @types/node >=13.7.0

* fix: use @types/node >=13.7.0

Co-authored-by: Alexander Fenster <fenster@google.com>
Co-authored-by: Alexander Fenster <github@fenster.name>

* chore: rebuild

* docs: update changelog

* fix: parse.js "parent.add(oneof)“ error (protocolbuffers#1602)

Co-authored-by: xiaoweili <xiaoweili@tencent.com>

* chore: release v6.11.1

* fix(types): bring back Field.rule to .d.ts

* fix: rebuild type, release v6.11.2

* build: configure backports

* build: configure 6.x as default branch

* fix: do not let setProperty change the prototype (protocolbuffers#1731)

* fix(deps): use eslint 8.x (protocolbuffers#1728)

* build: run tests if ci label added (protocolbuffers#1734)

* build: publish to main

* chore(6.x): release 6.11.3 (protocolbuffers#1737)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Support parsing of complex options

* Use readValue to read the proto value and add better example

* Fix lint issues

* fix: rollback files

* Re-do parse logic to take arrays into account and make it simpler

Co-authored-by: Alexander Fenster <fenster@google.com>
Co-authored-by: Matthew Douglass <5410142+mdouglass@users.noreply.github.com>
Co-authored-by: Fedor Indutny <fedor.indutny@gmail.com>
Co-authored-by: Alexander Fenster <github@fenster.name>
Co-authored-by: leon <leon776@users.noreply.github.com>
Co-authored-by: xiaoweili <xiaoweili@tencent.com>
Co-authored-by: Benjamin Coe <bencoe@google.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants