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

Field options for types #1375

Closed
enzief opened this issue May 23, 2022 · 4 comments
Closed

Field options for types #1375

enzief opened this issue May 23, 2022 · 4 comments

Comments

@enzief
Copy link

enzief commented May 23, 2022

Motivation: allow Scala annotations to be added after type ascription of a message field.

For example, it's impossible to append @nowarn to a deprecated class. We should be able to do this:

message M {
    DeprecatedType the_field = 1 [(scalapb.field).type_annotations = "@nowarn"];
}

to generate

case class M(theField: DeprecatedType @nowarn)
@ak0rz
Copy link
Contributor

ak0rz commented May 23, 2022

Motivation: allow Scala annotations to be added after type ascription of a message field.

For example, it's impossible to append @nowarn to a deprecated class. We should be able to do this:

message M {
    DeprecatedType the_field = 1 [(scalapb.field).type_annotations = "@nowarn"];
}

to generate

case class M(theField: DeprecatedType @nowarn)

First of all, you must use the canonical name for the annotation:

message M {
    DeprecatedType the_field = 1 [(scalapb.field).annotations = "@scala.annotation.nowarn"];
}

secondly, in case of use of deprecated type (scalapb.field).annotations should work fine.

Can you try to reproduce it with canonical annotation name?

@thesamet
Copy link
Contributor

@enzief , see https://scalapb.github.io/docs/customizations#adding-annotations for documentation on (scalapb.field).annotations. It prepends the annotation though so I am not sure if it makes a difference in this case. Another suggestion which may eliminate the need for this in your use case is to compile protos in a seperate subproject for which you ignore its warnings.

@thesamet
Copy link
Contributor

Hi @enzief , were you able to check if the suggestions above work for your use case?

@enzief
Copy link
Author

enzief commented Jul 14, 2022

They work. Thank you @thesamet .

@enzief enzief closed this as completed Jul 14, 2022
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

3 participants