Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into mono_pkg_dont_block…
Browse files Browse the repository at this point in the history
…_tests
  • Loading branch information
osa1 committed Mar 6, 2024
2 parents 4479ad3 + b761358 commit cd86940
Show file tree
Hide file tree
Showing 20 changed files with 304 additions and 218 deletions.
56 changes: 28 additions & 28 deletions .github/workflows/dart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Cache Pub hosted dependencies
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319
with:
path: "~/.pub-cache/hosted"
key: "os:ubuntu-latest;pub-cache-hosted;sdk:stable"
restore-keys: |
os:ubuntu-latest;pub-cache-hosted
os:ubuntu-latest
- name: Setup Dart SDK
uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f
uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3
with:
sdk: stable
- id: checkout
Expand All @@ -43,7 +43,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Cache Pub hosted dependencies
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319
with:
path: "~/.pub-cache/hosted"
key: "os:ubuntu-latest;pub-cache-hosted;sdk:2.19.0;packages:protobuf;commands:analyze_0"
Expand All @@ -53,7 +53,7 @@ jobs:
os:ubuntu-latest;pub-cache-hosted
os:ubuntu-latest
- name: Setup Dart SDK
uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f
uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3
with:
sdk: "2.19.0"
- id: checkout
Expand All @@ -73,7 +73,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Cache Pub hosted dependencies
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319
with:
path: "~/.pub-cache/hosted"
key: "os:ubuntu-latest;pub-cache-hosted;sdk:2.19.0;packages:protobuf;commands:test_0"
Expand All @@ -83,7 +83,7 @@ jobs:
os:ubuntu-latest;pub-cache-hosted
os:ubuntu-latest
- name: Setup Dart SDK
uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f
uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3
with:
sdk: "2.19.0"
- id: checkout
Expand All @@ -103,7 +103,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Cache Pub hosted dependencies
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319
with:
path: "~/.pub-cache/hosted"
key: "os:ubuntu-latest;pub-cache-hosted;sdk:2.19.0;packages:protoc_plugin;commands:command_0-command_3-test_1"
Expand All @@ -113,7 +113,7 @@ jobs:
os:ubuntu-latest;pub-cache-hosted
os:ubuntu-latest
- name: Setup Dart SDK
uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f
uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3
with:
sdk: "2.19.0"
- id: checkout
Expand Down Expand Up @@ -141,7 +141,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Cache Pub hosted dependencies
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319
with:
path: "~/.pub-cache/hosted"
key: "os:ubuntu-latest;pub-cache-hosted;sdk:2.19.0;packages:protoc_plugin;commands:command_0-command_3-test_0"
Expand All @@ -151,7 +151,7 @@ jobs:
os:ubuntu-latest;pub-cache-hosted
os:ubuntu-latest
- name: Setup Dart SDK
uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f
uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3
with:
sdk: "2.19.0"
- id: checkout
Expand Down Expand Up @@ -179,7 +179,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Cache Pub hosted dependencies
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319
with:
path: "~/.pub-cache/hosted"
key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:protobuf;commands:analyze_0"
Expand All @@ -189,7 +189,7 @@ jobs:
os:ubuntu-latest;pub-cache-hosted
os:ubuntu-latest
- name: Setup Dart SDK
uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f
uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3
with:
sdk: dev
- id: checkout
Expand All @@ -209,7 +209,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Cache Pub hosted dependencies
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319
with:
path: "~/.pub-cache/hosted"
key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:protobuf;commands:test_0"
Expand All @@ -219,7 +219,7 @@ jobs:
os:ubuntu-latest;pub-cache-hosted
os:ubuntu-latest
- name: Setup Dart SDK
uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f
uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3
with:
sdk: dev
- id: checkout
Expand All @@ -239,7 +239,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Cache Pub hosted dependencies
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319
with:
path: "~/.pub-cache/hosted"
key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:protoc_plugin;commands:command_0-command_3-test_0"
Expand All @@ -249,7 +249,7 @@ jobs:
os:ubuntu-latest;pub-cache-hosted
os:ubuntu-latest
- name: Setup Dart SDK
uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f
uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3
with:
sdk: dev
- id: checkout
Expand Down Expand Up @@ -277,7 +277,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Cache Pub hosted dependencies
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319
with:
path: "~/.pub-cache/hosted"
key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:protoc_plugin;commands:format-command_0-command_3-analyze_1"
Expand All @@ -287,7 +287,7 @@ jobs:
os:ubuntu-latest;pub-cache-hosted
os:ubuntu-latest
- name: Setup Dart SDK
uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f
uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3
with:
sdk: dev
- id: checkout
Expand Down Expand Up @@ -319,7 +319,7 @@ jobs:
runs-on: macos-latest
steps:
- name: Cache Pub hosted dependencies
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319
with:
path: "~/.pub-cache/hosted"
key: "os:macos-latest;pub-cache-hosted;sdk:2.19.0;packages:protobuf;commands:test_0"
Expand All @@ -329,7 +329,7 @@ jobs:
os:macos-latest;pub-cache-hosted
os:macos-latest
- name: Setup Dart SDK
uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f
uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3
with:
sdk: "2.19.0"
- id: checkout
Expand All @@ -349,7 +349,7 @@ jobs:
runs-on: macos-latest
steps:
- name: Cache Pub hosted dependencies
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319
with:
path: "~/.pub-cache/hosted"
key: "os:macos-latest;pub-cache-hosted;sdk:dev;packages:protobuf;commands:test_0"
Expand All @@ -359,7 +359,7 @@ jobs:
os:macos-latest;pub-cache-hosted
os:macos-latest
- name: Setup Dart SDK
uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f
uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3
with:
sdk: dev
- id: checkout
Expand All @@ -379,7 +379,7 @@ jobs:
runs-on: windows-latest
steps:
- name: Setup Dart SDK
uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f
uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3
with:
sdk: "2.19.0"
- id: checkout
Expand All @@ -399,7 +399,7 @@ jobs:
runs-on: windows-latest
steps:
- name: Setup Dart SDK
uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f
uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3
with:
sdk: dev
- id: checkout
Expand All @@ -419,7 +419,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Cache Pub hosted dependencies
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319
with:
path: "~/.pub-cache/hosted"
key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:api_benchmark;commands:format-command_0-command_1-analyze_0"
Expand All @@ -429,7 +429,7 @@ jobs:
os:ubuntu-latest;pub-cache-hosted
os:ubuntu-latest
- name: Setup Dart SDK
uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f
uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3
with:
sdk: dev
- id: checkout
Expand Down Expand Up @@ -475,7 +475,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Cache Pub hosted dependencies
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319
with:
path: "~/.pub-cache/hosted"
key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:benchmarks;commands:format-command_0-command_2-analyze_0"
Expand All @@ -485,7 +485,7 @@ jobs:
os:ubuntu-latest;pub-cache-hosted
os:ubuntu-latest
- name: Setup Dart SDK
uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f
uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3
with:
sdk: dev
- id: checkout
Expand Down
11 changes: 11 additions & 0 deletions protobuf/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,20 @@
To migrate, use `PbMap.unmodifiable(map.keyFieldType, map.valueFieldType)`
instead of `PbMap.unmodifiable(map)`. ([#902])

* Messages deserialized from JSON now generate the unknown fields when
serialized as JSON.

Note that, as before, unknown fields in JSON messages are not stored in the
`unknownFields` of the message. They are only used by the JSON serializers to
support roundtripping.

([#49], [#918])

[#738]: https://github.com/google/protobuf.dart/issues/738
[#896]: https://github.com/google/protobuf.dart/issues/896
[#902]: https://github.com/google/protobuf.dart/issues/902
[#49]: https://github.com/google/protobuf.dart/issues/49
[#918]: https://github.com/google/protobuf.dart/pulls/918

## 3.1.0

Expand Down
2 changes: 2 additions & 0 deletions protobuf/lib/meta.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const GeneratedMessage_reservedNames = <String>[
'writeToCodedBufferWriter',
'writeToJson',
'writeToJsonMap',
r'$_clearField',
r'$_ensure',
r'$_get',
r'$_getI64',
Expand All @@ -72,6 +73,7 @@ const GeneratedMessage_reservedNames = <String>[
r'$_setBool',
r'$_setBytes',
r'$_setDouble',
r'$_setField',
r'$_setFloat',
r'$_setInt64',
r'$_setSignedInt32',
Expand Down
27 changes: 27 additions & 0 deletions protobuf/lib/src/protobuf/field_set.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ class _FieldSet {
/// Contains all the unknown fields, or null if there aren't any.
UnknownFieldSet? _unknownFields;

/// Contains unknown data for messages deserialized from json.
Map<String, dynamic>? _unknownJsonData;

/// Encodes whether `this` has been frozen, and if so, also memoizes the
/// hash code.
///
Expand Down Expand Up @@ -105,6 +108,7 @@ class _FieldSet {
if (_isReadOnly) return UnknownFieldSet.emptyUnknownFieldSet;
_unknownFields = UnknownFieldSet();
}
_unknownJsonData = null;
return _unknownFields!;
}

Expand Down Expand Up @@ -531,6 +535,8 @@ class _FieldSet {
if (_unknownFields != o._unknownFields) return false;
}

// Ignore _unknownJsonData to preserve existing equality behavior.

return true;
}

Expand Down Expand Up @@ -597,6 +603,8 @@ class _FieldSet {
// Hash with unknown fields.
hash = _HashUtils._combine(hash, _unknownFields?.hashCode ?? 0);

// Ignore _unknownJsonData to preserve existing hashing behavior.

if (_isReadOnly) {
_frozenState = hash;
}
Expand Down Expand Up @@ -682,6 +690,11 @@ class _FieldSet {
} else {
out.write(UnknownFieldSet().toString());
}

final unknownJsonData = _unknownJsonData;
if (unknownJsonData != null) {
out.write(unknownJsonData.toString());
}
}

/// Merges the contents of the [other] into this message.
Expand Down Expand Up @@ -713,6 +726,15 @@ class _FieldSet {
if (otherUnknownFields != null) {
_ensureUnknownFields().mergeFromUnknownFieldSet(otherUnknownFields);
}

final otherUnknownJsonData = other._unknownJsonData;
if (otherUnknownJsonData != null) {
final newUnknownJsonData =
Map<String, dynamic>.from(_unknownJsonData ?? {});
otherUnknownJsonData
.forEach((key, value) => newUnknownJsonData[key] = value);
_unknownJsonData = newUnknownJsonData.isEmpty ? null : newUnknownJsonData;
}
}

void _mergeField(FieldInfo otherFi, fieldValue, {required bool isExtension}) {
Expand Down Expand Up @@ -868,6 +890,11 @@ class _FieldSet {
_ensureUnknownFields()._fields.addAll(originalUnknownFields._fields);
}

final unknownJsonData = original._unknownJsonData;
if (unknownJsonData != null) {
_unknownJsonData = Map.from(unknownJsonData);
}

_oneofCases?.addAll(original._oneofCases!);
}
}
Loading

0 comments on commit cd86940

Please sign in to comment.