-
-
Notifications
You must be signed in to change notification settings - Fork 286
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
add collection_type settings #218
Conversation
This is awesome! Thanks a lot! @xuwei-k |
import protocbridge.JvmGenerator | ||
|
||
package object scalapb { | ||
def gen( | ||
flatPackage: Boolean = false, | ||
javaConversions: Boolean = false, | ||
grpc: Boolean = true, | ||
singleLineToString: Boolean = false): (JvmGenerator, Seq[String]) = | ||
singleLineToString: Boolean = false, | ||
collectionType: String = "scala.collection.Seq"): (JvmGenerator, Seq[String]) = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer that this would be a field-level setting (in scalapb.proto), not a global compiler setting. The use case I see is that a single repeated field in a proto is known to be a set, while the rest of the file stays with the default implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A field level set is definitely a good use case but for our projects being able to set a global collection type for repeated items different than Seq
would be really helpful. Seq
isnt very strict so that the functional programming libs we uses don't support it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's do a file-level option then. We found that global compiler settings (such as flat_package) that affect the public API of the generated code hurts maintainability issues down the line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A set of three options would be the best in my opinion.
In some cases I would really like to use plain arrays of primitives for the performance reasons, for example.
So, options having priorities from high to low in the following order would be really the perfect variant:
Field level option -> File-level option -> Global option -> Seq
What's the status of this PR? We urgently need to be able to use immutable sequences. |
I looked into it today, started to make some changes and it's currently parking in the collection_type. The main difference is that it's going to have a file and field-level options, but not as a global option. Global options should not affect the generated interfaces (I made that mistake with The current issues that still need to be solved:
|
https://gitter.im/trueaccord/ScalaPB?at=583dc53cb4d7ca3b7a1810fa
/cc @kailuowang
Edit: also fix #208