scalapb/ScalaPB

A way to set level preserve_unknown_fields for the project level.

ianlintner opened this issue · 4 comments

Currently, you can set preserve_unknown_fields at the namespace or file level using the https://scalapb.github.io/docs/customizations/

I would like a way to set it for the per-project setting to use the behavior pre 0.10.0 if I explicitly define it.

Ideal Solution: Set preserve_unknown_fields as an SBT option.

Hi @ianlintner , see this FAQ for why we chose not to have global options: https://scalapb.github.io/docs/faq#why-a-certain-customization-is-not-available-as-a-global-generator-parameter

Since you're aware this feature can be enabled for an entire package, what is the use case that isn't solved by this?

I have an external protobuf library that is language agnostic that has a few dozen different namespaces without a shared root.

My scala project uses the external protobuf library now requires 20+ additional package configurations to match the pre 0.10.0 behavior.

Is there another solution to make a better developer experience when working with large proto libs?

Would it work for you if there was a way to easily list all the top-level namespaces in package scoped options? Something like:

import "scalapb/scalapb.proto";

option (scalapb.options) = {
  scope: PACKAGE
  preserve_unknown_fields: false
  apply_to_packages: ["pkg1", "pkg2", "pkg3", ...]  # <-- new proposed feature
};

Out of curiosity, why not enable unknown fields for the Scala project? It may require changes if you used pattern matching, but other than that, I think it should be considered to enable it.

Closing due to inactivity. Feel free to comment if the issue is still relevant.