packages icon indicating copy to clipboard operation
packages copied to clipboard

[pigeon] Allows swift generator to skip error class generation

Open wamynobe opened this issue 1 year ago • 7 comments

Since the Kotlin generator allows skipping error class generation, it makes sense for the Swift generator to have the same option.

Related to: #6183 https://github.com/flutter/flutter/issues/142099

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

wamynobe avatar Oct 11 '24 10:10 wamynobe

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

google-cla[bot] avatar Oct 11 '24 10:10 google-cla[bot]

Hi @tarrinneal, In your previous PR #6183 , there are a few parts that I don't really understand (mostly about how to generate test files), for example the code kotlinIncludeErrorClass: input != 'core_tests', in packages/pigeon/tool/shared/generation.dart. Could you please guide me through these test cases?

wamynobe avatar Oct 12 '24 15:10 wamynobe

looks like the test cases using the default error class name in Swift have failed.

wamynobe avatar Oct 17 '24 08:10 wamynobe

How can I run those custom_package_tests test cases on my local machine?

wamynobe avatar Oct 17 '24 08:10 wamynobe

if you navigate to the pigeon directory you can run dart run tool/test.dart -f -t ios_swift_integration_tests

tarrinneal avatar Oct 17 '24 13:10 tarrinneal

This code

    final bool kotlinErrorClassGenerationTestFiles =
        input == 'core_tests' || input == 'background_platform_channels';

    final String kotlinErrorName = kotlinErrorClassGenerationTestFiles
        ? 'FlutterError'
        : '${pascalCaseName}Error';

and the corresponding usage of kotlinErrorName ensures that there are two files with the same error class name. You'll need to do that for swift as well.

tarrinneal avatar Oct 17 '24 13:10 tarrinneal

if you navigate to the pigeon directory you can run dart run tool/test.dart -f -t ios_swift_integration_tests

Thanks @tarrinneal I am now able to run those test cases.

and the corresponding usage of kotlinErrorName ensures that there are two files with the same error class name. You'll need to do that for swift as well.

I saw swiftErrorUseDefaultErrorName which has the same purpose as kotlinErrorClassGenerationTestFiles. Updated!

wamynobe avatar Oct 18 '24 02:10 wamynobe

@stuartmorgan for 2nd review

tarrinneal avatar Oct 23 '24 16:10 tarrinneal