File tree Expand file tree Collapse file tree 6 files changed +75
-4
lines changed Expand file tree Collapse file tree 6 files changed +75
-4
lines changed Original file line number Diff line number Diff line change @@ -118,6 +118,18 @@ task:
118118 - else
119119 - ./script/tool_runner.sh version-check --check-for-missing-changes --pr-labels="$CIRRUS_PR_LABELS"
120120 - fi
121+ publishable_bug_workaround_script :
122+ # Workaround for https://github.com/dart-lang/pub/issues/3618
123+ # TODO(stuartmorgan): Remove this once that issue is fixed.
124+ - cd packages/pigeon
125+ - pushd mock_handler_tester; flutter pub get; popd
126+ - pushd e2e_tests/test_objc; flutter pub get; popd
127+ - pushd platform_tests/ios_swift_unit_tests; flutter pub get; popd
128+ - pushd platform_tests/windows_unit_tests; flutter pub get; popd
129+ - pushd platform_tests/ios_unit_tests; flutter pub get; popd
130+ - pushd platform_tests/flutter_null_safe_unit_tests; flutter pub get; popd
131+ - pushd platform_tests/android_kotlin_unit_tests; flutter pub get; popd
132+ - pushd platform_tests/android_unit_tests; flutter pub get; popd
121133 publishable_script : ./script/tool_runner.sh publish-check --allow-pre-release
122134 - name : dart_unit_tests
123135 env :
Original file line number Diff line number Diff line change 1+ ## 4.2.5
2+
3+ * [ dart] Fixes enum parameter handling in Dart test API class.
4+
15## 4.2.4
26
37* [ kotlin] Fixes Kotlin generated sync host api error.
Original file line number Diff line number Diff line change @@ -276,6 +276,8 @@ void _writeFlutterApi(
276276 bool isMockHandler = false ,
277277}) {
278278 assert (api.location == ApiLocation .flutter);
279+ final List <String > customEnumNames =
280+ root.enums.map ((Enum x) => x.name).toList ();
279281 String codecName = _standardMessageCodec;
280282 if (getCodecClasses (api, root).isNotEmpty) {
281283 codecName = _getCodecName (api);
@@ -358,8 +360,14 @@ void _writeFlutterApi(
358360 _makeGenericTypeArguments (arg.type);
359361 final String castCall = _makeGenericCastCall (arg.type);
360362
361- indent.writeln (
362- 'final $argType ? $argName = ($argsArray [$count ] as $genericArgType ?)${castCall .isEmpty ? '' : '?$castCall ' };' );
363+ final String leftHandSide = 'final $argType ? $argName ' ;
364+ if (customEnumNames.contains (arg.type.baseName)) {
365+ indent.writeln (
366+ '$leftHandSide = $argsArray [$count ] == null ? null : $argType .values[$argsArray [$count ] as int];' );
367+ } else {
368+ indent.writeln (
369+ '$leftHandSide = ($argsArray [$count ] as $genericArgType ?)${castCall .isEmpty ? '' : '?$castCall ' };' );
370+ }
363371 if (! arg.type.isNullable) {
364372 indent.writeln (
365373 "assert($argName != null, 'Argument for $channelName was null, expected non-null $argType .');" );
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ import 'dart:mirrors';
99import 'ast.dart' ;
1010
1111/// The current version of pigeon. This must match the version in pubspec.yaml.
12- const String pigeonVersion = '4.2.4 ' ;
12+ const String pigeonVersion = '4.2.5 ' ;
1313
1414/// Read all the content from [stdin] to a String.
1515String readStdin () {
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ name: pigeon
22description : Code generator tool to make communication between Flutter and the host platform type-safe and easier.
33repository : https://github.com/flutter/packages/tree/main/packages/pigeon
44issue_tracker : https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3Apigeon
5- version : 4.2.4 # This must match the version in lib/generator_tools.dart
5+ version : 4.2.5 # This must match the version in lib/generator_tools.dart
66
77environment :
88 sdk : " >=2.12.0 <3.0.0"
Original file line number Diff line number Diff line change @@ -1309,4 +1309,51 @@ name: foobar
13091309 final String code = sink.toString ();
13101310 expect (code, contains ('extends StandardMessageCodec' ));
13111311 });
1312+
1313+ test ('host test code handles enums' , () {
1314+ final Root root = Root (
1315+ apis: < Api > [
1316+ Api (
1317+ name: 'Api' ,
1318+ location: ApiLocation .host,
1319+ dartHostTestHandler: 'ApiMock' ,
1320+ methods: < Method > [
1321+ Method (
1322+ name: 'doit' ,
1323+ returnType: const TypeDeclaration .voidDeclaration (),
1324+ arguments: < NamedType > [
1325+ NamedType (
1326+ type: const TypeDeclaration (
1327+ baseName: 'Enum' ,
1328+ isNullable: false ,
1329+ ),
1330+ name: 'anEnum' )
1331+ ])
1332+ ])
1333+ ],
1334+ classes: < Class > [],
1335+ enums: < Enum > [
1336+ Enum (
1337+ name: 'Enum' ,
1338+ members: < String > [
1339+ 'one' ,
1340+ 'two' ,
1341+ ],
1342+ )
1343+ ],
1344+ );
1345+ final StringBuffer sink = StringBuffer ();
1346+ generateTestDart (
1347+ const DartOptions (),
1348+ root,
1349+ sink,
1350+ dartOutPath: 'code.dart' ,
1351+ testOutPath: 'test.dart' ,
1352+ );
1353+ final String testCode = sink.toString ();
1354+ expect (
1355+ testCode,
1356+ contains (
1357+ 'final Enum? arg_anEnum = args[0] == null ? null : Enum.values[args[0] as int]' ));
1358+ });
13121359}
You can’t perform that action at this time.
0 commit comments