From e84fb7473e275a4a069af3275d6303f7cf18613f Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Wed, 6 Mar 2024 13:11:49 -0800 Subject: [PATCH 1/4] Update to latest lints --- analysis_options.yaml | 6 +- api_benchmark/lib/benchmarks/get_strings.dart | 2 +- api_benchmark/lib/benchmarks/has_strings.dart | 2 +- api_benchmark/lib/benchmarks/int32_json.dart | 2 +- api_benchmark/lib/benchmarks/int64_json.dart | 2 +- .../lib/benchmarks/repeated_int32_json.dart | 2 +- .../lib/benchmarks/repeated_int64_json.dart | 2 +- .../lib/benchmarks/repeated_string_json.dart | 2 +- api_benchmark/lib/benchmarks/set_strings.dart | 2 +- api_benchmark/lib/benchmarks/string_json.dart | 2 +- api_benchmark/lib/dashboard_view.dart | 4 +- api_benchmark/pubspec.yaml | 2 +- api_benchmark/tool/builder.dart | 2 +- benchmarks/pubspec.yaml | 2 +- protobuf/lib/src/protobuf/builder_info.dart | 4 +- .../lib/src/protobuf/coded_buffer_reader.dart | 2 +- .../lib/src/protobuf/generated_message.dart | 2 +- protobuf/lib/src/protobuf/json.dart | 2 +- protobuf/pubspec.yaml | 2 +- protobuf/test/coded_buffer_reader_test.dart | 2 +- protobuf/test/list_test.dart | 2 +- protobuf/test/map_mixin_test.dart | 6 +- protobuf/test/mock_util.dart | 2 +- protoc_plugin/pubspec.yaml | 2 +- protoc_plugin/test/any_test.dart | 2 +- protoc_plugin/test/extension_test.dart | 10 ++-- protoc_plugin/test/freeze_test.dart | 31 +++++------ .../test/generated_message_test.dart | 4 +- protoc_plugin/test/import_public_test.dart | 4 +- protoc_plugin/test/map_field_test.dart | 11 ++-- protoc_plugin/test/map_test.dart | 2 +- .../test/message_generator_test.dart | 4 +- protoc_plugin/test/proto3_json_test.dart | 25 ++++----- protoc_plugin/test/protoc_options_test.dart | 2 +- .../test/send_protos_via_sendports_test.dart | 4 +- protoc_plugin/test/test_util.dart | 2 +- protoc_plugin/test/to_builder_test.dart | 55 +++++++++---------- 37 files changed, 103 insertions(+), 113 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index e7321a172..f1e6a5ce8 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -4,13 +4,13 @@ analyzer: language: strict-casts: true errors: + inference_failure_on_collection_literal: ignore + inference_failure_on_untyped_parameter: ignore + inference_failure_on_function_invocation: ignore lines_longer_than_80_chars: ignore linter: rules: - avoid_bool_literals_in_conditional_expressions - - comment_references - prefer_final_in_for_each - prefer_final_locals - - prefer_relative_imports - - use_super_parameters diff --git a/api_benchmark/lib/benchmarks/get_strings.dart b/api_benchmark/lib/benchmarks/get_strings.dart index ccf4531a4..70962d2cd 100644 --- a/api_benchmark/lib/benchmarks/get_strings.dart +++ b/api_benchmark/lib/benchmarks/get_strings.dart @@ -120,7 +120,7 @@ class GetStringsBenchmark extends Benchmark { String get measureSampleUnits => 'string reads/ms'; static const $id = BenchmarkID.GET_STRINGS; - static final $type = BenchmarkType($id, $create); + static final $type = const BenchmarkType($id, $create); static GetStringsBenchmark $create(Request r) { assert(r.params.hasMessageCount()); diff --git a/api_benchmark/lib/benchmarks/has_strings.dart b/api_benchmark/lib/benchmarks/has_strings.dart index 9301cc672..75903cd1b 100644 --- a/api_benchmark/lib/benchmarks/has_strings.dart +++ b/api_benchmark/lib/benchmarks/has_strings.dart @@ -120,7 +120,7 @@ class HasStringsBenchmark extends Benchmark { String get measureSampleUnits => 'string reads/ms'; static const $id = BenchmarkID.HAS_STRINGS; - static final $type = BenchmarkType($id, $create); + static final $type = const BenchmarkType($id, $create); static HasStringsBenchmark $create(Request r) { assert(r.params.hasMessageCount()); diff --git a/api_benchmark/lib/benchmarks/int32_json.dart b/api_benchmark/lib/benchmarks/int32_json.dart index 35deac0ee..5ee66d395 100644 --- a/api_benchmark/lib/benchmarks/int32_json.dart +++ b/api_benchmark/lib/benchmarks/int32_json.dart @@ -74,7 +74,7 @@ class Int32Benchmark extends Benchmark { String get measureSampleUnits => 'int32 reads/ms'; static const $id = BenchmarkID.READ_INT32_FIELDS_JSON; - static final $type = BenchmarkType($id, $create); + static final $type = const BenchmarkType($id, $create); static Int32Benchmark $create(Request r) { assert(r.params.hasInt32FieldCount()); diff --git a/api_benchmark/lib/benchmarks/int64_json.dart b/api_benchmark/lib/benchmarks/int64_json.dart index cc16f5244..8368bb904 100644 --- a/api_benchmark/lib/benchmarks/int64_json.dart +++ b/api_benchmark/lib/benchmarks/int64_json.dart @@ -76,7 +76,7 @@ class Int64Benchmark extends Benchmark { String get measureSampleUnits => 'int64 reads/ms'; static const $id = BenchmarkID.READ_INT64_FIELDS_JSON; - static final $type = BenchmarkType($id, $create); + static final $type = const BenchmarkType($id, $create); static Int64Benchmark $create(Request r) { assert(r.params.hasInt64FieldCount()); diff --git a/api_benchmark/lib/benchmarks/repeated_int32_json.dart b/api_benchmark/lib/benchmarks/repeated_int32_json.dart index 7f7ffbdb9..fb38d106b 100644 --- a/api_benchmark/lib/benchmarks/repeated_int32_json.dart +++ b/api_benchmark/lib/benchmarks/repeated_int32_json.dart @@ -66,7 +66,7 @@ class RepeatedInt32Benchmark extends Benchmark { String get measureSampleUnits => 'int32 reads/ms'; static const $id = BenchmarkID.READ_INT32_REPEATED_JSON; - static final $type = BenchmarkType($id, $create); + static final $type = const BenchmarkType($id, $create); static RepeatedInt32Benchmark $create(Request r) { assert(r.params.hasInt32RepeatCount()); assert(r.params.hasMessageCount()); diff --git a/api_benchmark/lib/benchmarks/repeated_int64_json.dart b/api_benchmark/lib/benchmarks/repeated_int64_json.dart index 727ac5694..b36387726 100644 --- a/api_benchmark/lib/benchmarks/repeated_int64_json.dart +++ b/api_benchmark/lib/benchmarks/repeated_int64_json.dart @@ -68,7 +68,7 @@ class RepeatedInt64Benchmark extends Benchmark { String get measureSampleUnits => 'int64 reads/ms'; static const $id = BenchmarkID.READ_INT64_REPEATED_JSON; - static final $type = BenchmarkType($id, $create); + static final $type = const BenchmarkType($id, $create); static RepeatedInt64Benchmark $create(Request r) { assert(r.params.hasInt64RepeatCount()); assert(r.params.hasMessageCount()); diff --git a/api_benchmark/lib/benchmarks/repeated_string_json.dart b/api_benchmark/lib/benchmarks/repeated_string_json.dart index 24bc901c3..bed807e3f 100644 --- a/api_benchmark/lib/benchmarks/repeated_string_json.dart +++ b/api_benchmark/lib/benchmarks/repeated_string_json.dart @@ -76,7 +76,7 @@ class RepeatedStringBenchmark extends Benchmark { String get measureSampleUnits => 'string reads/ms'; static const $id = BenchmarkID.READ_STRING_REPEATED_JSON; - static final $type = BenchmarkType($id, $create); + static final $type = const BenchmarkType($id, $create); static RepeatedStringBenchmark $create(Request r) { assert(r.params.hasStringFieldCount()); diff --git a/api_benchmark/lib/benchmarks/set_strings.dart b/api_benchmark/lib/benchmarks/set_strings.dart index a10776b29..7e1928e8a 100644 --- a/api_benchmark/lib/benchmarks/set_strings.dart +++ b/api_benchmark/lib/benchmarks/set_strings.dart @@ -94,7 +94,7 @@ class SetStringsBenchmark extends Benchmark { String get measureSampleUnits => 'string writes/ms'; static const $id = BenchmarkID.SET_STRINGS; - static final $type = BenchmarkType($id, $create); + static final $type = const BenchmarkType($id, $create); static SetStringsBenchmark $create(Request r) { assert(r.params.hasMessageCount()); diff --git a/api_benchmark/lib/benchmarks/string_json.dart b/api_benchmark/lib/benchmarks/string_json.dart index 5370c6a44..603318761 100644 --- a/api_benchmark/lib/benchmarks/string_json.dart +++ b/api_benchmark/lib/benchmarks/string_json.dart @@ -82,7 +82,7 @@ class StringBenchmark extends Benchmark { String get measureSampleUnits => 'string reads/ms'; static const $id = BenchmarkID.READ_STRING_FIELDS_JSON; - static final $type = BenchmarkType($id, $create); + static final $type = const BenchmarkType($id, $create); static StringBenchmark $create(Request r) { assert(r.params.hasStringFieldCount()); diff --git a/api_benchmark/lib/dashboard_view.dart b/api_benchmark/lib/dashboard_view.dart index 5a8965963..c16c0af89 100644 --- a/api_benchmark/lib/dashboard_view.dart +++ b/api_benchmark/lib/dashboard_view.dart @@ -293,7 +293,7 @@ class _Label { class _Button { final ButtonElement elt; - final _clicks = StreamController.broadcast(); + final _clicks = StreamController.broadcast(); String? _renderedLabel; bool? _renderedEnabled; @@ -301,7 +301,7 @@ class _Button { elt.onClick.listen((e) => _clicks.add(true)); } - Stream get onClick => _clicks.stream; + Stream get onClick => _clicks.stream; void render(String label, bool enabled) { if (label != _renderedLabel) { diff --git a/api_benchmark/pubspec.yaml b/api_benchmark/pubspec.yaml index 9a9d11ade..9c62c1ab3 100644 --- a/api_benchmark/pubspec.yaml +++ b/api_benchmark/pubspec.yaml @@ -20,7 +20,7 @@ dev_dependencies: build: ^2.0.0 build_runner: ^2.0.6 build_web_compilers: ^4.0.0 - dart_flutter_team_lints: ^1.0.0 + dart_flutter_team_lints: ^2.0.0 glob: ^2.0.0 protoc_plugin: path: "../protoc_plugin" diff --git a/api_benchmark/tool/builder.dart b/api_benchmark/tool/builder.dart index f36864ec3..de36b67c2 100644 --- a/api_benchmark/tool/builder.dart +++ b/api_benchmark/tool/builder.dart @@ -26,7 +26,7 @@ class _BenchmarkBuilder implements Builder { await buildStep.writeAsString( AssetId(buildStep.inputId.package, 'web/data/data.json'), - JsonEncoder.withIndent(' ').convert(data)); + const JsonEncoder.withIndent(' ').convert(data)); } @override diff --git a/benchmarks/pubspec.yaml b/benchmarks/pubspec.yaml index 68b002584..330c4fbfd 100644 --- a/benchmarks/pubspec.yaml +++ b/benchmarks/pubspec.yaml @@ -19,7 +19,7 @@ dependencies: dev_dependencies: args: ^2.3.1 - dart_flutter_team_lints: ^1.0.0 + dart_flutter_team_lints: ^2.0.0 path: ^1.8.2 pool: ^1.5.1 protoc_plugin: diff --git a/protobuf/lib/src/protobuf/builder_info.dart b/protobuf/lib/src/protobuf/builder_info.dart index 1ae344133..608aeae82 100644 --- a/protobuf/lib/src/protobuf/builder_info.dart +++ b/protobuf/lib/src/protobuf/builder_info.dart @@ -44,7 +44,7 @@ class BuilderInfo { // For well-known types. final Object? Function(GeneratedMessage message, TypeRegistry typeRegistry)? toProto3Json; - final Function(GeneratedMessage targetMessage, Object json, + final void Function(GeneratedMessage targetMessage, Object json, TypeRegistry typeRegistry, JsonParsingContext context)? fromProto3Json; final CreateBuilderFunc? createEmptyInstance; @@ -66,7 +66,7 @@ class BuilderInfo { {String? protoName}) { final index = byIndex.length; final fieldInfo = (tagNumber == 0) - ? FieldInfo.dummy(index) + ? FieldInfo.dummy(index) : FieldInfo(name, tagNumber, index, fieldType!, defaultOrMaker: defaultOrMaker, subBuilder: subBuilder, diff --git a/protobuf/lib/src/protobuf/coded_buffer_reader.dart b/protobuf/lib/src/protobuf/coded_buffer_reader.dart index cc7e3ddf1..5c1e345fd 100644 --- a/protobuf/lib/src/protobuf/coded_buffer_reader.dart +++ b/protobuf/lib/src/protobuf/coded_buffer_reader.dart @@ -50,7 +50,7 @@ class CodedBufferReader { bool isAtEnd() => _bufferPos >= _currentLimit; - void _withLimit(int byteLimit, Function() callback) { + void _withLimit(int byteLimit, void Function() callback) { if (byteLimit < 0) { throw ArgumentError( 'CodedBufferReader encountered an embedded string or message' diff --git a/protobuf/lib/src/protobuf/generated_message.dart b/protobuf/lib/src/protobuf/generated_message.dart index 5a0b51cea..5eb3667d7 100644 --- a/protobuf/lib/src/protobuf/generated_message.dart +++ b/protobuf/lib/src/protobuf/generated_message.dart @@ -10,7 +10,7 @@ part of '../../protobuf.dart'; typedef CreateBuilderFunc = GeneratedMessage Function(); /// Type of a function that creates the default value of a protobuf field. -typedef MakeDefaultFunc = Function(); +typedef MakeDefaultFunc = dynamic Function(); /// Type of a function that makes an enum integer value to corresponding /// [ProtobufEnum] value. diff --git a/protobuf/lib/src/protobuf/json.dart b/protobuf/lib/src/protobuf/json.dart index 1184fa633..2f6258f7d 100644 --- a/protobuf/lib/src/protobuf/json.dart +++ b/protobuf/lib/src/protobuf/json.dart @@ -10,7 +10,7 @@ Map _writeToJsonMap(_FieldSet fs) { if (_isRepeated(fieldType)) { final PbList list = fieldValue; - return List.from(list.map((e) => convertToMap(e, baseType))); + return List.from(list.map((e) => convertToMap(e, baseType))); } switch (baseType) { diff --git a/protobuf/pubspec.yaml b/protobuf/pubspec.yaml index aeaf84223..5b63c9aad 100644 --- a/protobuf/pubspec.yaml +++ b/protobuf/pubspec.yaml @@ -14,6 +14,6 @@ dependencies: meta: ^1.7.0 dev_dependencies: - dart_flutter_team_lints: ^1.0.0 + dart_flutter_team_lints: ^2.0.0 matcher: ^0.12.11 test: ^1.16.0 diff --git a/protobuf/test/coded_buffer_reader_test.dart b/protobuf/test/coded_buffer_reader_test.dart index 00a715c04..a7fd0a9dd 100644 --- a/protobuf/test/coded_buffer_reader_test.dart +++ b/protobuf/test/coded_buffer_reader_test.dart @@ -11,7 +11,7 @@ import 'test_util.dart'; void main() { final throwsInvalidProtocolBufferException = - throwsA(TypeMatcher()); + throwsA(isA()); group('testCodedBufferReader', () { final inputBuffer = List.unmodifiable([ diff --git a/protobuf/test/list_test.dart b/protobuf/test/list_test.dart index 4d29ece59..ac5d79c6a 100644 --- a/protobuf/test/list_test.dart +++ b/protobuf/test/list_test.dart @@ -93,7 +93,7 @@ void main() { expect(() { // ignore: unnecessary_cast (PbList() as List).add('hello'); - }, throwsA(TypeMatcher())); + }, throwsA(isA())); }); test('PbList for signed int32 validates items', () { diff --git a/protobuf/test/map_mixin_test.dart b/protobuf/test/map_mixin_test.dart index 1608a46da..c7c8b7091 100644 --- a/protobuf/test/map_mixin_test.dart +++ b/protobuf/test/map_mixin_test.dart @@ -97,15 +97,15 @@ void main() { test("protobuf doesn't compare equal to a map with the same values", () { final a = Rec(); - expect(a == Map.from(a), false); - expect(Map.from(a) == a, false); + expect(a == Map.of(a), false); + expect(Map.of(a) == a, false); }); test("reading protobuf values shouldn't change equality", () { final a = Rec(); final b = Rec(); expect(a == b, true); - Map.from(a); + Map.of(a); expect(a == b, true); }); } diff --git a/protobuf/test/mock_util.dart b/protobuf/test/mock_util.dart index 731763547..2e8bb6aa7 100644 --- a/protobuf/test/mock_util.dart +++ b/protobuf/test/mock_util.dart @@ -12,7 +12,7 @@ import 'package:protobuf/protobuf.dart' PbFieldType, ProtobufEnum; -final mockEnumValues = [ProtobufEnum(1, 'a'), ProtobufEnum(2, 'b')]; +final mockEnumValues = [const ProtobufEnum(1, 'a'), const ProtobufEnum(2, 'b')]; BuilderInfo mockInfo(String className, CreateBuilderFunc create) { return BuilderInfo(className, createEmptyInstance: create) ..a(1, 'val', PbFieldType.O3, defaultOrMaker: 42) diff --git a/protoc_plugin/pubspec.yaml b/protoc_plugin/pubspec.yaml index 14c96de1a..28d46c276 100644 --- a/protoc_plugin/pubspec.yaml +++ b/protoc_plugin/pubspec.yaml @@ -13,7 +13,7 @@ dependencies: dev_dependencies: collection: ^1.15.0 - dart_flutter_team_lints: ^1.0.0 + dart_flutter_team_lints: ^2.0.0 matcher: ^0.12.10 test: ^1.16.0 diff --git a/protoc_plugin/test/any_test.dart b/protoc_plugin/test/any_test.dart index 86a3b650c..68f3d2d64 100644 --- a/protoc_plugin/test/any_test.dart +++ b/protoc_plugin/test/any_test.dart @@ -25,7 +25,7 @@ void main() { expect(searchRequest1.query, 'hest1'); expect(() { any.unpackInto(SearchResponse()); - }, throwsA(const TypeMatcher())); + }, throwsA(isA())); }); test('any inside any', () { diff --git a/protoc_plugin/test/extension_test.dart b/protoc_plugin/test/extension_test.dart index c1a80a49b..9622fe633 100644 --- a/protoc_plugin/test/extension_test.dart +++ b/protoc_plugin/test/extension_test.dart @@ -173,7 +173,7 @@ void main() { test('can extend a message with a message field with a different type', () { expect(Non_nested_extension.nonNestedExtension.makeDefault!(), - TypeMatcher()); + isA()); expect(Non_nested_extension.nonNestedExtension.name, 'nonNestedExtension'); }); @@ -276,7 +276,7 @@ void main() { expect( () => withUnknownFields.getExtension(Unittest.defaultStringExtension), - throwsA(const TypeMatcher())); + throwsA(isA())); expect(reparsed.getExtension(Unittest.defaultStringExtension), 'bar'); @@ -306,7 +306,7 @@ void main() { .reparseMessage(withUnknownFields) .getExtension(Extend_unittest.outer) .getExtension(Extend_unittest.extensionInner), - throwsA(const TypeMatcher())); + throwsA(isA())); expect( reparsed @@ -364,7 +364,7 @@ void main() { reason: 'this succeeds because it does not decode Extend_unittest.outer'); expect(() => r2.reparseMessage(withMalformedExtensionEncoding), - throwsA(const TypeMatcher())); + throwsA(isA())); }); test('ExtensionRegistry.reparseMessage preserves frozenness', () { @@ -379,7 +379,7 @@ void main() { () => r .reparseMessage(withUnknownFields) .setExtension(Unittest.defaultStringExtension, 'blah'), - throwsA(TypeMatcher())); + throwsA(isA())); }); test( diff --git a/protoc_plugin/test/freeze_test.dart b/protoc_plugin/test/freeze_test.dart index 846ca4c59..b427d282b 100644 --- a/protoc_plugin/test/freeze_test.dart +++ b/protoc_plugin/test/freeze_test.dart @@ -30,24 +30,21 @@ void main() { expect(top.nestedMessageList.length, 1); expect(top.nestedMessageList[0].isFrozen, true); expect(() => top.nestedMessageList.add(Nested()..a = 0), - throwsA(const TypeMatcher())); + throwsA(isA())); // Check map field expect(top.nestedMessageMap.length, 1); expect(top.nestedMessageMap[1]!.isFrozen, true); expect(() => top.nestedMessageMap[2] = Nested()..a = 0, - throwsA(const TypeMatcher())); - expect(() => map[0] = Nested()..a = 0, - throwsA(const TypeMatcher())); + throwsA(isA())); + expect(() => map[0] = Nested()..a = 0, throwsA(isA())); // Check message field expect(top.nestedMessage.isFrozen, true); // Check aliases - expect(() => list.add(Nested()..a = 0), - throwsA(const TypeMatcher())); - expect(() => map[123] = Nested()..a = 0, - throwsA(const TypeMatcher())); + expect(() => list.add(Nested()..a = 0), throwsA(isA())); + expect(() => map[123] = Nested()..a = 0, throwsA(isA())); expect(list[0].isFrozen, true); expect(map[1]!.isFrozen, true); expect(msg1.isFrozen, true); @@ -58,17 +55,15 @@ void main() { test('frozen messages should not be updated by merge methods', () { final top = TopEntity()..freeze(); - expect(() => top.mergeFromBuffer([]), - throwsA(TypeMatcher())); + expect( + () => top.mergeFromBuffer([]), throwsA(isA())); - expect(() => top.mergeFromJsonMap({}), - throwsA(TypeMatcher())); + expect(() => top.mergeFromJsonMap({}), throwsA(isA())); expect(() => top.mergeFromMessage(TopEntity()), - throwsA(TypeMatcher())); + throwsA(isA())); - expect(() => top.mergeFromProto3Json({}), - throwsA(TypeMatcher())); + expect(() => top.mergeFromProto3Json({}), throwsA(isA())); }); test('nested frozen messages should not be updated by merge methods', () { @@ -91,7 +86,7 @@ void main() { (1 << 3) | 0, // tag = 1, type = varint 123, // int64 id = 123 ]), - throwsA(TypeMatcher())); + throwsA(isA())); } { @@ -103,7 +98,7 @@ void main() { expect( () => top.mergeFromMessage( TopEntity()..sub = (SubEntity()..id = Int64(123))), - throwsA(TypeMatcher())); + throwsA(isA())); } { @@ -116,7 +111,7 @@ void main() { () => top.mergeFromProto3Json({ 'sub': {'id': 123} }), - throwsA(TypeMatcher())); + throwsA(isA())); } }); } diff --git a/protoc_plugin/test/generated_message_test.dart b/protoc_plugin/test/generated_message_test.dart index a25f6a4d4..22774d2b2 100644 --- a/protoc_plugin/test/generated_message_test.dart +++ b/protoc_plugin/test/generated_message_test.dart @@ -24,7 +24,7 @@ import 'test_util.dart'; void main() { final throwsInvalidProtocolBufferException = - throwsA(TypeMatcher()); + throwsA(isA()); test('testProtosShareRepeatedArraysIfDidntChange', () { final value1 = TestAllTypes() ..repeatedInt32.add(100) @@ -146,7 +146,7 @@ void main() { // void testReflectionDefaults() {} // UNSUPPORTED -- until reflection test('testEnumInterface', () { - expect(TestAllTypes().defaultNestedEnum, TypeMatcher()); + expect(TestAllTypes().defaultNestedEnum, isA()); }); test('testEnumMap', () { diff --git a/protoc_plugin/test/import_public_test.dart b/protoc_plugin/test/import_public_test.dart index 827f0f462..c5d174895 100644 --- a/protoc_plugin/test/import_public_test.dart +++ b/protoc_plugin/test/import_public_test.dart @@ -8,7 +8,7 @@ import '../out/protos/import_public.pb.dart'; void main() { test('can reference a message type imported publicly', () { - expect(Foo(), TypeMatcher()); - expect(A(), TypeMatcher()); + expect(Foo(), isA()); + expect(A(), isA()); }); } diff --git a/protoc_plugin/test/map_field_test.dart b/protoc_plugin/test/map_field_test.dart index 038ec6717..11b40568f 100644 --- a/protoc_plugin/test/map_field_test.dart +++ b/protoc_plugin/test/map_field_test.dart @@ -270,14 +270,13 @@ void main() { setValues(testMap); testMap.freeze(); - expect(() => updateValues(testMap), - throwsA(const TypeMatcher())); + expect(() => updateValues(testMap), throwsA(isA())); expect(() => testMap.int32ToMessageField[1]!.value = 42, - throwsA(const TypeMatcher())); + throwsA(isA())); expect(() => testMap.int32ToStringField.remove(1), - throwsA(const TypeMatcher())); + throwsA(isA())); expect(() => testMap.int32ToStringField.clear(), - throwsA(const TypeMatcher())); + throwsA(isA())); }); test('Values for different keys are not merged together when decoding', () { @@ -452,6 +451,6 @@ void main() { final msg = TestMap()..freeze(); expect(() { msg.int32ToInt32Field[0] = 1; - }, throwsA(const TypeMatcher())); + }, throwsA(isA())); }); } diff --git a/protoc_plugin/test/map_test.dart b/protoc_plugin/test/map_test.dart index e99958a46..91963394f 100644 --- a/protoc_plugin/test/map_test.dart +++ b/protoc_plugin/test/map_test.dart @@ -84,7 +84,7 @@ void main() { test('keys returns each field name (even when unset)', () { final rec = pb.Rec(); - expect(Set.from(rec.keys), {'msg', 'num', 'nums', 'str'}); + expect(Set.of(rec.keys), {'msg', 'num', 'nums', 'str'}); }); test('containsKey returns true for fields that exist (even when unset)', () { diff --git a/protoc_plugin/test/message_generator_test.dart b/protoc_plugin/test/message_generator_test.dart index c25fa0ec0..487e91328 100644 --- a/protoc_plugin/test/message_generator_test.dart +++ b/protoc_plugin/test/message_generator_test.dart @@ -112,8 +112,8 @@ void main() { final writer = IndentingWriter(filename: ''); mg.generate(writer); - final eq = ListEquality(); - final fieldStringsMap = HashMap( + final eq = const ListEquality(); + final fieldStringsMap = HashMap, List>( equals: eq.equals, hashCode: eq.hash, isValidKey: eq.isValidKey); fieldStringsMap[[4, 0]] = ['PhoneNumber']; fieldStringsMap[[4, 0, 2, 0]] = ['type', 'hasType', 'clearType']; diff --git a/protoc_plugin/test/proto3_json_test.dart b/protoc_plugin/test/proto3_json_test.dart index dc9de0edb..9d9b7f9e4 100644 --- a/protoc_plugin/test/proto3_json_test.dart +++ b/protoc_plugin/test/proto3_json_test.dart @@ -218,9 +218,9 @@ void main() { expect(Timestamp.fromDateTime(DateTime.utc(420)).toProto3Json(), '0420-01-01T00:00:00Z'); expect(() => Timestamp.fromDateTime(DateTime.utc(42001)).toProto3Json(), - throwsA(TypeMatcher())); + throwsA(isA())); expect(() => Timestamp.fromDateTime(DateTime.utc(-1)).toProto3Json(), - throwsA(TypeMatcher())); + throwsA(isA())); expect( Timestamp.fromDateTime(DateTime.utc(9999, 12, 31, 23, 59, 59)) .toProto3Json(), @@ -231,11 +231,11 @@ void main() { expect((Timestamp()..nanos = 8200000).toProto3Json(), '1970-01-01T00:00:00.008200Z'); expect(() => (Timestamp()..nanos = -8200000).toProto3Json(), - throwsA(TypeMatcher())); + throwsA(isA())); expect(() => (Timestamp()..nanos = -8200000).toProto3Json(), - throwsA(TypeMatcher())); + throwsA(isA())); expect(() => (Timestamp()..nanos = 1000000000).toProto3Json(), - throwsA(TypeMatcher())); + throwsA(isA())); }); test('Duration', () { @@ -289,7 +289,7 @@ void main() { expect( () => Any.pack(Timestamp.fromDateTime(DateTime(1969, 7, 20, 20, 17))) .toProto3Json(), - throwsA(TypeMatcher())); + throwsA(isA())); }); test('Nested Any', () { @@ -334,8 +334,7 @@ void main() { 'struct': {'a': 0}, 'list': [{}, [], 'why'] }); - expect( - () => Value().toProto3Json(), throwsA(TypeMatcher())); + expect(() => Value().toProto3Json(), throwsA(isA())); }); test('empty', () { @@ -373,11 +372,11 @@ void main() { expect((FieldMask()..paths.addAll(['foo_bar', 'zop'])).toProto3Json(), 'fooBar,zop'); expect(() => (FieldMask()..paths.add('foo_3_bar')).toProto3Json(), - throwsA(TypeMatcher())); + throwsA(isA())); expect(() => (FieldMask()..paths.add('foo__bar')).toProto3Json(), - throwsA(TypeMatcher())); + throwsA(isA())); expect(() => (FieldMask()..paths.add('fooBar')).toProto3Json(), - throwsA(TypeMatcher())); + throwsA(isA())); }); }); @@ -864,13 +863,13 @@ void main() { ..mergeFromProto3Json({ 'myOwnInventedField': 'blahblahblah', }), - throwsA(const TypeMatcher())); + throwsA(isA())); expect( () => TestAllTypes() ..mergeFromProto3Json({ 'myOwnInventedField': 'blahblahblah', }, ignoreUnknownFields: false), - throwsA(const TypeMatcher())); + throwsA(isA())); final t = TestAllTypes() ..mergeFromProto3Json({ 'myOwnInventedField': 'blahblahblah', diff --git a/protoc_plugin/test/protoc_options_test.dart b/protoc_plugin/test/protoc_options_test.dart index fd64bbf9a..8f81f920c 100644 --- a/protoc_plugin/test/protoc_options_test.dart +++ b/protoc_plugin/test/protoc_options_test.dart @@ -13,7 +13,7 @@ void main() { if (parameter != null) request.parameter = parameter; final response = CodeGeneratorResponse(); final options = parseGenerationOptions(request, response); - expect(options, TypeMatcher()); + expect(options, isA()); expect(response.error, ''); } diff --git a/protoc_plugin/test/send_protos_via_sendports_test.dart b/protoc_plugin/test/send_protos_via_sendports_test.dart index 40b784f03..940cd7368 100644 --- a/protoc_plugin/test/send_protos_via_sendports_test.dart +++ b/protoc_plugin/test/send_protos_via_sendports_test.dart @@ -34,7 +34,7 @@ void main() async { expect(!identical(object, clone), true); expect(!identical(object.inner, clone.inner), true); expect(identical(object.info_, clone.info_), true); - }, onPlatform: {'js': Skip('dart:isolate only works on Dart VM')}); + }, onPlatform: {'js': const Skip('dart:isolate only works on Dart VM')}); test('Map-using proto can be transferred via ports', () async { final object = map.TestMap() @@ -54,5 +54,5 @@ void main() async { // the `_info_` did not get cloned. expect(!identical(object, clone), true); expect(identical(object.info_, clone.info_), true); - }, onPlatform: {'js': Skip('dart:isolate only works on Dart VM')}); + }, onPlatform: {'js': const Skip('dart:isolate only works on Dart VM')}); } diff --git a/protoc_plugin/test/test_util.dart b/protoc_plugin/test/test_util.dart index 605748b54..f1b1dccdc 100644 --- a/protoc_plugin/test/test_util.dart +++ b/protoc_plugin/test/test_util.dart @@ -9,7 +9,7 @@ import 'package:test/test.dart'; import '../out/protos/google/protobuf/unittest.pb.dart'; import '../out/protos/google/protobuf/unittest_import.pb.dart'; -final Matcher throwsATypeError = throwsA(TypeMatcher()); +final Matcher throwsATypeError = throwsA(isA()); Int64 make64(int lo, [int? hi]) { hi ??= lo < 0 ? -1 : 0; diff --git a/protoc_plugin/test/to_builder_test.dart b/protoc_plugin/test/to_builder_test.dart index f2b770fe6..9a22f533a 100644 --- a/protoc_plugin/test/to_builder_test.dart +++ b/protoc_plugin/test/to_builder_test.dart @@ -27,22 +27,22 @@ void main() { test('frozen message cannot be modified', () { expect(() => original.inner = (Inner()..value = 'bar'), - throwsA(TypeMatcher())); + throwsA(isA())); expect(() => original.inner..value = 'bar', - throwsA(TypeMatcher())); + throwsA(isA())); expect(() => original.inners.add(Inner()..value = 'bar'), - throwsA(TypeMatcher())); + throwsA(isA())); }); test('extensions cannot be modified', () { expect(() => original.setExtension(FooExt.inner, Inner()..value = 'bar'), - throwsA(TypeMatcher())); + throwsA(isA())); expect(() => original.getExtension(FooExt.inner).value = 'bar', - throwsA(TypeMatcher())); + throwsA(isA())); expect( () => original.getExtension(FooExt.inners).add(Inner()..value = 'bar'), - throwsA(TypeMatcher())); + throwsA(isA())); }); final builder = original.toBuilder() as Outer; @@ -69,8 +69,8 @@ void main() { test( 'the builder is only a shallow copy, the nested message is still frozen.', () { - expect(() => builder.inner.value = 'bar', - throwsA(TypeMatcher())); + expect( + () => builder.inner.value = 'bar', throwsA(isA())); }); test('the builder is mutable', () { builder.inner = (Inner()..value = 'zop'); @@ -150,41 +150,38 @@ void main() { expect( () => builder.unknownFields.getField(1)!.lengthDelimited[0] = utf8.encode('alice'), - throwsA(TypeMatcher())); + throwsA(isA())); }); test('cannot add to a frozen UnknownFieldSetField', () { emptyMessage.freeze(); + expect(() => field.addFixed32(1), throwsA(isA())); + expect(() => field.fixed32s.add(1), throwsA(isA())); + expect( + () => field.addFixed64(Int64(1)), throwsA(isA())); expect( - () => field.addFixed32(1), throwsA(TypeMatcher())); - expect(() => field.fixed32s.add(1), - throwsA(TypeMatcher())); - expect(() => field.addFixed64(Int64(1)), - throwsA(TypeMatcher())); - expect(() => field.fixed64s.add(Int64(1)), - throwsA(TypeMatcher())); + () => field.fixed64s.add(Int64(1)), throwsA(isA())); expect(() => field.addLengthDelimited([1]), - throwsA(TypeMatcher())); + throwsA(isA())); expect(() => field.lengthDelimited.add([1]), - throwsA(TypeMatcher())); + throwsA(isA())); expect(() => field.addGroup(unknownFieldSet.clone()), - throwsA(TypeMatcher())); + throwsA(isA())); expect(() => field.groups.add(unknownFieldSet.clone()), - throwsA(TypeMatcher())); - expect(() => field.addVarint(Int64(1)), - throwsA(TypeMatcher())); - expect(() => field.varints.add(Int64(1)), - throwsA(TypeMatcher())); + throwsA(isA())); + expect(() => field.addVarint(Int64(1)), throwsA(isA())); + expect( + () => field.varints.add(Int64(1)), throwsA(isA())); }); test('cannot add or merge field to a frozen UnknownFieldSet', () { emptyMessage.freeze(); expect(() => unknownFieldSet.addField(2, field), - throwsA(TypeMatcher())); + throwsA(isA())); expect(() => unknownFieldSet.mergeField(2, field), - throwsA(TypeMatcher())); + throwsA(isA())); }); test('cannot merge message into a frozen UnknownFieldSet', () { @@ -192,16 +189,16 @@ void main() { final other = emptyMessage.deepCopy(); expect(() => emptyMessage.mergeFromBuffer(other.writeToBuffer()), - throwsA(TypeMatcher())); + throwsA(isA())); expect(() => emptyMessage.mergeFromMessage(other), - throwsA(TypeMatcher())); + throwsA(isA())); }); test('cannot add a field to a frozen UnknownFieldSet', () { emptyMessage.freeze(); expect(() => unknownFieldSet.addField(tagNumber, field), - throwsA(TypeMatcher())); + throwsA(isA())); }); }); } From 047d05b513b93a2ca5876dd0c52a293e3c7b7b9b Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Wed, 6 Mar 2024 13:17:23 -0800 Subject: [PATCH 2/4] versioning --- .github/workflows/dart.yml | 58 ++++++++++++------------ api_benchmark/pubspec.yaml | 2 +- benchmarks/pubspec.yaml | 2 +- protobuf/CHANGELOG.md | 2 + protobuf/lib/src/protobuf/field_set.dart | 4 +- protobuf/pubspec.yaml | 2 +- protoc_plugin/CHANGELOG.md | 1 + protoc_plugin/lib/indenting_writer.dart | 2 +- protoc_plugin/lib/testing/mixins.dart | 6 +-- protoc_plugin/pubspec.yaml | 2 +- tool/ci.sh | 18 +++----- 11 files changed, 49 insertions(+), 50 deletions(-) diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index 325f6b538..9c61106eb 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -1,4 +1,4 @@ -# Created with package:mono_repo v6.5.7 +# Created with package:mono_repo v6.6.1 name: Dart CI on: push: @@ -35,27 +35,27 @@ jobs: name: Checkout repository uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 - name: mono_repo self validate - run: dart pub global activate mono_repo 6.5.7 + run: dart pub global activate mono_repo 6.6.1 - name: mono_repo self validate run: dart pub global run mono_repo generate --validate job_002: - name: "format_analyze; linux; Dart 2.19.0; PKG: protobuf; `dart analyze lib`, `dart analyze test`" + name: "format_analyze; linux; Dart 3.3.0; PKG: protobuf; `dart analyze lib`, `dart analyze test`" runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319 with: path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:2.19.0;packages:protobuf;commands:analyze_1-analyze_2" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.3.0;packages:protobuf;commands:analyze_1-analyze_2" restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:2.19.0;packages:protobuf - os:ubuntu-latest;pub-cache-hosted;sdk:2.19.0 + os:ubuntu-latest;pub-cache-hosted;sdk:3.3.0;packages:protobuf + os:ubuntu-latest;pub-cache-hosted;sdk:3.3.0 os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 with: - sdk: "2.19.0" + sdk: "3.3.0" - id: checkout name: Checkout repository uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 @@ -233,23 +233,23 @@ jobs: if: "always() && steps.protoc_plugin_pub_upgrade.conclusion == 'success'" working-directory: protoc_plugin job_007: - name: "run_tests; linux; Dart 2.19.0; PKG: protobuf; `dart test`" + name: "run_tests; linux; Dart 3.3.0; PKG: protobuf; `dart test`" runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies 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" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.3.0;packages:protobuf;commands:test_0" restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:2.19.0;packages:protobuf - os:ubuntu-latest;pub-cache-hosted;sdk:2.19.0 + os:ubuntu-latest;pub-cache-hosted;sdk:3.3.0;packages:protobuf + os:ubuntu-latest;pub-cache-hosted;sdk:3.3.0 os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 with: - sdk: "2.19.0" + sdk: "3.3.0" - id: checkout name: Checkout repository uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 @@ -270,23 +270,23 @@ jobs: - job_005 - job_006 job_008: - name: "run_tests; linux; Dart 2.19.0; PKG: protoc_plugin; `./../tool/setup.sh`, `make protos`, `dart test`" + name: "run_tests; linux; Dart 3.3.0; PKG: protoc_plugin; `./../tool/setup.sh`, `make protos`, `dart test`" runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies 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" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.3.0;packages:protoc_plugin;commands:command_0-command_3-test_0" restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:2.19.0;packages:protoc_plugin - os:ubuntu-latest;pub-cache-hosted;sdk:2.19.0 + os:ubuntu-latest;pub-cache-hosted;sdk:3.3.0;packages:protoc_plugin + os:ubuntu-latest;pub-cache-hosted;sdk:3.3.0 os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 with: - sdk: "2.19.0" + sdk: "3.3.0" - id: checkout name: Checkout repository uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 @@ -397,23 +397,23 @@ jobs: - job_005 - job_006 job_011: - name: "run_tests; osx; Dart 2.19.0; PKG: protobuf; `dart test`" + name: "run_tests; osx; Dart 3.3.0; PKG: protobuf; `dart test`" runs-on: macos-latest steps: - name: Cache Pub hosted dependencies 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" + key: "os:macos-latest;pub-cache-hosted;sdk:3.3.0;packages:protobuf;commands:test_0" restore-keys: | - os:macos-latest;pub-cache-hosted;sdk:2.19.0;packages:protobuf - os:macos-latest;pub-cache-hosted;sdk:2.19.0 + os:macos-latest;pub-cache-hosted;sdk:3.3.0;packages:protobuf + os:macos-latest;pub-cache-hosted;sdk:3.3.0 os:macos-latest;pub-cache-hosted os:macos-latest - name: Setup Dart SDK uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 with: - sdk: "2.19.0" + sdk: "3.3.0" - id: checkout name: Checkout repository uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 @@ -471,13 +471,13 @@ jobs: - job_005 - job_006 job_013: - name: "run_tests; windows; Dart 2.19.0; PKG: protobuf; `dart test`" + name: "run_tests; windows; Dart 3.3.0; PKG: protobuf; `dart test`" runs-on: windows-latest steps: - name: Setup Dart SDK uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 with: - sdk: "2.19.0" + sdk: "3.3.0" - id: checkout name: Checkout repository uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 @@ -525,23 +525,23 @@ jobs: - job_005 - job_006 job_015: - name: "run_legacy_tests; linux; Dart 2.19.0; PKG: protoc_plugin; `./../tool/setup.sh`, `make protos`, `dart test legacy_tests/generated_message_test.dart`" + name: "run_legacy_tests; linux; Dart 3.3.0; PKG: protoc_plugin; `./../tool/setup.sh`, `make protos`, `dart test legacy_tests/generated_message_test.dart`" runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies 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" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.3.0;packages:protoc_plugin;commands:command_0-command_3-test_1" restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:2.19.0;packages:protoc_plugin - os:ubuntu-latest;pub-cache-hosted;sdk:2.19.0 + os:ubuntu-latest;pub-cache-hosted;sdk:3.3.0;packages:protoc_plugin + os:ubuntu-latest;pub-cache-hosted;sdk:3.3.0 os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 with: - sdk: "2.19.0" + sdk: "3.3.0" - id: checkout name: Checkout repository uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 diff --git a/api_benchmark/pubspec.yaml b/api_benchmark/pubspec.yaml index 9c62c1ab3..f98dfdb9b 100644 --- a/api_benchmark/pubspec.yaml +++ b/api_benchmark/pubspec.yaml @@ -9,7 +9,7 @@ description: Benchmarking a number of different api calls. publish_to: none environment: - sdk: '>=2.19.0 <3.0.0' + sdk: ^3.3.0 dependencies: fixnum: any diff --git a/benchmarks/pubspec.yaml b/benchmarks/pubspec.yaml index 330c4fbfd..ac23f0ce9 100644 --- a/benchmarks/pubspec.yaml +++ b/benchmarks/pubspec.yaml @@ -7,7 +7,7 @@ description: Benchmarks various protobuf functions publish_to: none environment: - sdk: '>=2.19.0 <3.0.0' + sdk: ^3.3.0 dependencies: # NB. When bumping benchmark_harness check if `benchmark_base.BenchmarkBase` diff --git a/protobuf/CHANGELOG.md b/protobuf/CHANGELOG.md index 32a41e693..02653662f 100644 --- a/protobuf/CHANGELOG.md +++ b/protobuf/CHANGELOG.md @@ -1,5 +1,7 @@ ## 4.0.0-dev +* Require Dart 3.3 + * **Breaking:** The following types and members are now removed: - `PbEventMixin` diff --git a/protobuf/lib/src/protobuf/field_set.dart b/protobuf/lib/src/protobuf/field_set.dart index bd9799116..15c36586d 100644 --- a/protobuf/lib/src/protobuf/field_set.dart +++ b/protobuf/lib/src/protobuf/field_set.dart @@ -337,7 +337,7 @@ class _FieldSet { if (currentOneofTag != null) { _clearField(currentOneofTag); } - _oneofCases![oneofIndex] = tag; + _oneofCases[oneofIndex] = tag; } _values[fi.index!] = value; @@ -485,7 +485,7 @@ class _FieldSet { if (currentOneofTag != null) { _clearField(currentOneofTag); } - _oneofCases![oneofIndex] = tag; + _oneofCases[oneofIndex] = tag; } _values[index] = value; } diff --git a/protobuf/pubspec.yaml b/protobuf/pubspec.yaml index 5b63c9aad..321e89b5d 100644 --- a/protobuf/pubspec.yaml +++ b/protobuf/pubspec.yaml @@ -6,7 +6,7 @@ description: >- repository: https://github.com/google/protobuf.dart/tree/master/protobuf environment: - sdk: '>=2.19.0 <4.0.0' + sdk: ^3.3.0 dependencies: collection: ^1.15.0 diff --git a/protoc_plugin/CHANGELOG.md b/protoc_plugin/CHANGELOG.md index 1d56341df..112201cb1 100644 --- a/protoc_plugin/CHANGELOG.md +++ b/protoc_plugin/CHANGELOG.md @@ -1,5 +1,6 @@ ## 22.0.0-dev +* Require Dart 3.3 * Remove `PbEventMixin` mixin. ([#738]) * Type of repeated fields is now `PbList` (instead of `List`), type of map fields is now `PbMap` (instead of `Map`). ([#903]) diff --git a/protoc_plugin/lib/indenting_writer.dart b/protoc_plugin/lib/indenting_writer.dart index f6b8dae43..307b7856e 100644 --- a/protoc_plugin/lib/indenting_writer.dart +++ b/protoc_plugin/lib/indenting_writer.dart @@ -159,7 +159,7 @@ class IndentingWriter { } final annotation = GeneratedCodeInfo_Annotation() ..path.addAll(fieldPath) - ..sourceFile = _sourceFile! + ..sourceFile = _sourceFile ..begin = _previousOffset + start ..end = _previousOffset + start + name.length; sourceLocationInfo.annotation.add(annotation); diff --git a/protoc_plugin/lib/testing/mixins.dart b/protoc_plugin/lib/testing/mixins.dart index c735f1def..4fd460710 100644 --- a/protoc_plugin/lib/testing/mixins.dart +++ b/protoc_plugin/lib/testing/mixins.dart @@ -1,4 +1,4 @@ -abstract class Mixin1 { +abstract mixin class Mixin1 { String get overriddenString => 'mixin1'; String get interfaceString; @@ -6,10 +6,10 @@ abstract class Mixin1 { bool hasInterfaceString(); } -abstract class Mixin2 { +abstract mixin class Mixin2 { String get overriddenString => 'mixin2'; bool hasOverriddenHasMethod() => false; } -abstract class Mixin3 {} +abstract mixin class Mixin3 {} diff --git a/protoc_plugin/pubspec.yaml b/protoc_plugin/pubspec.yaml index 28d46c276..7fdf30d16 100644 --- a/protoc_plugin/pubspec.yaml +++ b/protoc_plugin/pubspec.yaml @@ -4,7 +4,7 @@ description: A protobuf protoc compiler plugin used to generate Dart code. repository: https://github.com/google/protobuf.dart/tree/master/protoc_plugin environment: - sdk: '>=2.19.0 <4.0.0' + sdk: ^3.3.0 dependencies: fixnum: ^1.0.0 diff --git a/tool/ci.sh b/tool/ci.sh index a824f9d2b..bf376f724 100755 --- a/tool/ci.sh +++ b/tool/ci.sh @@ -1,9 +1,10 @@ #!/bin/bash -# Created with package:mono_repo v6.5.7 +# Created with package:mono_repo v6.6.1 # Support built in commands on windows out of the box. + # When it is a flutter repo (check the pubspec.yaml for "sdk: flutter") -# then "flutter" is called instead of "pub". +# then "flutter pub" is called instead of "dart pub". # This assumes that the Flutter SDK has been installed in a previous step. function pub() { if grep -Fq "sdk: flutter" "${PWD}/pubspec.yaml"; then @@ -12,18 +13,13 @@ function pub() { command dart pub "$@" fi } -# When it is a flutter repo (check the pubspec.yaml for "sdk: flutter") -# then "flutter" is called instead of "pub". -# This assumes that the Flutter SDK has been installed in a previous step. + function format() { - if grep -Fq "sdk: flutter" "${PWD}/pubspec.yaml"; then - command flutter format "$@" - else - command dart format "$@" - fi + command dart format "$@" } + # When it is a flutter repo (check the pubspec.yaml for "sdk: flutter") -# then "flutter" is called instead of "pub". +# then "flutter analyze" is called instead of "dart analyze". # This assumes that the Flutter SDK has been installed in a previous step. function analyze() { if grep -Fq "sdk: flutter" "${PWD}/pubspec.yaml"; then From f4f14c918a48950480157b6293e034ef90e92e4e Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Wed, 6 Mar 2024 13:17:55 -0800 Subject: [PATCH 3/4] also generate things --- .../lib/src/generated/dart_options.pb.dart | 4 +- .../lib/src/generated/descriptor.pb.dart | 74 ++++++++++--------- .../lib/src/generated/descriptor.pbenum.dart | 24 ++++++ .../lib/src/generated/plugin.pb.dart | 8 +- 4 files changed, 70 insertions(+), 40 deletions(-) diff --git a/protoc_plugin/lib/src/generated/dart_options.pb.dart b/protoc_plugin/lib/src/generated/dart_options.pb.dart index f045820bd..b4421402b 100644 --- a/protoc_plugin/lib/src/generated/dart_options.pb.dart +++ b/protoc_plugin/lib/src/generated/dart_options.pb.dart @@ -13,6 +13,8 @@ import 'dart:core' as $core; import 'package:protobuf/protobuf.dart' as $pb; +export 'package:protobuf/protobuf.dart' show GeneratedMessageGenericExtensions; + /// A mixin that can be used in the 'with' clause of the generated Dart class /// for a proto message. class DartMixin extends $pb.GeneratedMessage { @@ -171,7 +173,7 @@ class Imports extends $pb.GeneratedMessage { /// so the generated code may contain errors. Therefore, running dartanalyzer /// on the generated file is a good idea. @$pb.TagNumber(1) - $core.List get mixins => $_getList(0); + $pb.PbList get mixins => $_getList(0); } class Dart_options { diff --git a/protoc_plugin/lib/src/generated/descriptor.pb.dart b/protoc_plugin/lib/src/generated/descriptor.pb.dart index d367d33e5..eaf04fc31 100644 --- a/protoc_plugin/lib/src/generated/descriptor.pb.dart +++ b/protoc_plugin/lib/src/generated/descriptor.pb.dart @@ -16,6 +16,8 @@ import 'package:protobuf/protobuf.dart' as $pb; import 'descriptor.pbenum.dart'; +export 'package:protobuf/protobuf.dart' show GeneratedMessageGenericExtensions; + export 'descriptor.pbenum.dart'; /// The protocol compiler can output a FileDescriptorSet containing the .proto @@ -71,7 +73,7 @@ class FileDescriptorSet extends $pb.GeneratedMessage { static FileDescriptorSet? _defaultInstance; @$pb.TagNumber(1) - $core.List get file => $_getList(0); + $pb.PbList get file => $_getList(0); } /// Describes a complete .proto file. @@ -216,20 +218,20 @@ class FileDescriptorProto extends $pb.GeneratedMessage { /// Names of files imported by this file. @$pb.TagNumber(3) - $core.List<$core.String> get dependency => $_getList(2); + $pb.PbList<$core.String> get dependency => $_getList(2); /// All top-level definitions in this file. @$pb.TagNumber(4) - $core.List get messageType => $_getList(3); + $pb.PbList get messageType => $_getList(3); @$pb.TagNumber(5) - $core.List get enumType => $_getList(4); + $pb.PbList get enumType => $_getList(4); @$pb.TagNumber(6) - $core.List get service => $_getList(5); + $pb.PbList get service => $_getList(5); @$pb.TagNumber(7) - $core.List get extension => $_getList(6); + $pb.PbList get extension => $_getList(6); @$pb.TagNumber(8) FileOptions get options => $_getN(7); @@ -265,12 +267,12 @@ class FileDescriptorProto extends $pb.GeneratedMessage { /// Indexes of the public imported files in the dependency list above. @$pb.TagNumber(10) - $core.List<$core.int> get publicDependency => $_getList(9); + $pb.PbList<$core.int> get publicDependency => $_getList(9); /// Indexes of the weak imported files in the dependency list. /// For Google-internal migration only. Do not use. @$pb.TagNumber(11) - $core.List<$core.int> get weakDependency => $_getList(10); + $pb.PbList<$core.int> get weakDependency => $_getList(10); /// The syntax of the proto file. /// The supported values are "proto2" and "proto3". @@ -597,19 +599,19 @@ class DescriptorProto extends $pb.GeneratedMessage { void clearName() => $_clearField(1); @$pb.TagNumber(2) - $core.List get field => $_getList(1); + $pb.PbList get field => $_getList(1); @$pb.TagNumber(3) - $core.List get nestedType => $_getList(2); + $pb.PbList get nestedType => $_getList(2); @$pb.TagNumber(4) - $core.List get enumType => $_getList(3); + $pb.PbList get enumType => $_getList(3); @$pb.TagNumber(5) - $core.List get extensionRange => $_getList(4); + $pb.PbList get extensionRange => $_getList(4); @$pb.TagNumber(6) - $core.List get extension => $_getList(5); + $pb.PbList get extension => $_getList(5); @$pb.TagNumber(7) MessageOptions get options => $_getN(6); @@ -626,15 +628,15 @@ class DescriptorProto extends $pb.GeneratedMessage { MessageOptions ensureOptions() => $_ensure(6); @$pb.TagNumber(8) - $core.List get oneofDecl => $_getList(7); + $pb.PbList get oneofDecl => $_getList(7); @$pb.TagNumber(9) - $core.List get reservedRange => $_getList(8); + $pb.PbList get reservedRange => $_getList(8); /// Reserved field names, which may not be used by fields in the same message. /// A given name may only be reserved once. @$pb.TagNumber(10) - $core.List<$core.String> get reservedName => $_getList(9); + $pb.PbList<$core.String> get reservedName => $_getList(9); } class ExtensionRangeOptions extends $pb.GeneratedMessage { @@ -692,7 +694,7 @@ class ExtensionRangeOptions extends $pb.GeneratedMessage { /// The parser stores options it doesn't recognize here. See above. @$pb.TagNumber(999) - $core.List get uninterpretedOption => $_getList(0); + $pb.PbList get uninterpretedOption => $_getList(0); } /// Describes a field within a message. @@ -1241,7 +1243,7 @@ class EnumDescriptorProto extends $pb.GeneratedMessage { void clearName() => $_clearField(1); @$pb.TagNumber(2) - $core.List get value => $_getList(1); + $pb.PbList get value => $_getList(1); @$pb.TagNumber(3) EnumOptions get options => $_getN(2); @@ -1261,13 +1263,13 @@ class EnumDescriptorProto extends $pb.GeneratedMessage { /// by enum values in the same enum declaration. Reserved ranges may not /// overlap. @$pb.TagNumber(4) - $core.List get reservedRange => + $pb.PbList get reservedRange => $_getList(3); /// Reserved enum value names, which may not be reused. A given name may only /// be reserved once. @$pb.TagNumber(5) - $core.List<$core.String> get reservedName => $_getList(4); + $pb.PbList<$core.String> get reservedName => $_getList(4); } /// Describes a value within an enum. @@ -1448,7 +1450,7 @@ class ServiceDescriptorProto extends $pb.GeneratedMessage { void clearName() => $_clearField(1); @$pb.TagNumber(2) - $core.List get method => $_getList(1); + $pb.PbList get method => $_getList(1); @$pb.TagNumber(3) ServiceOptions get options => $_getN(2); @@ -2087,7 +2089,7 @@ class FileOptions extends $pb.GeneratedMessage { /// The parser stores options it doesn't recognize here. /// See the documentation for the "Options" section above. @$pb.TagNumber(999) - $core.List get uninterpretedOption => $_getList(20); + $pb.PbList get uninterpretedOption => $_getList(20); } class MessageOptions extends $pb.GeneratedMessage { @@ -2257,7 +2259,7 @@ class MessageOptions extends $pb.GeneratedMessage { /// The parser stores options it doesn't recognize here. See above. @$pb.TagNumber(999) - $core.List get uninterpretedOption => $_getList(4); + $pb.PbList get uninterpretedOption => $_getList(4); } class FieldOptions extends $pb.GeneratedMessage { @@ -2476,7 +2478,7 @@ class FieldOptions extends $pb.GeneratedMessage { /// The parser stores options it doesn't recognize here. See above. @$pb.TagNumber(999) - $core.List get uninterpretedOption => $_getList(6); + $pb.PbList get uninterpretedOption => $_getList(6); } class OneofOptions extends $pb.GeneratedMessage { @@ -2532,7 +2534,7 @@ class OneofOptions extends $pb.GeneratedMessage { /// The parser stores options it doesn't recognize here. See above. @$pb.TagNumber(999) - $core.List get uninterpretedOption => $_getList(0); + $pb.PbList get uninterpretedOption => $_getList(0); } class EnumOptions extends $pb.GeneratedMessage { @@ -2627,7 +2629,7 @@ class EnumOptions extends $pb.GeneratedMessage { /// The parser stores options it doesn't recognize here. See above. @$pb.TagNumber(999) - $core.List get uninterpretedOption => $_getList(2); + $pb.PbList get uninterpretedOption => $_getList(2); } class EnumValueOptions extends $pb.GeneratedMessage { @@ -2704,7 +2706,7 @@ class EnumValueOptions extends $pb.GeneratedMessage { /// The parser stores options it doesn't recognize here. See above. @$pb.TagNumber(999) - $core.List get uninterpretedOption => $_getList(1); + $pb.PbList get uninterpretedOption => $_getList(1); } class ServiceOptions extends $pb.GeneratedMessage { @@ -2781,7 +2783,7 @@ class ServiceOptions extends $pb.GeneratedMessage { /// The parser stores options it doesn't recognize here. See above. @$pb.TagNumber(999) - $core.List get uninterpretedOption => $_getList(1); + $pb.PbList get uninterpretedOption => $_getList(1); } class MethodOptions extends $pb.GeneratedMessage { @@ -2879,7 +2881,7 @@ class MethodOptions extends $pb.GeneratedMessage { /// The parser stores options it doesn't recognize here. See above. @$pb.TagNumber(999) - $core.List get uninterpretedOption => $_getList(2); + $pb.PbList get uninterpretedOption => $_getList(2); } /// The name of the uninterpreted option. Each string represents a segment in @@ -3061,7 +3063,7 @@ class UninterpretedOption extends $pb.GeneratedMessage { static UninterpretedOption? _defaultInstance; @$pb.TagNumber(2) - $core.List get name => $_getList(0); + $pb.PbList get name => $_getList(0); /// The value of the uninterpreted option, in whatever type the tokenizer /// identified it as during parsing. Exactly one of these should be set. @@ -3233,7 +3235,7 @@ class SourceCodeInfo_Location extends $pb.GeneratedMessage { /// this path refers to the whole field declaration (from the beginning /// of the label to the terminating semicolon). @$pb.TagNumber(1) - $core.List<$core.int> get path => $_getList(0); + $pb.PbList<$core.int> get path => $_getList(0); /// Always has exactly three or four elements: start line, start column, /// end line (optional, otherwise assumed same as start line), end column. @@ -3241,7 +3243,7 @@ class SourceCodeInfo_Location extends $pb.GeneratedMessage { /// and column numbers are zero-based -- typically you will want to add /// 1 to each before displaying to a user. @$pb.TagNumber(2) - $core.List<$core.int> get span => $_getList(1); + $pb.PbList<$core.int> get span => $_getList(1); /// If this SourceCodeInfo represents a complete declaration, these are any /// comments appearing before and after the declaration which appear to be @@ -3315,7 +3317,7 @@ class SourceCodeInfo_Location extends $pb.GeneratedMessage { void clearTrailingComments() => $_clearField(4); @$pb.TagNumber(6) - $core.List<$core.String> get leadingDetachedComments => $_getList(4); + $pb.PbList<$core.String> get leadingDetachedComments => $_getList(4); } /// Encapsulates information about the original source file from which a @@ -3415,7 +3417,7 @@ class SourceCodeInfo extends $pb.GeneratedMessage { /// ignore those that it doesn't understand, as more types of locations could /// be recorded in the future. @$pb.TagNumber(1) - $core.List get location => $_getList(0); + $pb.PbList get location => $_getList(0); } class GeneratedCodeInfo_Annotation extends $pb.GeneratedMessage { @@ -3489,7 +3491,7 @@ class GeneratedCodeInfo_Annotation extends $pb.GeneratedMessage { /// Identifies the element in the original source .proto file. This field /// is formatted the same as SourceCodeInfo.Location.path. @$pb.TagNumber(1) - $core.List<$core.int> get path => $_getList(0); + $pb.PbList<$core.int> get path => $_getList(0); /// Identifies the filesystem path to the original source .proto. @$pb.TagNumber(2) @@ -3591,7 +3593,7 @@ class GeneratedCodeInfo extends $pb.GeneratedMessage { /// An Annotation connects some span of text in generated code to an element /// of its generating .proto file. @$pb.TagNumber(1) - $core.List get annotation => $_getList(0); + $pb.PbList get annotation => $_getList(0); } const _omitFieldNames = $core.bool.fromEnvironment('protobuf.omit_field_names'); diff --git a/protoc_plugin/lib/src/generated/descriptor.pbenum.dart b/protoc_plugin/lib/src/generated/descriptor.pbenum.dart index 8b92c04a8..579a37286 100644 --- a/protoc_plugin/lib/src/generated/descriptor.pbenum.dart +++ b/protoc_plugin/lib/src/generated/descriptor.pbenum.dart @@ -14,14 +14,22 @@ import 'dart:core' as $core; import 'package:protobuf/protobuf.dart' as $pb; class FieldDescriptorProto_Type extends $pb.ProtobufEnum { + /// 0 is reserved for errors. + /// Order is weird for historical reasons. static const FieldDescriptorProto_Type TYPE_DOUBLE = FieldDescriptorProto_Type._(1, _omitEnumNames ? '' : 'TYPE_DOUBLE'); static const FieldDescriptorProto_Type TYPE_FLOAT = FieldDescriptorProto_Type._(2, _omitEnumNames ? '' : 'TYPE_FLOAT'); + + /// Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if + /// negative values are likely. static const FieldDescriptorProto_Type TYPE_INT64 = FieldDescriptorProto_Type._(3, _omitEnumNames ? '' : 'TYPE_INT64'); static const FieldDescriptorProto_Type TYPE_UINT64 = FieldDescriptorProto_Type._(4, _omitEnumNames ? '' : 'TYPE_UINT64'); + + /// Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if + /// negative values are likely. static const FieldDescriptorProto_Type TYPE_INT32 = FieldDescriptorProto_Type._(5, _omitEnumNames ? '' : 'TYPE_INT32'); static const FieldDescriptorProto_Type TYPE_FIXED64 = @@ -32,10 +40,17 @@ class FieldDescriptorProto_Type extends $pb.ProtobufEnum { FieldDescriptorProto_Type._(8, _omitEnumNames ? '' : 'TYPE_BOOL'); static const FieldDescriptorProto_Type TYPE_STRING = FieldDescriptorProto_Type._(9, _omitEnumNames ? '' : 'TYPE_STRING'); + + /// Tag-delimited aggregate. + /// Group type is deprecated and not supported in proto3. However, Proto3 + /// implementations should still be able to parse the group wire format and + /// treat group fields as unknown fields. static const FieldDescriptorProto_Type TYPE_GROUP = FieldDescriptorProto_Type._(10, _omitEnumNames ? '' : 'TYPE_GROUP'); static const FieldDescriptorProto_Type TYPE_MESSAGE = FieldDescriptorProto_Type._(11, _omitEnumNames ? '' : 'TYPE_MESSAGE'); + + /// New in version 2. static const FieldDescriptorProto_Type TYPE_BYTES = FieldDescriptorProto_Type._(12, _omitEnumNames ? '' : 'TYPE_BYTES'); static const FieldDescriptorProto_Type TYPE_UINT32 = @@ -81,6 +96,7 @@ class FieldDescriptorProto_Type extends $pb.ProtobufEnum { } class FieldDescriptorProto_Label extends $pb.ProtobufEnum { + /// 0 is reserved for errors static const FieldDescriptorProto_Label LABEL_OPTIONAL = FieldDescriptorProto_Label._(1, _omitEnumNames ? '' : 'LABEL_OPTIONAL'); static const FieldDescriptorProto_Label LABEL_REQUIRED = @@ -107,6 +123,8 @@ class FieldDescriptorProto_Label extends $pb.ProtobufEnum { class FileOptions_OptimizeMode extends $pb.ProtobufEnum { static const FileOptions_OptimizeMode SPEED = FileOptions_OptimizeMode._(1, _omitEnumNames ? '' : 'SPEED'); + + /// etc. static const FileOptions_OptimizeMode CODE_SIZE = FileOptions_OptimizeMode._(2, _omitEnumNames ? '' : 'CODE_SIZE'); static const FileOptions_OptimizeMode LITE_RUNTIME = @@ -127,6 +145,7 @@ class FileOptions_OptimizeMode extends $pb.ProtobufEnum { } class FieldOptions_CType extends $pb.ProtobufEnum { + /// Default mode. static const FieldOptions_CType STRING = FieldOptions_CType._(0, _omitEnumNames ? '' : 'STRING'); static const FieldOptions_CType CORD = @@ -148,10 +167,15 @@ class FieldOptions_CType extends $pb.ProtobufEnum { } class FieldOptions_JSType extends $pb.ProtobufEnum { + /// Use the default type. static const FieldOptions_JSType JS_NORMAL = FieldOptions_JSType._(0, _omitEnumNames ? '' : 'JS_NORMAL'); + + /// Use JavaScript strings. static const FieldOptions_JSType JS_STRING = FieldOptions_JSType._(1, _omitEnumNames ? '' : 'JS_STRING'); + + /// Use JavaScript numbers. static const FieldOptions_JSType JS_NUMBER = FieldOptions_JSType._(2, _omitEnumNames ? '' : 'JS_NUMBER'); diff --git a/protoc_plugin/lib/src/generated/plugin.pb.dart b/protoc_plugin/lib/src/generated/plugin.pb.dart index bad241898..10e6d56e9 100644 --- a/protoc_plugin/lib/src/generated/plugin.pb.dart +++ b/protoc_plugin/lib/src/generated/plugin.pb.dart @@ -16,6 +16,8 @@ import 'package:protobuf/protobuf.dart' as $pb; import 'descriptor.pb.dart' as $0; +export 'package:protobuf/protobuf.dart' show GeneratedMessageGenericExtensions; + export 'plugin.pbenum.dart'; /// The version number of protocol compiler. @@ -204,7 +206,7 @@ class CodeGeneratorRequest extends $pb.GeneratedMessage { /// code generator should generate code only for these files. Each file's /// descriptor will be included in proto_file, below. @$pb.TagNumber(1) - $core.List<$core.String> get fileToGenerate => $_getList(0); + $pb.PbList<$core.String> get fileToGenerate => $_getList(0); /// The generator parameter passed on the command-line. @$pb.TagNumber(2) @@ -249,7 +251,7 @@ class CodeGeneratorRequest extends $pb.GeneratedMessage { /// Type names of fields and extensions in the FileDescriptorProto are always /// fully qualified. @$pb.TagNumber(15) - $core.List<$0.FileDescriptorProto> get protoFile => $_getList(3); + $pb.PbList<$0.FileDescriptorProto> get protoFile => $_getList(3); } /// Represents a single generated file. @@ -525,7 +527,7 @@ class CodeGeneratorResponse extends $pb.GeneratedMessage { void clearSupportedFeatures() => $_clearField(2); @$pb.TagNumber(15) - $core.List get file => $_getList(2); + $pb.PbList get file => $_getList(2); } const _omitFieldNames = $core.bool.fromEnvironment('protobuf.omit_field_names'); From 3eaf741682670a747cf3551b724386ea7e7a424c Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Wed, 6 Mar 2024 13:26:41 -0800 Subject: [PATCH 4/4] drop legacy tests --- .github/workflows/dart.yml | 65 ++--------- .../legacy_tests/generated_message_test.dart | 101 ------------------ protoc_plugin/mono_pkg.yaml | 6 -- tool/ci.sh | 6 +- 4 files changed, 7 insertions(+), 171 deletions(-) delete mode 100644 protoc_plugin/legacy_tests/generated_message_test.dart diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index 9c61106eb..5058f900d 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -240,7 +240,7 @@ jobs: uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319 with: path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.3.0;packages:protobuf;commands:test_0" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.3.0;packages:protobuf;commands:test" restore-keys: | os:ubuntu-latest;pub-cache-hosted;sdk:3.3.0;packages:protobuf os:ubuntu-latest;pub-cache-hosted;sdk:3.3.0 @@ -277,7 +277,7 @@ jobs: uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319 with: path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.3.0;packages:protoc_plugin;commands:command_0-command_3-test_0" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.3.0;packages:protoc_plugin;commands:command_0-command_3-test" restore-keys: | os:ubuntu-latest;pub-cache-hosted;sdk:3.3.0;packages:protoc_plugin os:ubuntu-latest;pub-cache-hosted;sdk:3.3.0 @@ -322,7 +322,7 @@ jobs: uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319 with: path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:protobuf;commands:test_0" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:protobuf;commands:test" restore-keys: | os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:protobuf os:ubuntu-latest;pub-cache-hosted;sdk:dev @@ -359,7 +359,7 @@ jobs: 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" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:protoc_plugin;commands:command_0-command_3-test" restore-keys: | os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:protoc_plugin os:ubuntu-latest;pub-cache-hosted;sdk:dev @@ -404,7 +404,7 @@ jobs: uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319 with: path: "~/.pub-cache/hosted" - key: "os:macos-latest;pub-cache-hosted;sdk:3.3.0;packages:protobuf;commands:test_0" + key: "os:macos-latest;pub-cache-hosted;sdk:3.3.0;packages:protobuf;commands:test" restore-keys: | os:macos-latest;pub-cache-hosted;sdk:3.3.0;packages:protobuf os:macos-latest;pub-cache-hosted;sdk:3.3.0 @@ -441,7 +441,7 @@ jobs: uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319 with: path: "~/.pub-cache/hosted" - key: "os:macos-latest;pub-cache-hosted;sdk:dev;packages:protobuf;commands:test_0" + key: "os:macos-latest;pub-cache-hosted;sdk:dev;packages:protobuf;commands:test" restore-keys: | os:macos-latest;pub-cache-hosted;sdk:dev;packages:protobuf os:macos-latest;pub-cache-hosted;sdk:dev @@ -524,56 +524,3 @@ jobs: - job_004 - job_005 - job_006 - job_015: - name: "run_legacy_tests; linux; Dart 3.3.0; PKG: protoc_plugin; `./../tool/setup.sh`, `make protos`, `dart test legacy_tests/generated_message_test.dart`" - runs-on: ubuntu-latest - steps: - - name: Cache Pub hosted dependencies - uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319 - with: - path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.3.0;packages:protoc_plugin;commands:command_0-command_3-test_1" - restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:3.3.0;packages:protoc_plugin - os:ubuntu-latest;pub-cache-hosted;sdk:3.3.0 - os:ubuntu-latest;pub-cache-hosted - os:ubuntu-latest - - name: Setup Dart SDK - uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 - with: - sdk: "3.3.0" - - id: checkout - name: Checkout repository - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 - - id: protoc_plugin_pub_upgrade - name: protoc_plugin; dart pub upgrade - run: dart pub upgrade - if: "always() && steps.checkout.conclusion == 'success'" - working-directory: protoc_plugin - - name: protoc_plugin; ./../tool/setup.sh - run: ./../tool/setup.sh - if: "always() && steps.protoc_plugin_pub_upgrade.conclusion == 'success'" - working-directory: protoc_plugin - - name: protoc_plugin; make protos - run: make protos - if: "always() && steps.protoc_plugin_pub_upgrade.conclusion == 'success'" - working-directory: protoc_plugin - - name: protoc_plugin; dart test legacy_tests/generated_message_test.dart - run: dart test legacy_tests/generated_message_test.dart - if: "always() && steps.protoc_plugin_pub_upgrade.conclusion == 'success'" - working-directory: protoc_plugin - needs: - - job_001 - - job_002 - - job_003 - - job_004 - - job_005 - - job_006 - - job_007 - - job_008 - - job_009 - - job_010 - - job_011 - - job_012 - - job_013 - - job_014 diff --git a/protoc_plugin/legacy_tests/generated_message_test.dart b/protoc_plugin/legacy_tests/generated_message_test.dart deleted file mode 100644 index 77dc36d74..000000000 --- a/protoc_plugin/legacy_tests/generated_message_test.dart +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file -// 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=2.11 - -import 'package:test/test.dart'; - -import '../out/protos/google/protobuf/unittest.pb.dart'; -import '../out/protos/toplevel.pb.dart'; -import '../out/protos/toplevel_import.pb.dart' as t; - -void main() { - test('testSettersRejectNull', () { - final message = TestAllTypes(); - expect(() { - message.optionalString = null; - }, throwsArgumentError); - expect(() { - message.optionalBytes = null; - }, throwsArgumentError); - expect(() { - message.optionalNestedMessage = null; - }, throwsArgumentError); - expect(() { - message.optionalNestedMessage = null; - }, throwsArgumentError); - expect(() { - message.optionalNestedEnum = null; - }, throwsArgumentError); - expect(() { - message.repeatedString.add(null); - }, throwsArgumentError); - expect(() { - message.repeatedBytes.add(null); - }, throwsArgumentError); - expect(() { - message.repeatedNestedMessage.add(null); - }, throwsArgumentError); - expect(() { - message.repeatedNestedMessage.add(null); - }, throwsArgumentError); - expect(() { - message.repeatedNestedEnum.add(null); - }, throwsArgumentError); - }); - - test('testRepeatedSettersRejectNull', () { - final message = TestAllTypes(); - - message.repeatedString.addAll(['one', 'two']); - expect(() { - message.repeatedString[1] = null; - }, throwsArgumentError); - - message.repeatedBytes.addAll(['one'.codeUnits, 'two'.codeUnits]); - expect(() { - message.repeatedBytes[1] = null; - }, throwsArgumentError); - - message.repeatedNestedMessage.addAll([ - TestAllTypes_NestedMessage()..bb = 318, - TestAllTypes_NestedMessage()..bb = 456 - ]); - expect(() { - message.repeatedNestedMessage[1] = null; - }, throwsArgumentError); - - message.repeatedNestedEnum - .addAll([TestAllTypes_NestedEnum.FOO, TestAllTypes_NestedEnum.BAR]); - expect(() { - message.repeatedNestedEnum[1] = null; - }, throwsArgumentError); - }); - - test('testRepeatedAppendRejectsNull', () { - final message = TestAllTypes(); - - expect(() { - message.repeatedForeignMessage.addAll([ForeignMessage()..c = 12, null]); - }, throwsArgumentError); - - expect(() { - message.repeatedForeignEnum.addAll([ForeignEnum.FOREIGN_BAZ, null]); - }, throwsArgumentError); - - expect(() { - message.repeatedString.addAll(['one', null]); - }, throwsArgumentError); - - expect(() { - message.repeatedBytes.addAll(['one'.codeUnits, null]); - }, throwsArgumentError); - }); - - test('testToplevel', () { - final message = t.M(); - message.t = T(); - t.SApi(null); - }); -} diff --git a/protoc_plugin/mono_pkg.yaml b/protoc_plugin/mono_pkg.yaml index f7cefe59b..345113da0 100644 --- a/protoc_plugin/mono_pkg.yaml +++ b/protoc_plugin/mono_pkg.yaml @@ -14,9 +14,3 @@ stages: - command: make protos - test sdk: [pubspec, dev] - - run_legacy_tests: - - group: - - command: ./../tool/setup.sh - - command: make protos - - test: legacy_tests/generated_message_test.dart - sdk: [pubspec] diff --git a/tool/ci.sh b/tool/ci.sh index bf376f724..0b23b056a 100755 --- a/tool/ci.sh +++ b/tool/ci.sh @@ -99,14 +99,10 @@ for PKG in ${PKGS}; do echo 'dart format --output=none --set-exit-if-changed .' dart format --output=none --set-exit-if-changed . || EXIT_CODE=$? ;; - test_0) + test) echo 'dart test' dart test || EXIT_CODE=$? ;; - test_1) - echo 'dart test legacy_tests/generated_message_test.dart' - dart test legacy_tests/generated_message_test.dart || EXIT_CODE=$? - ;; *) echo -e "\033[31mUnknown TASK '${TASK}' - TERMINATING JOB\033[0m" exit 64