Skip to content

[pigeon] Generated Swift code can create un-annotated style violations #178736

@stuartmorgan-g

Description

@stuartmorgan-g

In the Swift generator, we generate a deepEquals and deepHash method with a file-specific suffix to avoid collisions in multi-output use cases.

https://github.com/flutter/packages/blob/34746bb64150c7bbf319a9eee4164b4a5d733b2e/packages/pigeon/lib/src/swift/swift_generator.dart#L1494

However, we don't do any validation or transformation on it to follow Swift conventions, and that bit us in in_app_purchase:

sk2_pigeon.g.swift:76: [AlwaysUseLowerCamelCase] rename 'deepEqualssk2_pigeon' using lowerCamelCase
sk2_pigeon.g.swift:117: [AlwaysUseLowerCamelCase] rename 'deepHashsk2_pigeon' using lowerCamelCase

The issue is that in_app_purchase uses sk2_pigeon as its file name, and we're including the underscore without adding a // swift-format-ignore: AlwaysUseLowerCamelCase like we already do in cases where unconditionally emit underscores.

We should either transform to remove underscores (potentially dangerous; e.g., in theory someone could have foo_bar and fooBar as different output filenames, although I'm not convinced that's a case we actually need to worry about), or we should look for style violations and annotate them.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listp: pigeonrelated to pigeon messaging codegen toolpackageflutter/packages repository. See also p: labels.team-ecosystemOwned by Ecosystem teamtriaged-ecosystemTriaged by Ecosystem team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions