Skip to content

Commit

Permalink
Add option to preserve unknown fields.
Browse files Browse the repository at this point in the history
  • Loading branch information
thesamet committed Dec 3, 2017
1 parent 2a0d61d commit a677f96
Show file tree
Hide file tree
Showing 28 changed files with 408 additions and 92 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Change Log

## [Unreleased](https://github.com/scalapb/ScalaPB/tree/HEAD)
- Update to protobuf-java 3.5.0
- Added file-level option to preserve unknown fields in generated classes.

## [v0.6.7](https://github.com/scalapb/ScalaPB/tree/v0.6.6) (2017-11-23)
[Full Changelog](https://github.com/scalapb/ScalaPB/compare/v0.6.0...v0.6.7)
- GeneratedMessageCompanion: add `nestedMessagesCompanions` and Add
- Added base class GeneratedFileObject that will be the base class for the
singleton object generated for each proto file.
Expand Down
185 changes: 157 additions & 28 deletions compiler-plugin/src/main/java/scalapb/options/compiler/Scalapb.java

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,12 @@ trait DescriptorPimps {

def isValueClass: Boolean = messageOptions.getExtendsList.asScala.exists(valueClassNames)

// In protobuf 3.5.0 all messages preserve unknown fields. We make an exception for value classes
// since they must have an exactly one val.
def preservesUnknownFields = (
message.isExtendable || message.getFile.scalaOptions.getPreserveUnknownFields
) && !isValueClass

def baseClasses: Seq[String] = {
val specialMixins = message.getFullName match {
case "google.protobuf.Any" => Seq("_root_.scalapb.AnyMethods")
Expand Down
Loading

0 comments on commit a677f96

Please sign in to comment.