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

The deprecated attribute #221

Open
vorner opened this issue Sep 9, 2019 · 1 comment
Open

The deprecated attribute #221

vorner opened this issue Sep 9, 2019 · 1 comment

Comments

@vorner
Copy link
Contributor

vorner commented Sep 9, 2019

Hello

I have a proto file with some [deprecated=true] attributes in it, like this one:

enum Stuff {
    DEFAULT = 0;
    OUTDATED = 1 [deprecated=true];
    NEW = 2;
}

From what I can tell, it doesn't propagate the attribute into the generated code. Would it be hard to place the #[deprecated] attribute onto the generated code?

@danburkert
Copy link
Collaborator

Nope, should be relatively straightforward. Sounds like a great feature addition to prost.

danburkert referenced this issue Jan 18, 2020
Protobufs support `deprecated` field options. These field options allow
the field to continue to be supported, but allow for language specific
code generators to include that the field has been deprecated in the
generated code. As discussed in
https://github.com/danburkert/prost/issues/221 we should consider
supporting this in `prost`.

This commit adds support for this feature in `prost-build` by checking
the field options, and if present emitting a `#[deprecated]` attribute.

One short coming of this change is that it is difficult to test that the
`deprecated` attribute is correctly added with an assertion since the
attribute is not accessible at runtime.
dunmatt referenced this issue in dunmatt/prost Apr 1, 2020
Protobufs support `deprecated` field options. These field options allow
the field to continue to be supported, but allow for language specific
code generators to include that the field has been deprecated in the
generated code. As discussed in
https://github.com/danburkert/prost/issues/221 we should consider
supporting this in `prost`.

This commit adds support for this feature in `prost-build` by checking
the field options, and if present emitting a `#[deprecated]` attribute.

One short coming of this change is that it is difficult to test that the
`deprecated` attribute is correctly added with an assertion since the
attribute is not accessible at runtime.
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

2 participants