-
-
Notifications
You must be signed in to change notification settings - Fork 287
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: removing private from typemapper (#1674)
* feat: removing private from typemapper * feat: public_constructor_parameters flag
- Loading branch information
1 parent
b8a7cd1
commit d93a990
Showing
9 changed files
with
170 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
syntax = "proto3"; | ||
|
||
package com.thesamet.proto.e2e; | ||
|
||
import "scalapb/scalapb.proto"; | ||
|
||
option (scalapb.options) = { | ||
public_constructor_parameters: true, | ||
preserve_unknown_fields: false, | ||
single_file: true, | ||
import: "com.thesamet.proto.e2e.TypeMappers.enumMapper", | ||
aux_field_options : [ | ||
{ | ||
target: "com.thesamet.proto.e2e.NestedExampleEvent.action" | ||
options: { | ||
type: "String" | ||
}} | ||
], | ||
}; | ||
|
||
message NestedExampleEvent { | ||
string id = 1; | ||
Action action = 2; | ||
enum Action { | ||
Undefined = 0; | ||
Allow = 1; | ||
Deny = 2; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.thesamet.proto.e2e | ||
|
||
import scalapb.{GeneratedEnumCompanion, TypeMapper} | ||
|
||
object TypeMappers { | ||
implicit def enumMapper[A <: scalapb.GeneratedEnum](implicit ec: GeneratedEnumCompanion[A]): TypeMapper[A, String] = TypeMapper[A, String](_.name)(ec.fromName(_).get) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import org.scalatest.funspec.AnyFunSpec | ||
import org.scalatest.matchers.must.Matchers | ||
import com.thesamet.proto.e2e.issue1664.NestedExampleEvent | ||
|
||
class Issue1664Spec extends AnyFunSpec with Matchers { | ||
|
||
it("issue1664:public_constructor_parameters") { | ||
// Without public_constructor_parameters, this is inaccessible | ||
NestedExampleEvent._typemapper_action.toBase("Allow") mustBe NestedExampleEvent.Action.Allow | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.