From c90ba1d6f7603705df9252ad1c578ddbc778d8d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20A=C4=9Facan?= Date: Fri, 14 Nov 2025 11:49:38 +0000 Subject: [PATCH 1/4] Add dart=3.10 pragmas to protobuf lib code --- protobuf/lib/meta.dart | 2 + protobuf/lib/protobuf.dart | 2 + protobuf/lib/src/protobuf/annotations.dart | 2 + protobuf/lib/src/protobuf/builder_info.dart | 19 ++++---- protobuf/lib/src/protobuf/coded_buffer.dart | 2 + .../lib/src/protobuf/coded_buffer_reader.dart | 2 + .../lib/src/protobuf/coded_buffer_writer.dart | 46 ++++++++++--------- protobuf/lib/src/protobuf/consts.dart | 2 + protobuf/lib/src/protobuf/exceptions.dart | 2 + protobuf/lib/src/protobuf/extension.dart | 2 + .../lib/src/protobuf/extension_field_set.dart | 2 + .../lib/src/protobuf/extension_registry.dart | 6 ++- protobuf/lib/src/protobuf/field_error.dart | 2 + protobuf/lib/src/protobuf/field_info.dart | 2 + protobuf/lib/src/protobuf/field_set.dart | 13 +++--- protobuf/lib/src/protobuf/field_type.dart | 2 + .../lib/src/protobuf/generated_message.dart | 19 ++++++-- .../lib/src/protobuf/generated_service.dart | 2 + protobuf/lib/src/protobuf/internal.dart | 4 +- protobuf/lib/src/protobuf/json/json.dart | 11 +---- protobuf/lib/src/protobuf/json/json_vm.dart | 2 + protobuf/lib/src/protobuf/json/json_web.dart | 9 ++-- .../src/protobuf/json_parsing_context.dart | 2 + protobuf/lib/src/protobuf/message_set.dart | 2 + .../lib/src/protobuf/mixins/map_mixin.dart | 2 + .../lib/src/protobuf/mixins/well_known.dart | 9 ++-- protobuf/lib/src/protobuf/pb_list.dart | 2 + protobuf/lib/src/protobuf/pb_map.dart | 2 + .../lib/src/protobuf/permissive_compare.dart | 2 + protobuf/lib/src/protobuf/proto3_json.dart | 26 +++++------ protobuf/lib/src/protobuf/protobuf_enum.dart | 2 + protobuf/lib/src/protobuf/rpc_client.dart | 2 + protobuf/lib/src/protobuf/type_registry.dart | 2 + .../lib/src/protobuf/unknown_field_set.dart | 23 +++++----- protobuf/lib/src/protobuf/unpack.dart | 2 + protobuf/lib/src/protobuf/utils.dart | 2 + protobuf/lib/src/protobuf/wire_format.dart | 2 + 37 files changed, 155 insertions(+), 82 deletions(-) diff --git a/protobuf/lib/meta.dart b/protobuf/lib/meta.dart index 8a9ba6815..573b1853e 100644 --- a/protobuf/lib/meta.dart +++ b/protobuf/lib/meta.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// @dart=3.10 + /// Provides metadata about GeneratedMessage and ProtobufEnum to /// dart-protoc-plugin. (Experimental API; subject to change.) /// @nodoc diff --git a/protobuf/lib/protobuf.dart b/protobuf/lib/protobuf.dart index f28801963..e473e449c 100644 --- a/protobuf/lib/protobuf.dart +++ b/protobuf/lib/protobuf.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// @dart=3.10 + /// Runtime library for Dart implementation of [protobufs][1]. /// /// [1]: https://developers.google.com/protocol-buffers diff --git a/protobuf/lib/src/protobuf/annotations.dart b/protobuf/lib/src/protobuf/annotations.dart index 093a9af9b..463a87044 100644 --- a/protobuf/lib/src/protobuf/annotations.dart +++ b/protobuf/lib/src/protobuf/annotations.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// @dart=3.10 + /// Annotation for marking accessors that belong together. class TagNumber { final int tagNumber; diff --git a/protobuf/lib/src/protobuf/builder_info.dart b/protobuf/lib/src/protobuf/builder_info.dart index 28997e4c2..93475d842 100644 --- a/protobuf/lib/src/protobuf/builder_info.dart +++ b/protobuf/lib/src/protobuf/builder_info.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// @dart=3.10 + part of 'internal.dart'; /// Per-message type setup. @@ -561,10 +563,12 @@ class BuilderInfo { } List _computeSortedByTag() => - // Code generator inserts fields in tag order, but it's possible for - // user-written code to insert unordered. - List.from(fieldInfo.values, growable: false) - ..sort((FieldInfo a, FieldInfo b) => a.tagNumber.compareTo(b.tagNumber)); + // Code generator inserts fields in tag order, but it's possible for + // user-written code to insert unordered. + List.from( + fieldInfo.values, + growable: false, + )..sort((FieldInfo a, FieldInfo b) => a.tagNumber.compareTo(b.tagNumber)); GeneratedMessage _makeEmptyMessage( int tagNumber, @@ -572,10 +576,9 @@ class BuilderInfo { ) { var subBuilderFunc = subBuilder(tagNumber); if (subBuilderFunc == null && extensionRegistry != null) { - subBuilderFunc = - extensionRegistry - .getExtension(qualifiedMessageName, tagNumber)! - .subBuilder; + subBuilderFunc = extensionRegistry + .getExtension(qualifiedMessageName, tagNumber)! + .subBuilder; } return subBuilderFunc!(); } diff --git a/protobuf/lib/src/protobuf/coded_buffer.dart b/protobuf/lib/src/protobuf/coded_buffer.dart index ebfe6d7cb..7c39f25a9 100644 --- a/protobuf/lib/src/protobuf/coded_buffer.dart +++ b/protobuf/lib/src/protobuf/coded_buffer.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// @dart=3.10 + part of 'internal.dart'; void _writeToCodedBufferWriter(FieldSet fs, CodedBufferWriter out) { diff --git a/protobuf/lib/src/protobuf/coded_buffer_reader.dart b/protobuf/lib/src/protobuf/coded_buffer_reader.dart index 28d269946..c25a1f3d9 100644 --- a/protobuf/lib/src/protobuf/coded_buffer_reader.dart +++ b/protobuf/lib/src/protobuf/coded_buffer_reader.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// @dart=3.10 + part of 'internal.dart'; /// Reader used for converting binary-encoded protobufs into diff --git a/protobuf/lib/src/protobuf/coded_buffer_writer.dart b/protobuf/lib/src/protobuf/coded_buffer_writer.dart index 387fb2e2f..5149637d6 100644 --- a/protobuf/lib/src/protobuf/coded_buffer_writer.dart +++ b/protobuf/lib/src/protobuf/coded_buffer_writer.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// @dart=3.10 + // ignore_for_file: constant_identifier_names part of 'internal.dart'; @@ -153,8 +155,9 @@ class CodedBufferWriter { // Copy at most `bytesToCopy` bytes from the current chunk. final leftInChunk = bytesInChunk - chunkPos; - final bytesToCopyFromChunk = - leftInChunk > bytesToCopy ? bytesToCopy : leftInChunk; + final bytesToCopyFromChunk = leftInChunk > bytesToCopy + ? bytesToCopy + : leftInChunk; buffer.setRange( outPos, outPos + bytesToCopyFromChunk, @@ -484,26 +487,25 @@ class CodedBufferWriter { static const _MESSAGE_BIT_INDEX = 20; /// Mapping from value types to wire-types indexed by _valueTypeIndex(...). - static final Uint8List _wireTypes = - Uint8List(32) - ..[_BOOL_BIT_INDEX] = WIRETYPE_VARINT - ..[_BYTES_BIT_INDEX] = WIRETYPE_LENGTH_DELIMITED - ..[_STRING_BIT_INDEX] = WIRETYPE_LENGTH_DELIMITED - ..[_DOUBLE_BIT_INDEX] = WIRETYPE_FIXED64 - ..[_FLOAT_BIT_INDEX] = WIRETYPE_FIXED32 - ..[_ENUM_BIT_INDEX] = WIRETYPE_VARINT - ..[_GROUP_BIT_INDEX] = WIRETYPE_START_GROUP - ..[_INT32_BIT_INDEX] = WIRETYPE_VARINT - ..[_INT64_BIT_INDEX] = WIRETYPE_VARINT - ..[_SINT32_BIT_INDEX] = WIRETYPE_VARINT - ..[_SINT64_BIT_INDEX] = WIRETYPE_VARINT - ..[_UINT32_BIT_INDEX] = WIRETYPE_VARINT - ..[_UINT64_BIT_INDEX] = WIRETYPE_VARINT - ..[_FIXED32_BIT_INDEX] = WIRETYPE_FIXED32 - ..[_FIXED64_BIT_INDEX] = WIRETYPE_FIXED64 - ..[_SFIXED32_BIT_INDEX] = WIRETYPE_FIXED32 - ..[_SFIXED64_BIT_INDEX] = WIRETYPE_FIXED64 - ..[_MESSAGE_BIT_INDEX] = WIRETYPE_LENGTH_DELIMITED; + static final Uint8List _wireTypes = Uint8List(32) + ..[_BOOL_BIT_INDEX] = WIRETYPE_VARINT + ..[_BYTES_BIT_INDEX] = WIRETYPE_LENGTH_DELIMITED + ..[_STRING_BIT_INDEX] = WIRETYPE_LENGTH_DELIMITED + ..[_DOUBLE_BIT_INDEX] = WIRETYPE_FIXED64 + ..[_FLOAT_BIT_INDEX] = WIRETYPE_FIXED32 + ..[_ENUM_BIT_INDEX] = WIRETYPE_VARINT + ..[_GROUP_BIT_INDEX] = WIRETYPE_START_GROUP + ..[_INT32_BIT_INDEX] = WIRETYPE_VARINT + ..[_INT64_BIT_INDEX] = WIRETYPE_VARINT + ..[_SINT32_BIT_INDEX] = WIRETYPE_VARINT + ..[_SINT64_BIT_INDEX] = WIRETYPE_VARINT + ..[_UINT32_BIT_INDEX] = WIRETYPE_VARINT + ..[_UINT64_BIT_INDEX] = WIRETYPE_VARINT + ..[_FIXED32_BIT_INDEX] = WIRETYPE_FIXED32 + ..[_FIXED64_BIT_INDEX] = WIRETYPE_FIXED64 + ..[_SFIXED32_BIT_INDEX] = WIRETYPE_FIXED32 + ..[_SFIXED64_BIT_INDEX] = WIRETYPE_FIXED64 + ..[_MESSAGE_BIT_INDEX] = WIRETYPE_LENGTH_DELIMITED; } int _encodeZigZag32(int value) => (value << 1) ^ (value >> 31); diff --git a/protobuf/lib/src/protobuf/consts.dart b/protobuf/lib/src/protobuf/consts.dart index 22062b7d6..473acafd7 100644 --- a/protobuf/lib/src/protobuf/consts.dart +++ b/protobuf/lib/src/protobuf/consts.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// @dart=3.10 + /// Constant string value of `double.infinity.toString()` and the infinity /// value recognized by `double.parse(..)`. const infinity = 'Infinity'; diff --git a/protobuf/lib/src/protobuf/exceptions.dart b/protobuf/lib/src/protobuf/exceptions.dart index ce34a140e..1825efb86 100644 --- a/protobuf/lib/src/protobuf/exceptions.dart +++ b/protobuf/lib/src/protobuf/exceptions.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// @dart=3.10 + const _truncatedMessageText = ''' While parsing a protocol message, the input ended unexpectedly in the middle of a field. This could either mean that the input diff --git a/protobuf/lib/src/protobuf/extension.dart b/protobuf/lib/src/protobuf/extension.dart index 1af1529a9..b04eb3665 100644 --- a/protobuf/lib/src/protobuf/extension.dart +++ b/protobuf/lib/src/protobuf/extension.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// @dart=3.10 + part of 'internal.dart'; /// An object representing an extension field. diff --git a/protobuf/lib/src/protobuf/extension_field_set.dart b/protobuf/lib/src/protobuf/extension_field_set.dart index bb954e25f..ae179f4e9 100644 --- a/protobuf/lib/src/protobuf/extension_field_set.dart +++ b/protobuf/lib/src/protobuf/extension_field_set.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// @dart=3.10 + part of 'internal.dart'; class ExtensionFieldSet { diff --git a/protobuf/lib/src/protobuf/extension_registry.dart b/protobuf/lib/src/protobuf/extension_registry.dart index f7de71afc..bb5ba4040 100644 --- a/protobuf/lib/src/protobuf/extension_registry.dart +++ b/protobuf/lib/src/protobuf/extension_registry.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// @dart=3.10 + part of 'internal.dart'; /// A collection of [Extension] objects, organized by the message type they @@ -117,8 +119,8 @@ T _reparseMessage( if (itemList != null) { for (final group in itemList.groups) { - final typeId = - group._fields[_messageSetItemTypeIdTag]!.varints[0].toInt(); + final typeId = group._fields[_messageSetItemTypeIdTag]!.varints[0] + .toInt(); if (extensionRegistry.getExtension( message.info_.qualifiedMessageName, typeId, diff --git a/protobuf/lib/src/protobuf/field_error.dart b/protobuf/lib/src/protobuf/field_error.dart index a91160234..d77f9182e 100644 --- a/protobuf/lib/src/protobuf/field_error.dart +++ b/protobuf/lib/src/protobuf/field_error.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// @dart=3.10 + part of 'internal.dart'; /// Returns the error message for an invalid field value, diff --git a/protobuf/lib/src/protobuf/field_info.dart b/protobuf/lib/src/protobuf/field_info.dart index 775b3c0f0..c9f816ca7 100644 --- a/protobuf/lib/src/protobuf/field_info.dart +++ b/protobuf/lib/src/protobuf/field_info.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// @dart=3.10 + part of 'internal.dart'; /// An object representing a protobuf message field. diff --git a/protobuf/lib/src/protobuf/field_set.dart b/protobuf/lib/src/protobuf/field_set.dart index 6677da0b4..223c0b804 100644 --- a/protobuf/lib/src/protobuf/field_set.dart +++ b/protobuf/lib/src/protobuf/field_set.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// @dart=3.10 + part of 'internal.dart'; @pragma('vm:never-inline') @@ -910,10 +912,9 @@ class FieldSet { } if (otherFi.isGroupOrMessage) { - final currentFi = - isExtension - ? _ensureExtensions()._getFieldOrNull(fi as Extension) - : _values[fi.index!]; + final currentFi = isExtension + ? _ensureExtensions()._getFieldOrNull(fi as Extension) + : _values[fi.index!]; final GeneratedMessage msg = fieldValue; if (currentFi == null) { @@ -998,8 +999,8 @@ class FieldSet { if (fieldInfo.isMapField) { final PbMap? map = _values[index]; if (map != null) { - _values[index] = - (fieldInfo as MapFieldInfo)._createMapField()..addAll(map); + _values[index] = (fieldInfo as MapFieldInfo)._createMapField() + ..addAll(map); } } else if (fieldInfo.isRepeated) { final PbList? list = _values[index]; diff --git a/protobuf/lib/src/protobuf/field_type.dart b/protobuf/lib/src/protobuf/field_type.dart index ea08419db..4669b4815 100644 --- a/protobuf/lib/src/protobuf/field_type.dart +++ b/protobuf/lib/src/protobuf/field_type.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// @dart=3.10 + // ignore_for_file: constant_identifier_names,non_constant_identifier_names part of 'internal.dart'; diff --git a/protobuf/lib/src/protobuf/generated_message.dart b/protobuf/lib/src/protobuf/generated_message.dart index 79515d2da..dd813c1c7 100644 --- a/protobuf/lib/src/protobuf/generated_message.dart +++ b/protobuf/lib/src/protobuf/generated_message.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// @dart=3.10 + // ignore_for_file: non_constant_identifier_names part of 'internal.dart'; @@ -25,10 +27,19 @@ typedef ValueOfFunc = ProtobufEnum? Function(int value); /// `GeneratedMessage_reservedNames` and should be unlikely to be used in a /// proto file. abstract class GeneratedMessage { - FieldSet? __fieldSet; - - @pragma('dart2js:tryInline') - FieldSet get _fieldSet => __fieldSet!; + // The pragma tells dart2js that the late checks for `__fieldSet` are + // unnecessary. The field is always initialized before use, but dart2js can't + // see that. One problem is that `this.info_` is called before the + // initializing assignment, and potentially one of the many overrides for + // `get:info_` could access the field before it is initialized, or call one of + // the methods that accesses the field. The code generated for the `get:info_` + // methods does not do this, but it is hard to determine from first + // principles. + @pragma('dart2js:late:trust') + late final FieldSet __fieldSet; + + @pragma('dart2js:prefer-inline') + FieldSet get _fieldSet => __fieldSet; GeneratedMessage() { __fieldSet = FieldSet(this, info_); diff --git a/protobuf/lib/src/protobuf/generated_service.dart b/protobuf/lib/src/protobuf/generated_service.dart index fc6feae30..6aad68c37 100644 --- a/protobuf/lib/src/protobuf/generated_service.dart +++ b/protobuf/lib/src/protobuf/generated_service.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// @dart=3.10 + part of 'internal.dart'; /// Server side context. diff --git a/protobuf/lib/src/protobuf/internal.dart b/protobuf/lib/src/protobuf/internal.dart index ed1c0a5b4..4fddeaf32 100644 --- a/protobuf/lib/src/protobuf/internal.dart +++ b/protobuf/lib/src/protobuf/internal.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// @dart=3.10 + /// Runtime library for Dart implementation of [protobufs][1]. /// /// [1]: https://developers.google.com/protocol-buffers @@ -26,7 +28,7 @@ import 'permissive_compare.dart'; import 'type_registry.dart'; import 'utils.dart'; -export 'annotations.dart' show TagNumber, GrpcServiceName; +export 'annotations.dart' show GrpcServiceName, TagNumber; export 'pb_list.dart' show PbList; export 'pb_map.dart' show PbMap; export 'type_registry.dart' show TypeRegistry; diff --git a/protobuf/lib/src/protobuf/json/json.dart b/protobuf/lib/src/protobuf/json/json.dart index 84c87193e..2ad647b30 100644 --- a/protobuf/lib/src/protobuf/json/json.dart +++ b/protobuf/lib/src/protobuf/json/json.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// @dart=3.10 + import 'dart:convert' show base64Decode, base64Encode; import 'package:fixnum/fixnum.dart' show Int64; @@ -276,19 +278,16 @@ dynamic _convertJsonValue( } } expectedType = 'bool (true, false, "true", "false", 1, 0)'; - break; case PbFieldType.BYTES_BIT: if (value is String) { return base64Decode(value); } expectedType = 'Base64 String'; - break; case PbFieldType.STRING_BIT: if (value is String) { return value; } expectedType = 'String'; - break; case PbFieldType.FLOAT_BIT: case PbFieldType.DOUBLE_BIT: // Allow quoted values, although we don't emit them. @@ -300,7 +299,6 @@ dynamic _convertJsonValue( return double.parse(value); } expectedType = 'num or stringified num'; - break; case PbFieldType.ENUM_BIT: // Allow quoted values, although we don't emit them. if (value is String) { @@ -313,14 +311,12 @@ dynamic _convertJsonValue( return meta.decodeEnum(tagNumber, registry, value); } expectedType = 'int or stringified int'; - break; case PbFieldType.INT32_BIT: case PbFieldType.SINT32_BIT: case PbFieldType.SFIXED32_BIT: if (value is int) return value; if (value is String) return int.parse(value); expectedType = 'int or stringified int'; - break; case PbFieldType.UINT32_BIT: case PbFieldType.FIXED32_BIT: int? validatedValue; @@ -331,7 +327,6 @@ dynamic _convertJsonValue( } if (validatedValue != null) return validatedValue; expectedType = 'int or stringified int'; - break; case PbFieldType.INT64_BIT: case PbFieldType.SINT64_BIT: case PbFieldType.UINT64_BIT: @@ -340,7 +335,6 @@ dynamic _convertJsonValue( if (value is int) return Int64(value); if (value is String) return Int64.parseInt(value); expectedType = 'int or stringified int'; - break; case PbFieldType.GROUP_BIT: case PbFieldType.MESSAGE_BIT: if (value is Map) { @@ -350,7 +344,6 @@ dynamic _convertJsonValue( return subMessage; } expectedType = 'nested message or group'; - break; default: throw ArgumentError('Unknown type $fieldType'); } diff --git a/protobuf/lib/src/protobuf/json/json_vm.dart b/protobuf/lib/src/protobuf/json/json_vm.dart index 831756abd..126be2e2b 100644 --- a/protobuf/lib/src/protobuf/json/json_vm.dart +++ b/protobuf/lib/src/protobuf/json/json_vm.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// @dart=3.10 + import 'dart:convert' show jsonDecode, jsonEncode; import '../internal.dart'; diff --git a/protobuf/lib/src/protobuf/json/json_web.dart b/protobuf/lib/src/protobuf/json/json_web.dart index 1912ffd46..494e7bc05 100644 --- a/protobuf/lib/src/protobuf/json/json_web.dart +++ b/protobuf/lib/src/protobuf/json/json_web.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// @dart=3.10 + import 'dart:convert' show base64Decode, base64Encode; import 'dart:js_interop'; import 'dart:js_interop_unsafe'; @@ -174,7 +176,7 @@ JSObject _writeToRawJs(FieldSet fs) { } final unknownJsonData = fs.unknownJsonData; if (unknownJsonData != null) { - unknownJsonData.forEach((key, value) { + unknownJsonData.forEach((String key, Object? value) { result.setProperty(key.toJS, value.jsify()); }); } @@ -216,8 +218,9 @@ void _mergeFromRawJsMap( if (fi == null) { fi = registry?.getExtension(fs.messageName, int.parse(key)); if (fi == null) { - (fs.unknownJsonData ??= {})[key] = - json.getProperty(jsKey).dartify(); + (fs.unknownJsonData ??= {})[key] = json + .getProperty(jsKey) + .dartify(); continue; } } diff --git a/protobuf/lib/src/protobuf/json_parsing_context.dart b/protobuf/lib/src/protobuf/json_parsing_context.dart index 99bdfdfd2..2fec72e51 100644 --- a/protobuf/lib/src/protobuf/json_parsing_context.dart +++ b/protobuf/lib/src/protobuf/json_parsing_context.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// @dart=3.10 + class JsonParsingContext { // A list of indices into maps and lists pointing to the current root. final List _path = []; diff --git a/protobuf/lib/src/protobuf/message_set.dart b/protobuf/lib/src/protobuf/message_set.dart index dfae87708..2d491f817 100644 --- a/protobuf/lib/src/protobuf/message_set.dart +++ b/protobuf/lib/src/protobuf/message_set.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// @dart=3.10 + part of 'internal.dart'; const _messageSetItemsTag = 1; diff --git a/protobuf/lib/src/protobuf/mixins/map_mixin.dart b/protobuf/lib/src/protobuf/mixins/map_mixin.dart index 71b389820..b113b9c82 100644 --- a/protobuf/lib/src/protobuf/mixins/map_mixin.dart +++ b/protobuf/lib/src/protobuf/mixins/map_mixin.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// @dart=3.10 + import '../../../protobuf.dart' show BuilderInfo; /// Note that this class does not claim to implement [Map]. Instead, this needs diff --git a/protobuf/lib/src/protobuf/mixins/well_known.dart b/protobuf/lib/src/protobuf/mixins/well_known.dart index bf63a4342..eb56e5e0a 100644 --- a/protobuf/lib/src/protobuf/mixins/well_known.dart +++ b/protobuf/lib/src/protobuf/mixins/well_known.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// @dart=3.10 + import 'dart:convert'; import 'package:fixnum/fixnum.dart'; @@ -347,8 +349,9 @@ mixin DurationMixin { ); } else { final secondsString = match[1]!; - final seconds = - secondsString == '' ? Int64.ZERO : Int64.parseInt(secondsString); + final seconds = secondsString == '' + ? Int64.ZERO + : Int64.parseInt(secondsString); duration.seconds = seconds; final nanos = int.parse((match[2] ?? '').padRight(9, '0')); duration.nanos = seconds < 0 ? -nanos : nanos; @@ -537,7 +540,7 @@ mixin ListValueMixin implements GeneratedMessage { if (json is List) { final subBuilder = message.info_.subBuilder(_valueFieldTagNumber)!; for (var i = 0; i < json.length; i++) { - final Object element = json[i]; + final Object? element = json[i]; final v = subBuilder() as ValueMixin; context.addListIndex(i); ValueMixin.fromProto3JsonHelper(v, element, typeRegistry, context); diff --git a/protobuf/lib/src/protobuf/pb_list.dart b/protobuf/lib/src/protobuf/pb_list.dart index eed80e2e8..c8bd49359 100644 --- a/protobuf/lib/src/protobuf/pb_list.dart +++ b/protobuf/lib/src/protobuf/pb_list.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// @dart=3.10 + import 'dart:collection' show ListBase; import 'dart:math' as math; diff --git a/protobuf/lib/src/protobuf/pb_map.dart b/protobuf/lib/src/protobuf/pb_map.dart index 00513337d..affd4d908 100644 --- a/protobuf/lib/src/protobuf/pb_map.dart +++ b/protobuf/lib/src/protobuf/pb_map.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// @dart=3.10 + import 'dart:collection' show MapBase; import 'internal.dart'; diff --git a/protobuf/lib/src/protobuf/permissive_compare.dart b/protobuf/lib/src/protobuf/permissive_compare.dart index 7b197ecd6..65e59e256 100644 --- a/protobuf/lib/src/protobuf/permissive_compare.dart +++ b/protobuf/lib/src/protobuf/permissive_compare.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// @dart=3.10 + /// Returns true if [a] and [b] are the same ignoring case and all instances of /// `-` and `_`. /// diff --git a/protobuf/lib/src/protobuf/proto3_json.dart b/protobuf/lib/src/protobuf/proto3_json.dart index 5da053152..d1ad8dce7 100644 --- a/protobuf/lib/src/protobuf/proto3_json.dart +++ b/protobuf/lib/src/protobuf/proto3_json.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// @dart=3.10 + part of 'internal.dart'; // Public because this is called from the mixins library. @@ -178,10 +180,9 @@ Object? _writeToProto3Json(FieldSet fs, TypeRegistry typeRegistry) { ); }); } else if (fieldInfo.isRepeated) { - jsonValue = - (value as PbList) - .map((element) => valueToProto3Json(element, fieldInfo.type)) - .toList(); + jsonValue = (value as PbList) + .map((element) => valueToProto3Json(element, fieldInfo.type)) + .toList(); } else { jsonValue = valueToProto3Json(value, fieldInfo.type); } @@ -330,12 +331,11 @@ void _mergeFromProto3JsonWithContext( case PbFieldType.ENUM_BIT: if (value is String) { // TODO(sigurdm): Do we want to avoid linear search here? Measure... - final result = - context.permissiveEnums - ? fieldInfo.enumValues!.findFirst( - (e) => permissiveCompare(e.name, value), - ) - : fieldInfo.enumValues!.findFirst((e) => e.name == value); + final result = context.permissiveEnums + ? fieldInfo.enumValues!.findFirst( + (e) => permissiveCompare(e.name, value), + ) + : fieldInfo.enumValues!.findFirst((e) => e.name == value); if ((result != null) || context.ignoreUnknownFields) return result; throw context.parseException('Unknown enum value', value); } else if (value is int) { @@ -343,9 +343,9 @@ void _mergeFromProto3JsonWithContext( (context.ignoreUnknownFields ? null : (throw context.parseException( - 'Unknown enum value', - value, - ))); + 'Unknown enum value', + value, + ))); } throw context.parseException( 'Expected enum as a string or integer', diff --git a/protobuf/lib/src/protobuf/protobuf_enum.dart b/protobuf/lib/src/protobuf/protobuf_enum.dart index 5ec61a0a8..62bcd7b5a 100644 --- a/protobuf/lib/src/protobuf/protobuf_enum.dart +++ b/protobuf/lib/src/protobuf/protobuf_enum.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// @dart=3.10 + // ignore_for_file: non_constant_identifier_names part of 'internal.dart'; diff --git a/protobuf/lib/src/protobuf/rpc_client.dart b/protobuf/lib/src/protobuf/rpc_client.dart index 7f091f08a..8c6b723ae 100644 --- a/protobuf/lib/src/protobuf/rpc_client.dart +++ b/protobuf/lib/src/protobuf/rpc_client.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// @dart=3.10 + part of 'internal.dart'; /// Client side context for [RpcClient]s. diff --git a/protobuf/lib/src/protobuf/type_registry.dart b/protobuf/lib/src/protobuf/type_registry.dart index d1b9c89c5..1d9ccf8ab 100644 --- a/protobuf/lib/src/protobuf/type_registry.dart +++ b/protobuf/lib/src/protobuf/type_registry.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// @dart=3.10 + import '../../protobuf.dart'; /// A TypeRegistry is used to resolve Any messages in the proto3 JSON conversion. diff --git a/protobuf/lib/src/protobuf/unknown_field_set.dart b/protobuf/lib/src/protobuf/unknown_field_set.dart index 222d12ace..61dce32d8 100644 --- a/protobuf/lib/src/protobuf/unknown_field_set.dart +++ b/protobuf/lib/src/protobuf/unknown_field_set.dart @@ -2,12 +2,14 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// @dart=3.10 + part of 'internal.dart'; /// A set of unknown fields in a [GeneratedMessage]. class UnknownFieldSet { - static final UnknownFieldSet emptyUnknownFieldSet = - UnknownFieldSet().._markReadOnly(); + static final UnknownFieldSet emptyUnknownFieldSet = UnknownFieldSet() + .._markReadOnly(); final Map _fields; @@ -222,9 +224,8 @@ class UnknownFieldSet { writeIndent(out, indentLevel); out.write('$tag: '); try { - final ufs = - UnknownFieldSet() - ..mergeFromCodedBufferReader(CodedBufferReader(value)); + final ufs = UnknownFieldSet() + ..mergeFromCodedBufferReader(CodedBufferReader(value)); out.write('{\n'); ufs.writeTextFormat(out, indentLevel + 1); writeIndent(out, indentLevel); @@ -265,7 +266,7 @@ class UnknownFieldSet { } UnknownFieldSet _deepCopy() { - Map newFields = {}; + final newFields = {}; for (final entry in _fields.entries) { final key = entry.key; final value = entry.value; @@ -404,12 +405,12 @@ class UnknownFieldSetField { } UnknownFieldSetField _deepCopy() { - final List> newLengthDelimited = List.from(_lengthDelimited); - final List newVarints = List.from(_varints); - final List newFixed32s = List.from(_fixed32s); - final List newFixed64s = List.from(_fixed64s); + final newLengthDelimited = List>.from(_lengthDelimited); + final newVarints = List.from(_varints); + final newFixed32s = List.from(_fixed32s); + final newFixed64s = List.from(_fixed64s); - final List newGroups = []; + final newGroups = []; for (final group in _groups) { newGroups.add(group._deepCopy()); } diff --git a/protobuf/lib/src/protobuf/unpack.dart b/protobuf/lib/src/protobuf/unpack.dart index 08d547606..e101d40c1 100644 --- a/protobuf/lib/src/protobuf/unpack.dart +++ b/protobuf/lib/src/protobuf/unpack.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// @dart=3.10 + part of 'internal.dart'; /// Unpacks the message in [value] into [instance]. diff --git a/protobuf/lib/src/protobuf/utils.dart b/protobuf/lib/src/protobuf/utils.dart index e52440df3..109a51d81 100644 --- a/protobuf/lib/src/protobuf/utils.dart +++ b/protobuf/lib/src/protobuf/utils.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// @dart=3.10 + import 'package:fixnum/fixnum.dart' show Int64; import 'internal.dart'; diff --git a/protobuf/lib/src/protobuf/wire_format.dart b/protobuf/lib/src/protobuf/wire_format.dart index 375ee4b2d..d7347e0ac 100644 --- a/protobuf/lib/src/protobuf/wire_format.dart +++ b/protobuf/lib/src/protobuf/wire_format.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// @dart=3.10 + // ignore_for_file: constant_identifier_names part of 'internal.dart'; From 3159f08fbd567fc3846a5342987ca132f3a72f6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20A=C4=9Facan?= Date: Fri, 14 Nov 2025 12:34:05 +0000 Subject: [PATCH 2/4] Add pragmas to tests --- protobuf/test/builder_info_test.dart | 2 + protobuf/test/codec_test.dart | 9 ++- protobuf/test/coded_buffer_reader_test.dart | 2 + protobuf/test/dummy_field_test.dart | 2 + protobuf/test/json_test.dart | 18 ++--- protobuf/test/json_vm_test.dart | 2 + protobuf/test/list_equality_test.dart | 30 ++++--- protobuf/test/list_test.dart | 2 + protobuf/test/map_mixin_test.dart | 2 + protobuf/test/message_test.dart | 59 +++++++------- protobuf/test/mock_util.dart | 2 + protobuf/test/permissive_compare_test.dart | 2 + protobuf/test/readonly_message_test.dart | 86 +++++++++------------ protobuf/test/test_util.dart | 2 + 14 files changed, 112 insertions(+), 108 deletions(-) diff --git a/protobuf/test/builder_info_test.dart b/protobuf/test/builder_info_test.dart index d3356cbe3..c89bab702 100644 --- a/protobuf/test/builder_info_test.dart +++ b/protobuf/test/builder_info_test.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// @dart=3.10 + import 'package:protobuf/protobuf.dart'; import 'package:test/test.dart'; diff --git a/protobuf/test/codec_test.dart b/protobuf/test/codec_test.dart index 215e90d7f..4db493956 100644 --- a/protobuf/test/codec_test.dart +++ b/protobuf/test/codec_test.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// @dart=3.10 + import 'dart:typed_data'; import 'package:protobuf/protobuf.dart'; @@ -177,10 +179,9 @@ void main() { // Compare two doubles, where NaNs and same-sign inifinities compare equal. // For normal values, use equals. - Matcher doubleEquals(double expected) => - expected.isNaN - ? predicate((x) => x.isNaN, 'NaN expected') - : equals(expected); + Matcher doubleEquals(double expected) => expected.isNaN + ? predicate((x) => x.isNaN, 'NaN expected') + : equals(expected); List dataToBytes(ByteData byteData) => Uint8List.view(byteData.buffer); final floatToBytes = convertToBytes(PbFieldType.OF); diff --git a/protobuf/test/coded_buffer_reader_test.dart b/protobuf/test/coded_buffer_reader_test.dart index 9f83d92e4..bd4f87767 100644 --- a/protobuf/test/coded_buffer_reader_test.dart +++ b/protobuf/test/coded_buffer_reader_test.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// @dart=3.10 + import 'dart:typed_data'; import 'package:protobuf/protobuf.dart'; diff --git a/protobuf/test/dummy_field_test.dart b/protobuf/test/dummy_field_test.dart index 7867c8569..bb624be39 100644 --- a/protobuf/test/dummy_field_test.dart +++ b/protobuf/test/dummy_field_test.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// @dart=3.10 + import 'package:protobuf/protobuf.dart'; import 'package:test/test.dart'; diff --git a/protobuf/test/json_test.dart b/protobuf/test/json_test.dart index bf4097eb9..ae563b8f7 100644 --- a/protobuf/test/json_test.dart +++ b/protobuf/test/json_test.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// @dart=3.10 + // Basic smoke tests for the GeneratedMessage JSON API. // // There are more JSON tests in the dart-protoc-plugin package. @@ -128,10 +130,9 @@ void main() { test('testFrozentInt64JsonEncoding', () { final value = Int64.parseInt('1234567890123456789'); - final frozen = - T() - ..int64 = value - ..freeze(); + final frozen = T() + ..int64 = value + ..freeze(); final encoded = frozen.writeToJsonMap(); expect(encoded['5'], '$value'); final decoded = T()..mergeFromJsonMap(encoded); @@ -187,11 +188,10 @@ void main() { }); } -T makeTestJson() => - T() - ..val = 123 - ..str = 'hello' - ..int32s.addAll([1, 2, 3]); +T makeTestJson() => T() + ..val = 123 + ..str = 'hello' + ..int32s.addAll([1, 2, 3]); void checkJsonMap(Map m, {Map? unknownFields}) { expect(m.length, 3 + (unknownFields?.length ?? 0)); diff --git a/protobuf/test/json_vm_test.dart b/protobuf/test/json_vm_test.dart index bab4bd37a..ef2898671 100644 --- a/protobuf/test/json_vm_test.dart +++ b/protobuf/test/json_vm_test.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// @dart=3.10 + // VM-specific smoke tests for the GeneratedMessage JSON API. // // These tests will be skipped on js, as the dart2js platform diff --git a/protobuf/test/list_equality_test.dart b/protobuf/test/list_equality_test.dart index 00adce0a4..87bc7a133 100644 --- a/protobuf/test/list_equality_test.dart +++ b/protobuf/test/list_equality_test.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// @dart=3.10 + // Test for ensuring that protobuf lists compare using value semantics. import 'package:test/test.dart'; @@ -28,14 +30,12 @@ void main() { }); test('non-empty frozen lists compare as equal', () { - final first = - T() - ..int32s.add(1) - ..freeze(); - final second = - T() - ..int32s.add(1) - ..freeze(); + final first = T() + ..int32s.add(1) + ..freeze(); + final second = T() + ..int32s.add(1) + ..freeze(); expect(first.int32s == second.int32s, isTrue); }); @@ -46,14 +46,12 @@ void main() { }); test('different frozen lists do not compare as equal', () { - final first = - T() - ..int32s.add(1) - ..freeze(); - final second = - T() - ..int32s.add(2) - ..freeze(); + final first = T() + ..int32s.add(1) + ..freeze(); + final second = T() + ..int32s.add(2) + ..freeze(); expect(first.int32s == second.int32s, isFalse); }); } diff --git a/protobuf/test/list_test.dart b/protobuf/test/list_test.dart index 23e995100..7415ee77e 100644 --- a/protobuf/test/list_test.dart +++ b/protobuf/test/list_test.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// @dart=3.10 + import 'package:fixnum/fixnum.dart'; import 'package:protobuf/protobuf.dart'; import 'package:test/test.dart'; diff --git a/protobuf/test/map_mixin_test.dart b/protobuf/test/map_mixin_test.dart index a02180934..bd3b4c212 100644 --- a/protobuf/test/map_mixin_test.dart +++ b/protobuf/test/map_mixin_test.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// @dart=3.10 + // Unit tests for PbMapMixin. // There are more tests in the dart-protoc-plugin package. diff --git a/protobuf/test/message_test.dart b/protobuf/test/message_test.dart index 657bf86d6..9fd5ed857 100644 --- a/protobuf/test/message_test.dart +++ b/protobuf/test/message_test.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// @dart=3.10 + // Tests for GeneratedMessage methods. import 'package:fixnum/fixnum.dart' show Int64; @@ -65,16 +67,15 @@ Matcher throwsError(String expectedMessage) => throwsA( ); void main() { - final recProto = - Rec() - ..val = 123 - ..str = 'a\n\r\t"\\b' - ..bytes = [0, 1, 2, 127, 128, 255] - ..child = (Rec()..val = 456) - ..int32s.addAll([1, 2, 3]) - ..int64 = Int64.MAX_VALUE - ..stringMap['key "1"'] = '''value\n1''' - ..stringMap['key 2'] = 'value 2'; + final recProto = Rec() + ..val = 123 + ..str = 'a\n\r\t"\\b' + ..bytes = [0, 1, 2, 127, 128, 255] + ..child = (Rec()..val = 456) + ..int32s.addAll([1, 2, 3]) + ..int64 = Int64.MAX_VALUE + ..stringMap['key "1"'] = '''value\n1''' + ..stringMap['key 2'] = 'value 2'; test('getField with invalid tag throws exception', () { final r = Rec(); @@ -91,15 +92,13 @@ void main() { }); test('operator== and hashCode works for frozen message', () { - final a = - Rec() - ..val = 123 - ..int32s.addAll([1, 2, 3]) - ..freeze(); - final b = - Rec() - ..val = 123 - ..int32s.addAll([1, 2, 3]); + final a = Rec() + ..val = 123 + ..int32s.addAll([1, 2, 3]) + ..freeze(); + final b = Rec() + ..val = 123 + ..int32s.addAll([1, 2, 3]); expect(a.hashCode, b.hashCode); expect(a == b, true); @@ -107,11 +106,10 @@ void main() { }); test('isFrozen works', () { - final a = - Rec() - ..val = 123 - ..int32s.addAll([1, 2, 3]) - ..child = (Rec()..val = 100); + final a = Rec() + ..val = 123 + ..int32s.addAll([1, 2, 3]) + ..child = (Rec()..val = 100); expect(a.isFrozen, false); a.child.freeze(); expect(a.child.isFrozen, true); @@ -165,13 +163,12 @@ void main() { }); test('toTextFormatString handles extensions fields', () { - final a = - Rec() - ..val = 42 - ..setExtension(Ext.count, 123) - ..addExtension(Ext.items, 'a') - ..addExtension(Ext.items, 'b"c') - ..setExtension(Ext.data, [0, 1, 2, 127, 128, 255]); + final a = Rec() + ..val = 42 + ..setExtension(Ext.count, 123) + ..addExtension(Ext.items, 'a') + ..addExtension(Ext.items, 'b"c') + ..setExtension(Ext.data, [0, 1, 2, 127, 128, 255]); expect(a.toTextFormat(), _expectedTextProtoWithExtensions); }); diff --git a/protobuf/test/mock_util.dart b/protobuf/test/mock_util.dart index 167d1378e..c7a76fd1f 100644 --- a/protobuf/test/mock_util.dart +++ b/protobuf/test/mock_util.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// @dart=3.10 + import 'package:collection/collection.dart'; import 'package:fixnum/fixnum.dart' show Int64; import 'package:protobuf/protobuf.dart' diff --git a/protobuf/test/permissive_compare_test.dart b/protobuf/test/permissive_compare_test.dart index 5571f6844..8dd1f719d 100644 --- a/protobuf/test/permissive_compare_test.dart +++ b/protobuf/test/permissive_compare_test.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// @dart=3.10 + import 'package:protobuf/src/protobuf/permissive_compare.dart'; import 'package:test/test.dart'; diff --git a/protobuf/test/readonly_message_test.dart b/protobuf/test/readonly_message_test.dart index cf5b37d59..0f468e3e9 100644 --- a/protobuf/test/readonly_message_test.dart +++ b/protobuf/test/readonly_message_test.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// @dart=3.10 + import 'package:protobuf/protobuf.dart' show BuilderInfo, GeneratedMessage, PbFieldType, UnknownFieldSetField; import 'package:test/test.dart'; @@ -21,11 +23,10 @@ class Rec extends GeneratedMessage { Rec createEmptyInstance() => Rec(); @override - BuilderInfo info_ = - BuilderInfo('rec') - ..a(1, 'value', PbFieldType.O3) - ..pc(2, 'sub', PbFieldType.PM, subBuilder: Rec.create) - ..p(10, 'ints', PbFieldType.P3); + BuilderInfo info_ = BuilderInfo('rec') + ..a(1, 'value', PbFieldType.O3) + ..pc(2, 'sub', PbFieldType.PM, subBuilder: Rec.create) + ..p(10, 'ints', PbFieldType.P3); int get value => $_get(0, 0); set value(int v) { @@ -96,10 +97,9 @@ void main() { () => Rec.getDefault().sub.add(Rec.create()), throwsUnsupportedError(contains('add')), ); - var r = - Rec.create() - ..ints.add(10) - ..freeze(); + var r = Rec.create() + ..ints.add(10) + ..freeze(); expect( () => r.ints.clear(), throwsUnsupportedError(equals("'clear' on a read-only list")), @@ -113,10 +113,9 @@ void main() { throwsUnsupportedError(equals("'add' on a read-only list")), ); - r = - Rec.create() - ..sub.add(Rec.create()) - ..freeze(); + r = Rec.create() + ..sub.add(Rec.create()) + ..freeze(); expect( () => r.sub.add(Rec.create()), throwsUnsupportedError(equals("'add' on a read-only list")), @@ -129,10 +128,9 @@ void main() { test("can't modify sub-messages on a read-only message", () { final subMessage = Rec.create()..value = 1; - final r = - Rec.create() - ..sub.add(Rec.create()..sub.add(subMessage)) - ..freeze(); + final r = Rec.create() + ..sub.add(Rec.create()..sub.add(subMessage)) + ..freeze(); expect(r.sub[0].sub[0].value, 1); expect( () => subMessage.value = 2, @@ -154,10 +152,9 @@ void main() { }); test('can rebuild a frozen message with merge', () { - final orig = - Rec.create() - ..value = 10 - ..freeze(); + final orig = Rec.create() + ..value = 10 + ..freeze(); final rebuilt = orig.copyWith((m) => m.mergeFromJson('{"1": 7}')); expect(identical(orig, rebuilt), false); expect(orig.value, 10); @@ -165,10 +162,9 @@ void main() { }); test('can set a field while rebuilding a frozen message', () { - final orig = - Rec.create() - ..value = 10 - ..freeze(); + final orig = Rec.create() + ..value = 10 + ..freeze(); final rebuilt = orig.copyWith((m) => m.value = 7); expect(identical(orig, rebuilt), false); expect(orig.value, 10); @@ -176,10 +172,9 @@ void main() { }); test('can clear while rebuilding a frozen message', () { - final orig = - Rec.create() - ..value = 10 - ..freeze(); + final orig = Rec.create() + ..value = 10 + ..freeze(); final rebuilt = orig.copyWith((m) => m.clear()); expect(identical(orig, rebuilt), false); expect(orig.value, 10); @@ -188,10 +183,9 @@ void main() { }); test('can clear a field while rebuilding a frozen message', () { - final orig = - Rec.create() - ..value = 10 - ..freeze(); + final orig = Rec.create() + ..value = 10 + ..freeze(); final rebuilt = orig.copyWith((m) => m.clearField(1)); expect(identical(orig, rebuilt), false); expect(orig.value, 10); @@ -200,10 +194,9 @@ void main() { }); test('can modify repeated fields while rebuilding a frozen message', () { - var orig = - Rec.create() - ..ints.add(10) - ..freeze(); + var orig = Rec.create() + ..ints.add(10) + ..freeze(); var rebuilt = orig.copyWith((m) => m.ints.add(12)); expect(identical(orig, rebuilt), false); expect(orig.ints, [10]); @@ -217,10 +210,9 @@ void main() { expect(orig.ints, [10]); expect(rebuilt.ints, [2]); - orig = - Rec.create() - ..sub.add(Rec.create()) - ..freeze(); + orig = Rec.create() + ..sub.add(Rec.create()) + ..freeze(); rebuilt = orig.copyWith((m) => m.sub.add(Rec.create())); expect(orig.sub.length, 1); expect(rebuilt.sub.length, 2); @@ -228,10 +220,9 @@ void main() { test('cannot modify sub-messages while rebuilding a frozen message', () { final subMessage = Rec.create()..value = 1; - final orig = - Rec.create() - ..sub.add(Rec.create()..sub.add(subMessage)) - ..freeze(); + final orig = Rec.create() + ..sub.add(Rec.create()..sub.add(subMessage)) + ..freeze(); final rebuilt = orig.copyWith((m) { expect( @@ -257,9 +248,8 @@ void main() { }); test('can modify unknown fields while rebuilding a frozen message', () { - final orig = - Rec.create() - ..unknownFields.addField(20, UnknownFieldSetField()..fixed32s.add(1)); + final orig = Rec.create() + ..unknownFields.addField(20, UnknownFieldSetField()..fixed32s.add(1)); final rebuilt = orig.copyWith((m) => m.unknownFields.clear()); expect(orig.unknownFields.hasField(20), true); expect(rebuilt.unknownFields.hasField(20), false); diff --git a/protobuf/test/test_util.dart b/protobuf/test/test_util.dart index 4af608c67..bdeed37e9 100644 --- a/protobuf/test/test_util.dart +++ b/protobuf/test/test_util.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// @dart=3.10 + import 'package:fixnum/fixnum.dart'; import 'package:test/test.dart'; From 05722accb94b5f23e379bd65d4da219c257c0bd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20A=C4=9Facan?= Date: Mon, 17 Nov 2025 13:55:40 +0000 Subject: [PATCH 3/4] Use 3.7 formatting --- protobuf/lib/meta.dart | 2 +- protobuf/lib/protobuf.dart | 2 +- protobuf/lib/src/protobuf/annotations.dart | 2 +- protobuf/lib/src/protobuf/builder_info.dart | 19 ++-- protobuf/lib/src/protobuf/coded_buffer.dart | 2 +- .../lib/src/protobuf/coded_buffer_reader.dart | 2 +- .../lib/src/protobuf/coded_buffer_writer.dart | 46 +++++----- protobuf/lib/src/protobuf/consts.dart | 2 +- protobuf/lib/src/protobuf/exceptions.dart | 2 +- protobuf/lib/src/protobuf/extension.dart | 2 +- .../lib/src/protobuf/extension_field_set.dart | 2 +- .../lib/src/protobuf/extension_registry.dart | 6 +- protobuf/lib/src/protobuf/field_error.dart | 2 +- protobuf/lib/src/protobuf/field_info.dart | 2 +- protobuf/lib/src/protobuf/field_set.dart | 13 +-- protobuf/lib/src/protobuf/field_type.dart | 2 +- .../lib/src/protobuf/generated_message.dart | 2 +- .../lib/src/protobuf/generated_service.dart | 2 +- protobuf/lib/src/protobuf/internal.dart | 2 +- protobuf/lib/src/protobuf/json/json.dart | 2 +- protobuf/lib/src/protobuf/json/json_vm.dart | 2 +- protobuf/lib/src/protobuf/json/json_web.dart | 7 +- .../src/protobuf/json_parsing_context.dart | 2 +- protobuf/lib/src/protobuf/message_set.dart | 2 +- .../lib/src/protobuf/mixins/map_mixin.dart | 2 +- .../lib/src/protobuf/mixins/well_known.dart | 7 +- protobuf/lib/src/protobuf/pb_list.dart | 2 +- protobuf/lib/src/protobuf/pb_map.dart | 2 +- .../lib/src/protobuf/permissive_compare.dart | 2 +- protobuf/lib/src/protobuf/proto3_json.dart | 26 +++--- protobuf/lib/src/protobuf/protobuf_enum.dart | 2 +- protobuf/lib/src/protobuf/rpc_client.dart | 2 +- protobuf/lib/src/protobuf/type_registry.dart | 2 +- .../lib/src/protobuf/unknown_field_set.dart | 11 +-- protobuf/lib/src/protobuf/unpack.dart | 2 +- protobuf/lib/src/protobuf/utils.dart | 2 +- protobuf/lib/src/protobuf/wire_format.dart | 2 +- protobuf/test/builder_info_test.dart | 2 +- protobuf/test/codec_test.dart | 9 +- protobuf/test/coded_buffer_reader_test.dart | 2 +- protobuf/test/dummy_field_test.dart | 2 +- protobuf/test/json_test.dart | 18 ++-- protobuf/test/json_vm_test.dart | 2 +- protobuf/test/list_equality_test.dart | 30 ++++--- protobuf/test/list_test.dart | 2 +- protobuf/test/map_mixin_test.dart | 2 +- protobuf/test/message_test.dart | 59 +++++++------ protobuf/test/mock_util.dart | 2 +- protobuf/test/permissive_compare_test.dart | 2 +- protobuf/test/readonly_message_test.dart | 86 +++++++++++-------- protobuf/test/test_util.dart | 2 +- 51 files changed, 219 insertions(+), 194 deletions(-) diff --git a/protobuf/lib/meta.dart b/protobuf/lib/meta.dart index 573b1853e..b61e4045f 100644 --- a/protobuf/lib/meta.dart +++ b/protobuf/lib/meta.dart @@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=3.10 +// @dart=3.7 /// Provides metadata about GeneratedMessage and ProtobufEnum to /// dart-protoc-plugin. (Experimental API; subject to change.) diff --git a/protobuf/lib/protobuf.dart b/protobuf/lib/protobuf.dart index e473e449c..2bdefa336 100644 --- a/protobuf/lib/protobuf.dart +++ b/protobuf/lib/protobuf.dart @@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=3.10 +// @dart=3.7 /// Runtime library for Dart implementation of [protobufs][1]. /// diff --git a/protobuf/lib/src/protobuf/annotations.dart b/protobuf/lib/src/protobuf/annotations.dart index 463a87044..6c92225f4 100644 --- a/protobuf/lib/src/protobuf/annotations.dart +++ b/protobuf/lib/src/protobuf/annotations.dart @@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=3.10 +// @dart=3.7 /// Annotation for marking accessors that belong together. class TagNumber { diff --git a/protobuf/lib/src/protobuf/builder_info.dart b/protobuf/lib/src/protobuf/builder_info.dart index 93475d842..56400e7dc 100644 --- a/protobuf/lib/src/protobuf/builder_info.dart +++ b/protobuf/lib/src/protobuf/builder_info.dart @@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=3.10 +// @dart=3.7 part of 'internal.dart'; @@ -563,12 +563,10 @@ class BuilderInfo { } List _computeSortedByTag() => - // Code generator inserts fields in tag order, but it's possible for - // user-written code to insert unordered. - List.from( - fieldInfo.values, - growable: false, - )..sort((FieldInfo a, FieldInfo b) => a.tagNumber.compareTo(b.tagNumber)); + // Code generator inserts fields in tag order, but it's possible for + // user-written code to insert unordered. + List.from(fieldInfo.values, growable: false) + ..sort((FieldInfo a, FieldInfo b) => a.tagNumber.compareTo(b.tagNumber)); GeneratedMessage _makeEmptyMessage( int tagNumber, @@ -576,9 +574,10 @@ class BuilderInfo { ) { var subBuilderFunc = subBuilder(tagNumber); if (subBuilderFunc == null && extensionRegistry != null) { - subBuilderFunc = extensionRegistry - .getExtension(qualifiedMessageName, tagNumber)! - .subBuilder; + subBuilderFunc = + extensionRegistry + .getExtension(qualifiedMessageName, tagNumber)! + .subBuilder; } return subBuilderFunc!(); } diff --git a/protobuf/lib/src/protobuf/coded_buffer.dart b/protobuf/lib/src/protobuf/coded_buffer.dart index 7c39f25a9..e21e7c504 100644 --- a/protobuf/lib/src/protobuf/coded_buffer.dart +++ b/protobuf/lib/src/protobuf/coded_buffer.dart @@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=3.10 +// @dart=3.7 part of 'internal.dart'; diff --git a/protobuf/lib/src/protobuf/coded_buffer_reader.dart b/protobuf/lib/src/protobuf/coded_buffer_reader.dart index c25a1f3d9..266fe15bc 100644 --- a/protobuf/lib/src/protobuf/coded_buffer_reader.dart +++ b/protobuf/lib/src/protobuf/coded_buffer_reader.dart @@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=3.10 +// @dart=3.7 part of 'internal.dart'; diff --git a/protobuf/lib/src/protobuf/coded_buffer_writer.dart b/protobuf/lib/src/protobuf/coded_buffer_writer.dart index 5149637d6..cd9567ea4 100644 --- a/protobuf/lib/src/protobuf/coded_buffer_writer.dart +++ b/protobuf/lib/src/protobuf/coded_buffer_writer.dart @@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=3.10 +// @dart=3.7 // ignore_for_file: constant_identifier_names @@ -155,9 +155,8 @@ class CodedBufferWriter { // Copy at most `bytesToCopy` bytes from the current chunk. final leftInChunk = bytesInChunk - chunkPos; - final bytesToCopyFromChunk = leftInChunk > bytesToCopy - ? bytesToCopy - : leftInChunk; + final bytesToCopyFromChunk = + leftInChunk > bytesToCopy ? bytesToCopy : leftInChunk; buffer.setRange( outPos, outPos + bytesToCopyFromChunk, @@ -487,25 +486,26 @@ class CodedBufferWriter { static const _MESSAGE_BIT_INDEX = 20; /// Mapping from value types to wire-types indexed by _valueTypeIndex(...). - static final Uint8List _wireTypes = Uint8List(32) - ..[_BOOL_BIT_INDEX] = WIRETYPE_VARINT - ..[_BYTES_BIT_INDEX] = WIRETYPE_LENGTH_DELIMITED - ..[_STRING_BIT_INDEX] = WIRETYPE_LENGTH_DELIMITED - ..[_DOUBLE_BIT_INDEX] = WIRETYPE_FIXED64 - ..[_FLOAT_BIT_INDEX] = WIRETYPE_FIXED32 - ..[_ENUM_BIT_INDEX] = WIRETYPE_VARINT - ..[_GROUP_BIT_INDEX] = WIRETYPE_START_GROUP - ..[_INT32_BIT_INDEX] = WIRETYPE_VARINT - ..[_INT64_BIT_INDEX] = WIRETYPE_VARINT - ..[_SINT32_BIT_INDEX] = WIRETYPE_VARINT - ..[_SINT64_BIT_INDEX] = WIRETYPE_VARINT - ..[_UINT32_BIT_INDEX] = WIRETYPE_VARINT - ..[_UINT64_BIT_INDEX] = WIRETYPE_VARINT - ..[_FIXED32_BIT_INDEX] = WIRETYPE_FIXED32 - ..[_FIXED64_BIT_INDEX] = WIRETYPE_FIXED64 - ..[_SFIXED32_BIT_INDEX] = WIRETYPE_FIXED32 - ..[_SFIXED64_BIT_INDEX] = WIRETYPE_FIXED64 - ..[_MESSAGE_BIT_INDEX] = WIRETYPE_LENGTH_DELIMITED; + static final Uint8List _wireTypes = + Uint8List(32) + ..[_BOOL_BIT_INDEX] = WIRETYPE_VARINT + ..[_BYTES_BIT_INDEX] = WIRETYPE_LENGTH_DELIMITED + ..[_STRING_BIT_INDEX] = WIRETYPE_LENGTH_DELIMITED + ..[_DOUBLE_BIT_INDEX] = WIRETYPE_FIXED64 + ..[_FLOAT_BIT_INDEX] = WIRETYPE_FIXED32 + ..[_ENUM_BIT_INDEX] = WIRETYPE_VARINT + ..[_GROUP_BIT_INDEX] = WIRETYPE_START_GROUP + ..[_INT32_BIT_INDEX] = WIRETYPE_VARINT + ..[_INT64_BIT_INDEX] = WIRETYPE_VARINT + ..[_SINT32_BIT_INDEX] = WIRETYPE_VARINT + ..[_SINT64_BIT_INDEX] = WIRETYPE_VARINT + ..[_UINT32_BIT_INDEX] = WIRETYPE_VARINT + ..[_UINT64_BIT_INDEX] = WIRETYPE_VARINT + ..[_FIXED32_BIT_INDEX] = WIRETYPE_FIXED32 + ..[_FIXED64_BIT_INDEX] = WIRETYPE_FIXED64 + ..[_SFIXED32_BIT_INDEX] = WIRETYPE_FIXED32 + ..[_SFIXED64_BIT_INDEX] = WIRETYPE_FIXED64 + ..[_MESSAGE_BIT_INDEX] = WIRETYPE_LENGTH_DELIMITED; } int _encodeZigZag32(int value) => (value << 1) ^ (value >> 31); diff --git a/protobuf/lib/src/protobuf/consts.dart b/protobuf/lib/src/protobuf/consts.dart index 473acafd7..ad45cc474 100644 --- a/protobuf/lib/src/protobuf/consts.dart +++ b/protobuf/lib/src/protobuf/consts.dart @@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=3.10 +// @dart=3.7 /// Constant string value of `double.infinity.toString()` and the infinity /// value recognized by `double.parse(..)`. diff --git a/protobuf/lib/src/protobuf/exceptions.dart b/protobuf/lib/src/protobuf/exceptions.dart index 1825efb86..0c90f4249 100644 --- a/protobuf/lib/src/protobuf/exceptions.dart +++ b/protobuf/lib/src/protobuf/exceptions.dart @@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=3.10 +// @dart=3.7 const _truncatedMessageText = ''' While parsing a protocol message, the input ended unexpectedly diff --git a/protobuf/lib/src/protobuf/extension.dart b/protobuf/lib/src/protobuf/extension.dart index b04eb3665..66fdb7130 100644 --- a/protobuf/lib/src/protobuf/extension.dart +++ b/protobuf/lib/src/protobuf/extension.dart @@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=3.10 +// @dart=3.7 part of 'internal.dart'; diff --git a/protobuf/lib/src/protobuf/extension_field_set.dart b/protobuf/lib/src/protobuf/extension_field_set.dart index ae179f4e9..131cb5d35 100644 --- a/protobuf/lib/src/protobuf/extension_field_set.dart +++ b/protobuf/lib/src/protobuf/extension_field_set.dart @@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=3.10 +// @dart=3.7 part of 'internal.dart'; diff --git a/protobuf/lib/src/protobuf/extension_registry.dart b/protobuf/lib/src/protobuf/extension_registry.dart index bb5ba4040..6ec997f07 100644 --- a/protobuf/lib/src/protobuf/extension_registry.dart +++ b/protobuf/lib/src/protobuf/extension_registry.dart @@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=3.10 +// @dart=3.7 part of 'internal.dart'; @@ -119,8 +119,8 @@ T _reparseMessage( if (itemList != null) { for (final group in itemList.groups) { - final typeId = group._fields[_messageSetItemTypeIdTag]!.varints[0] - .toInt(); + final typeId = + group._fields[_messageSetItemTypeIdTag]!.varints[0].toInt(); if (extensionRegistry.getExtension( message.info_.qualifiedMessageName, typeId, diff --git a/protobuf/lib/src/protobuf/field_error.dart b/protobuf/lib/src/protobuf/field_error.dart index d77f9182e..a1dc40068 100644 --- a/protobuf/lib/src/protobuf/field_error.dart +++ b/protobuf/lib/src/protobuf/field_error.dart @@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=3.10 +// @dart=3.7 part of 'internal.dart'; diff --git a/protobuf/lib/src/protobuf/field_info.dart b/protobuf/lib/src/protobuf/field_info.dart index c9f816ca7..8abb5d394 100644 --- a/protobuf/lib/src/protobuf/field_info.dart +++ b/protobuf/lib/src/protobuf/field_info.dart @@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=3.10 +// @dart=3.7 part of 'internal.dart'; diff --git a/protobuf/lib/src/protobuf/field_set.dart b/protobuf/lib/src/protobuf/field_set.dart index 223c0b804..65fc10e63 100644 --- a/protobuf/lib/src/protobuf/field_set.dart +++ b/protobuf/lib/src/protobuf/field_set.dart @@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=3.10 +// @dart=3.7 part of 'internal.dart'; @@ -912,9 +912,10 @@ class FieldSet { } if (otherFi.isGroupOrMessage) { - final currentFi = isExtension - ? _ensureExtensions()._getFieldOrNull(fi as Extension) - : _values[fi.index!]; + final currentFi = + isExtension + ? _ensureExtensions()._getFieldOrNull(fi as Extension) + : _values[fi.index!]; final GeneratedMessage msg = fieldValue; if (currentFi == null) { @@ -999,8 +1000,8 @@ class FieldSet { if (fieldInfo.isMapField) { final PbMap? map = _values[index]; if (map != null) { - _values[index] = (fieldInfo as MapFieldInfo)._createMapField() - ..addAll(map); + _values[index] = + (fieldInfo as MapFieldInfo)._createMapField()..addAll(map); } } else if (fieldInfo.isRepeated) { final PbList? list = _values[index]; diff --git a/protobuf/lib/src/protobuf/field_type.dart b/protobuf/lib/src/protobuf/field_type.dart index 4669b4815..f671ff2da 100644 --- a/protobuf/lib/src/protobuf/field_type.dart +++ b/protobuf/lib/src/protobuf/field_type.dart @@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=3.10 +// @dart=3.7 // ignore_for_file: constant_identifier_names,non_constant_identifier_names part of 'internal.dart'; diff --git a/protobuf/lib/src/protobuf/generated_message.dart b/protobuf/lib/src/protobuf/generated_message.dart index dd813c1c7..702346b76 100644 --- a/protobuf/lib/src/protobuf/generated_message.dart +++ b/protobuf/lib/src/protobuf/generated_message.dart @@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=3.10 +// @dart=3.7 // ignore_for_file: non_constant_identifier_names diff --git a/protobuf/lib/src/protobuf/generated_service.dart b/protobuf/lib/src/protobuf/generated_service.dart index 6aad68c37..caeff6329 100644 --- a/protobuf/lib/src/protobuf/generated_service.dart +++ b/protobuf/lib/src/protobuf/generated_service.dart @@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=3.10 +// @dart=3.7 part of 'internal.dart'; diff --git a/protobuf/lib/src/protobuf/internal.dart b/protobuf/lib/src/protobuf/internal.dart index 4fddeaf32..f7cbc0c33 100644 --- a/protobuf/lib/src/protobuf/internal.dart +++ b/protobuf/lib/src/protobuf/internal.dart @@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=3.10 +// @dart=3.7 /// Runtime library for Dart implementation of [protobufs][1]. /// diff --git a/protobuf/lib/src/protobuf/json/json.dart b/protobuf/lib/src/protobuf/json/json.dart index 2ad647b30..39a65a3e7 100644 --- a/protobuf/lib/src/protobuf/json/json.dart +++ b/protobuf/lib/src/protobuf/json/json.dart @@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=3.10 +// @dart=3.7 import 'dart:convert' show base64Decode, base64Encode; diff --git a/protobuf/lib/src/protobuf/json/json_vm.dart b/protobuf/lib/src/protobuf/json/json_vm.dart index 126be2e2b..24e5fab7e 100644 --- a/protobuf/lib/src/protobuf/json/json_vm.dart +++ b/protobuf/lib/src/protobuf/json/json_vm.dart @@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=3.10 +// @dart=3.7 import 'dart:convert' show jsonDecode, jsonEncode; diff --git a/protobuf/lib/src/protobuf/json/json_web.dart b/protobuf/lib/src/protobuf/json/json_web.dart index 494e7bc05..8a4b134a7 100644 --- a/protobuf/lib/src/protobuf/json/json_web.dart +++ b/protobuf/lib/src/protobuf/json/json_web.dart @@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=3.10 +// @dart=3.7 import 'dart:convert' show base64Decode, base64Encode; import 'dart:js_interop'; @@ -218,9 +218,8 @@ void _mergeFromRawJsMap( if (fi == null) { fi = registry?.getExtension(fs.messageName, int.parse(key)); if (fi == null) { - (fs.unknownJsonData ??= {})[key] = json - .getProperty(jsKey) - .dartify(); + (fs.unknownJsonData ??= {})[key] = + json.getProperty(jsKey).dartify(); continue; } } diff --git a/protobuf/lib/src/protobuf/json_parsing_context.dart b/protobuf/lib/src/protobuf/json_parsing_context.dart index 2fec72e51..add1d0f0b 100644 --- a/protobuf/lib/src/protobuf/json_parsing_context.dart +++ b/protobuf/lib/src/protobuf/json_parsing_context.dart @@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=3.10 +// @dart=3.7 class JsonParsingContext { // A list of indices into maps and lists pointing to the current root. diff --git a/protobuf/lib/src/protobuf/message_set.dart b/protobuf/lib/src/protobuf/message_set.dart index 2d491f817..41066d372 100644 --- a/protobuf/lib/src/protobuf/message_set.dart +++ b/protobuf/lib/src/protobuf/message_set.dart @@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=3.10 +// @dart=3.7 part of 'internal.dart'; diff --git a/protobuf/lib/src/protobuf/mixins/map_mixin.dart b/protobuf/lib/src/protobuf/mixins/map_mixin.dart index b113b9c82..cd835ca50 100644 --- a/protobuf/lib/src/protobuf/mixins/map_mixin.dart +++ b/protobuf/lib/src/protobuf/mixins/map_mixin.dart @@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=3.10 +// @dart=3.7 import '../../../protobuf.dart' show BuilderInfo; diff --git a/protobuf/lib/src/protobuf/mixins/well_known.dart b/protobuf/lib/src/protobuf/mixins/well_known.dart index eb56e5e0a..6e8d03ee9 100644 --- a/protobuf/lib/src/protobuf/mixins/well_known.dart +++ b/protobuf/lib/src/protobuf/mixins/well_known.dart @@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=3.10 +// @dart=3.7 import 'dart:convert'; @@ -349,9 +349,8 @@ mixin DurationMixin { ); } else { final secondsString = match[1]!; - final seconds = secondsString == '' - ? Int64.ZERO - : Int64.parseInt(secondsString); + final seconds = + secondsString == '' ? Int64.ZERO : Int64.parseInt(secondsString); duration.seconds = seconds; final nanos = int.parse((match[2] ?? '').padRight(9, '0')); duration.nanos = seconds < 0 ? -nanos : nanos; diff --git a/protobuf/lib/src/protobuf/pb_list.dart b/protobuf/lib/src/protobuf/pb_list.dart index c8bd49359..b06d89e3c 100644 --- a/protobuf/lib/src/protobuf/pb_list.dart +++ b/protobuf/lib/src/protobuf/pb_list.dart @@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=3.10 +// @dart=3.7 import 'dart:collection' show ListBase; import 'dart:math' as math; diff --git a/protobuf/lib/src/protobuf/pb_map.dart b/protobuf/lib/src/protobuf/pb_map.dart index affd4d908..b106ba7ee 100644 --- a/protobuf/lib/src/protobuf/pb_map.dart +++ b/protobuf/lib/src/protobuf/pb_map.dart @@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=3.10 +// @dart=3.7 import 'dart:collection' show MapBase; diff --git a/protobuf/lib/src/protobuf/permissive_compare.dart b/protobuf/lib/src/protobuf/permissive_compare.dart index 65e59e256..059cc7584 100644 --- a/protobuf/lib/src/protobuf/permissive_compare.dart +++ b/protobuf/lib/src/protobuf/permissive_compare.dart @@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=3.10 +// @dart=3.7 /// Returns true if [a] and [b] are the same ignoring case and all instances of /// `-` and `_`. diff --git a/protobuf/lib/src/protobuf/proto3_json.dart b/protobuf/lib/src/protobuf/proto3_json.dart index d1ad8dce7..e7d37e8bc 100644 --- a/protobuf/lib/src/protobuf/proto3_json.dart +++ b/protobuf/lib/src/protobuf/proto3_json.dart @@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=3.10 +// @dart=3.7 part of 'internal.dart'; @@ -180,9 +180,10 @@ Object? _writeToProto3Json(FieldSet fs, TypeRegistry typeRegistry) { ); }); } else if (fieldInfo.isRepeated) { - jsonValue = (value as PbList) - .map((element) => valueToProto3Json(element, fieldInfo.type)) - .toList(); + jsonValue = + (value as PbList) + .map((element) => valueToProto3Json(element, fieldInfo.type)) + .toList(); } else { jsonValue = valueToProto3Json(value, fieldInfo.type); } @@ -331,11 +332,12 @@ void _mergeFromProto3JsonWithContext( case PbFieldType.ENUM_BIT: if (value is String) { // TODO(sigurdm): Do we want to avoid linear search here? Measure... - final result = context.permissiveEnums - ? fieldInfo.enumValues!.findFirst( - (e) => permissiveCompare(e.name, value), - ) - : fieldInfo.enumValues!.findFirst((e) => e.name == value); + final result = + context.permissiveEnums + ? fieldInfo.enumValues!.findFirst( + (e) => permissiveCompare(e.name, value), + ) + : fieldInfo.enumValues!.findFirst((e) => e.name == value); if ((result != null) || context.ignoreUnknownFields) return result; throw context.parseException('Unknown enum value', value); } else if (value is int) { @@ -343,9 +345,9 @@ void _mergeFromProto3JsonWithContext( (context.ignoreUnknownFields ? null : (throw context.parseException( - 'Unknown enum value', - value, - ))); + 'Unknown enum value', + value, + ))); } throw context.parseException( 'Expected enum as a string or integer', diff --git a/protobuf/lib/src/protobuf/protobuf_enum.dart b/protobuf/lib/src/protobuf/protobuf_enum.dart index 62bcd7b5a..eaf451fb0 100644 --- a/protobuf/lib/src/protobuf/protobuf_enum.dart +++ b/protobuf/lib/src/protobuf/protobuf_enum.dart @@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=3.10 +// @dart=3.7 // ignore_for_file: non_constant_identifier_names diff --git a/protobuf/lib/src/protobuf/rpc_client.dart b/protobuf/lib/src/protobuf/rpc_client.dart index 8c6b723ae..b123ac12f 100644 --- a/protobuf/lib/src/protobuf/rpc_client.dart +++ b/protobuf/lib/src/protobuf/rpc_client.dart @@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=3.10 +// @dart=3.7 part of 'internal.dart'; diff --git a/protobuf/lib/src/protobuf/type_registry.dart b/protobuf/lib/src/protobuf/type_registry.dart index 1d9ccf8ab..8de87c3a3 100644 --- a/protobuf/lib/src/protobuf/type_registry.dart +++ b/protobuf/lib/src/protobuf/type_registry.dart @@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=3.10 +// @dart=3.7 import '../../protobuf.dart'; diff --git a/protobuf/lib/src/protobuf/unknown_field_set.dart b/protobuf/lib/src/protobuf/unknown_field_set.dart index 61dce32d8..d362c5821 100644 --- a/protobuf/lib/src/protobuf/unknown_field_set.dart +++ b/protobuf/lib/src/protobuf/unknown_field_set.dart @@ -2,14 +2,14 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=3.10 +// @dart=3.7 part of 'internal.dart'; /// A set of unknown fields in a [GeneratedMessage]. class UnknownFieldSet { - static final UnknownFieldSet emptyUnknownFieldSet = UnknownFieldSet() - .._markReadOnly(); + static final UnknownFieldSet emptyUnknownFieldSet = + UnknownFieldSet().._markReadOnly(); final Map _fields; @@ -224,8 +224,9 @@ class UnknownFieldSet { writeIndent(out, indentLevel); out.write('$tag: '); try { - final ufs = UnknownFieldSet() - ..mergeFromCodedBufferReader(CodedBufferReader(value)); + final ufs = + UnknownFieldSet() + ..mergeFromCodedBufferReader(CodedBufferReader(value)); out.write('{\n'); ufs.writeTextFormat(out, indentLevel + 1); writeIndent(out, indentLevel); diff --git a/protobuf/lib/src/protobuf/unpack.dart b/protobuf/lib/src/protobuf/unpack.dart index e101d40c1..d693873be 100644 --- a/protobuf/lib/src/protobuf/unpack.dart +++ b/protobuf/lib/src/protobuf/unpack.dart @@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=3.10 +// @dart=3.7 part of 'internal.dart'; diff --git a/protobuf/lib/src/protobuf/utils.dart b/protobuf/lib/src/protobuf/utils.dart index 109a51d81..4a795b63d 100644 --- a/protobuf/lib/src/protobuf/utils.dart +++ b/protobuf/lib/src/protobuf/utils.dart @@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=3.10 +// @dart=3.7 import 'package:fixnum/fixnum.dart' show Int64; diff --git a/protobuf/lib/src/protobuf/wire_format.dart b/protobuf/lib/src/protobuf/wire_format.dart index d7347e0ac..c2f07d60e 100644 --- a/protobuf/lib/src/protobuf/wire_format.dart +++ b/protobuf/lib/src/protobuf/wire_format.dart @@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=3.10 +// @dart=3.7 // ignore_for_file: constant_identifier_names diff --git a/protobuf/test/builder_info_test.dart b/protobuf/test/builder_info_test.dart index c89bab702..87242c49e 100644 --- a/protobuf/test/builder_info_test.dart +++ b/protobuf/test/builder_info_test.dart @@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=3.10 +// @dart=3.7 import 'package:protobuf/protobuf.dart'; import 'package:test/test.dart'; diff --git a/protobuf/test/codec_test.dart b/protobuf/test/codec_test.dart index 4db493956..12eb9c4cb 100644 --- a/protobuf/test/codec_test.dart +++ b/protobuf/test/codec_test.dart @@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=3.10 +// @dart=3.7 import 'dart:typed_data'; @@ -179,9 +179,10 @@ void main() { // Compare two doubles, where NaNs and same-sign inifinities compare equal. // For normal values, use equals. - Matcher doubleEquals(double expected) => expected.isNaN - ? predicate((x) => x.isNaN, 'NaN expected') - : equals(expected); + Matcher doubleEquals(double expected) => + expected.isNaN + ? predicate((x) => x.isNaN, 'NaN expected') + : equals(expected); List dataToBytes(ByteData byteData) => Uint8List.view(byteData.buffer); final floatToBytes = convertToBytes(PbFieldType.OF); diff --git a/protobuf/test/coded_buffer_reader_test.dart b/protobuf/test/coded_buffer_reader_test.dart index bd4f87767..7749fb5d4 100644 --- a/protobuf/test/coded_buffer_reader_test.dart +++ b/protobuf/test/coded_buffer_reader_test.dart @@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=3.10 +// @dart=3.7 import 'dart:typed_data'; diff --git a/protobuf/test/dummy_field_test.dart b/protobuf/test/dummy_field_test.dart index bb624be39..55809b3de 100644 --- a/protobuf/test/dummy_field_test.dart +++ b/protobuf/test/dummy_field_test.dart @@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=3.10 +// @dart=3.7 import 'package:protobuf/protobuf.dart'; import 'package:test/test.dart'; diff --git a/protobuf/test/json_test.dart b/protobuf/test/json_test.dart index ae563b8f7..ad050c931 100644 --- a/protobuf/test/json_test.dart +++ b/protobuf/test/json_test.dart @@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=3.10 +// @dart=3.7 // Basic smoke tests for the GeneratedMessage JSON API. // @@ -130,9 +130,10 @@ void main() { test('testFrozentInt64JsonEncoding', () { final value = Int64.parseInt('1234567890123456789'); - final frozen = T() - ..int64 = value - ..freeze(); + final frozen = + T() + ..int64 = value + ..freeze(); final encoded = frozen.writeToJsonMap(); expect(encoded['5'], '$value'); final decoded = T()..mergeFromJsonMap(encoded); @@ -188,10 +189,11 @@ void main() { }); } -T makeTestJson() => T() - ..val = 123 - ..str = 'hello' - ..int32s.addAll([1, 2, 3]); +T makeTestJson() => + T() + ..val = 123 + ..str = 'hello' + ..int32s.addAll([1, 2, 3]); void checkJsonMap(Map m, {Map? unknownFields}) { expect(m.length, 3 + (unknownFields?.length ?? 0)); diff --git a/protobuf/test/json_vm_test.dart b/protobuf/test/json_vm_test.dart index ef2898671..8e6017e7e 100644 --- a/protobuf/test/json_vm_test.dart +++ b/protobuf/test/json_vm_test.dart @@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=3.10 +// @dart=3.7 // VM-specific smoke tests for the GeneratedMessage JSON API. // diff --git a/protobuf/test/list_equality_test.dart b/protobuf/test/list_equality_test.dart index 87bc7a133..4fbf68688 100644 --- a/protobuf/test/list_equality_test.dart +++ b/protobuf/test/list_equality_test.dart @@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=3.10 +// @dart=3.7 // Test for ensuring that protobuf lists compare using value semantics. @@ -30,12 +30,14 @@ void main() { }); test('non-empty frozen lists compare as equal', () { - final first = T() - ..int32s.add(1) - ..freeze(); - final second = T() - ..int32s.add(1) - ..freeze(); + final first = + T() + ..int32s.add(1) + ..freeze(); + final second = + T() + ..int32s.add(1) + ..freeze(); expect(first.int32s == second.int32s, isTrue); }); @@ -46,12 +48,14 @@ void main() { }); test('different frozen lists do not compare as equal', () { - final first = T() - ..int32s.add(1) - ..freeze(); - final second = T() - ..int32s.add(2) - ..freeze(); + final first = + T() + ..int32s.add(1) + ..freeze(); + final second = + T() + ..int32s.add(2) + ..freeze(); expect(first.int32s == second.int32s, isFalse); }); } diff --git a/protobuf/test/list_test.dart b/protobuf/test/list_test.dart index 7415ee77e..24af7c8a9 100644 --- a/protobuf/test/list_test.dart +++ b/protobuf/test/list_test.dart @@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=3.10 +// @dart=3.7 import 'package:fixnum/fixnum.dart'; import 'package:protobuf/protobuf.dart'; diff --git a/protobuf/test/map_mixin_test.dart b/protobuf/test/map_mixin_test.dart index bd3b4c212..bceef5f10 100644 --- a/protobuf/test/map_mixin_test.dart +++ b/protobuf/test/map_mixin_test.dart @@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=3.10 +// @dart=3.7 // Unit tests for PbMapMixin. // There are more tests in the dart-protoc-plugin package. diff --git a/protobuf/test/message_test.dart b/protobuf/test/message_test.dart index 9fd5ed857..7ebe95db3 100644 --- a/protobuf/test/message_test.dart +++ b/protobuf/test/message_test.dart @@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=3.10 +// @dart=3.7 // Tests for GeneratedMessage methods. @@ -67,15 +67,16 @@ Matcher throwsError(String expectedMessage) => throwsA( ); void main() { - final recProto = Rec() - ..val = 123 - ..str = 'a\n\r\t"\\b' - ..bytes = [0, 1, 2, 127, 128, 255] - ..child = (Rec()..val = 456) - ..int32s.addAll([1, 2, 3]) - ..int64 = Int64.MAX_VALUE - ..stringMap['key "1"'] = '''value\n1''' - ..stringMap['key 2'] = 'value 2'; + final recProto = + Rec() + ..val = 123 + ..str = 'a\n\r\t"\\b' + ..bytes = [0, 1, 2, 127, 128, 255] + ..child = (Rec()..val = 456) + ..int32s.addAll([1, 2, 3]) + ..int64 = Int64.MAX_VALUE + ..stringMap['key "1"'] = '''value\n1''' + ..stringMap['key 2'] = 'value 2'; test('getField with invalid tag throws exception', () { final r = Rec(); @@ -92,13 +93,15 @@ void main() { }); test('operator== and hashCode works for frozen message', () { - final a = Rec() - ..val = 123 - ..int32s.addAll([1, 2, 3]) - ..freeze(); - final b = Rec() - ..val = 123 - ..int32s.addAll([1, 2, 3]); + final a = + Rec() + ..val = 123 + ..int32s.addAll([1, 2, 3]) + ..freeze(); + final b = + Rec() + ..val = 123 + ..int32s.addAll([1, 2, 3]); expect(a.hashCode, b.hashCode); expect(a == b, true); @@ -106,10 +109,11 @@ void main() { }); test('isFrozen works', () { - final a = Rec() - ..val = 123 - ..int32s.addAll([1, 2, 3]) - ..child = (Rec()..val = 100); + final a = + Rec() + ..val = 123 + ..int32s.addAll([1, 2, 3]) + ..child = (Rec()..val = 100); expect(a.isFrozen, false); a.child.freeze(); expect(a.child.isFrozen, true); @@ -163,12 +167,13 @@ void main() { }); test('toTextFormatString handles extensions fields', () { - final a = Rec() - ..val = 42 - ..setExtension(Ext.count, 123) - ..addExtension(Ext.items, 'a') - ..addExtension(Ext.items, 'b"c') - ..setExtension(Ext.data, [0, 1, 2, 127, 128, 255]); + final a = + Rec() + ..val = 42 + ..setExtension(Ext.count, 123) + ..addExtension(Ext.items, 'a') + ..addExtension(Ext.items, 'b"c') + ..setExtension(Ext.data, [0, 1, 2, 127, 128, 255]); expect(a.toTextFormat(), _expectedTextProtoWithExtensions); }); diff --git a/protobuf/test/mock_util.dart b/protobuf/test/mock_util.dart index c7a76fd1f..88d588e2a 100644 --- a/protobuf/test/mock_util.dart +++ b/protobuf/test/mock_util.dart @@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=3.10 +// @dart=3.7 import 'package:collection/collection.dart'; import 'package:fixnum/fixnum.dart' show Int64; diff --git a/protobuf/test/permissive_compare_test.dart b/protobuf/test/permissive_compare_test.dart index 8dd1f719d..3a6347a00 100644 --- a/protobuf/test/permissive_compare_test.dart +++ b/protobuf/test/permissive_compare_test.dart @@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=3.10 +// @dart=3.7 import 'package:protobuf/src/protobuf/permissive_compare.dart'; import 'package:test/test.dart'; diff --git a/protobuf/test/readonly_message_test.dart b/protobuf/test/readonly_message_test.dart index 0f468e3e9..ae44effa1 100644 --- a/protobuf/test/readonly_message_test.dart +++ b/protobuf/test/readonly_message_test.dart @@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=3.10 +// @dart=3.7 import 'package:protobuf/protobuf.dart' show BuilderInfo, GeneratedMessage, PbFieldType, UnknownFieldSetField; @@ -23,10 +23,11 @@ class Rec extends GeneratedMessage { Rec createEmptyInstance() => Rec(); @override - BuilderInfo info_ = BuilderInfo('rec') - ..a(1, 'value', PbFieldType.O3) - ..pc(2, 'sub', PbFieldType.PM, subBuilder: Rec.create) - ..p(10, 'ints', PbFieldType.P3); + BuilderInfo info_ = + BuilderInfo('rec') + ..a(1, 'value', PbFieldType.O3) + ..pc(2, 'sub', PbFieldType.PM, subBuilder: Rec.create) + ..p(10, 'ints', PbFieldType.P3); int get value => $_get(0, 0); set value(int v) { @@ -97,9 +98,10 @@ void main() { () => Rec.getDefault().sub.add(Rec.create()), throwsUnsupportedError(contains('add')), ); - var r = Rec.create() - ..ints.add(10) - ..freeze(); + var r = + Rec.create() + ..ints.add(10) + ..freeze(); expect( () => r.ints.clear(), throwsUnsupportedError(equals("'clear' on a read-only list")), @@ -113,9 +115,10 @@ void main() { throwsUnsupportedError(equals("'add' on a read-only list")), ); - r = Rec.create() - ..sub.add(Rec.create()) - ..freeze(); + r = + Rec.create() + ..sub.add(Rec.create()) + ..freeze(); expect( () => r.sub.add(Rec.create()), throwsUnsupportedError(equals("'add' on a read-only list")), @@ -128,9 +131,10 @@ void main() { test("can't modify sub-messages on a read-only message", () { final subMessage = Rec.create()..value = 1; - final r = Rec.create() - ..sub.add(Rec.create()..sub.add(subMessage)) - ..freeze(); + final r = + Rec.create() + ..sub.add(Rec.create()..sub.add(subMessage)) + ..freeze(); expect(r.sub[0].sub[0].value, 1); expect( () => subMessage.value = 2, @@ -152,9 +156,10 @@ void main() { }); test('can rebuild a frozen message with merge', () { - final orig = Rec.create() - ..value = 10 - ..freeze(); + final orig = + Rec.create() + ..value = 10 + ..freeze(); final rebuilt = orig.copyWith((m) => m.mergeFromJson('{"1": 7}')); expect(identical(orig, rebuilt), false); expect(orig.value, 10); @@ -162,9 +167,10 @@ void main() { }); test('can set a field while rebuilding a frozen message', () { - final orig = Rec.create() - ..value = 10 - ..freeze(); + final orig = + Rec.create() + ..value = 10 + ..freeze(); final rebuilt = orig.copyWith((m) => m.value = 7); expect(identical(orig, rebuilt), false); expect(orig.value, 10); @@ -172,9 +178,10 @@ void main() { }); test('can clear while rebuilding a frozen message', () { - final orig = Rec.create() - ..value = 10 - ..freeze(); + final orig = + Rec.create() + ..value = 10 + ..freeze(); final rebuilt = orig.copyWith((m) => m.clear()); expect(identical(orig, rebuilt), false); expect(orig.value, 10); @@ -183,9 +190,10 @@ void main() { }); test('can clear a field while rebuilding a frozen message', () { - final orig = Rec.create() - ..value = 10 - ..freeze(); + final orig = + Rec.create() + ..value = 10 + ..freeze(); final rebuilt = orig.copyWith((m) => m.clearField(1)); expect(identical(orig, rebuilt), false); expect(orig.value, 10); @@ -194,9 +202,10 @@ void main() { }); test('can modify repeated fields while rebuilding a frozen message', () { - var orig = Rec.create() - ..ints.add(10) - ..freeze(); + var orig = + Rec.create() + ..ints.add(10) + ..freeze(); var rebuilt = orig.copyWith((m) => m.ints.add(12)); expect(identical(orig, rebuilt), false); expect(orig.ints, [10]); @@ -210,9 +219,10 @@ void main() { expect(orig.ints, [10]); expect(rebuilt.ints, [2]); - orig = Rec.create() - ..sub.add(Rec.create()) - ..freeze(); + orig = + Rec.create() + ..sub.add(Rec.create()) + ..freeze(); rebuilt = orig.copyWith((m) => m.sub.add(Rec.create())); expect(orig.sub.length, 1); expect(rebuilt.sub.length, 2); @@ -220,9 +230,10 @@ void main() { test('cannot modify sub-messages while rebuilding a frozen message', () { final subMessage = Rec.create()..value = 1; - final orig = Rec.create() - ..sub.add(Rec.create()..sub.add(subMessage)) - ..freeze(); + final orig = + Rec.create() + ..sub.add(Rec.create()..sub.add(subMessage)) + ..freeze(); final rebuilt = orig.copyWith((m) { expect( @@ -248,8 +259,9 @@ void main() { }); test('can modify unknown fields while rebuilding a frozen message', () { - final orig = Rec.create() - ..unknownFields.addField(20, UnknownFieldSetField()..fixed32s.add(1)); + final orig = + Rec.create() + ..unknownFields.addField(20, UnknownFieldSetField()..fixed32s.add(1)); final rebuilt = orig.copyWith((m) => m.unknownFields.clear()); expect(orig.unknownFields.hasField(20), true); expect(rebuilt.unknownFields.hasField(20), false); diff --git a/protobuf/test/test_util.dart b/protobuf/test/test_util.dart index bdeed37e9..1b24df0ce 100644 --- a/protobuf/test/test_util.dart +++ b/protobuf/test/test_util.dart @@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=3.10 +// @dart=3.7 import 'package:fixnum/fixnum.dart'; import 'package:test/test.dart'; From c4dd4e5c66412d0d1fefbcbb5ad40af4adf85710 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20A=C4=9Facan?= Date: Mon, 17 Nov 2025 14:03:49 +0000 Subject: [PATCH 4/4] Update export order --- protobuf/lib/src/protobuf/internal.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protobuf/lib/src/protobuf/internal.dart b/protobuf/lib/src/protobuf/internal.dart index f7cbc0c33..a268de441 100644 --- a/protobuf/lib/src/protobuf/internal.dart +++ b/protobuf/lib/src/protobuf/internal.dart @@ -29,10 +29,10 @@ import 'type_registry.dart'; import 'utils.dart'; export 'annotations.dart' show GrpcServiceName, TagNumber; +export 'exceptions.dart' show InvalidProtocolBufferException; export 'pb_list.dart' show PbList; export 'pb_map.dart' show PbMap; export 'type_registry.dart' show TypeRegistry; -export 'exceptions.dart' show InvalidProtocolBufferException; part 'builder_info.dart'; part 'coded_buffer.dart';