Skip to content

Obviously incorrect configurations should error or warn #2770

@stuartmorgan-g

Description

@stuartmorgan-g

If I run the following generation script:

  FfiGenerator(
    [...]
    objectiveC: ObjectiveC(
      interfaces: Interfaces(
        includeMember: (Declaration declaration, String member) {
          final String interfaceName = declaration.originalName;
          final String signature = member;
          return switch (interfaceName) {
            'NSFileManager' => <String>{
              'containerURLForSecurityApplicationGroupIdentifier:',
              'defaultManager',
            }.contains(signature),
            'NSURL' => <String>{
              'fileURLWithPath:',
              'URLByAppendingPathComponent:',
            }.contains(signature),
            _ => false,
          };
        },
      ),
    ),
  ).generate();

it succeeds without any warning messages or errors. It also doesn't contain any NSFileManager or NSURL methods, because there's no include directive.

I can see by adding logging that it's calling my includeMember filter for every interface; if it's going to call a method that checks whether to include (interface, method), and also call a method (in this case a default that always returns false) to check whether to include (interface), and the behavior is that both have to return true for a given interface, then it should be either a very prominent warning or an error if include(interface) returns false but includeMember(interface, member) returns true.

(Alternately, the behavior could change such that includeMember overrides include; it's not clear to me what the use case for the current behavior actually is.)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions