[jnigen] Report an empty config list entry as a config error - #3514
Conversation
|
Hi @Yusufihsangorgel. Sorry for the delay. I wanted to land some updates to the JNIgen config API before I looked at this. The API has been heavily refactored, so you'll need to sync to head to start with. High level feedback:
|
237b3a4 to
0cea928
Compare
| }) : workingDirectory = workingDirectory ?? Uri.directory('.') { | ||
| for (final className in classes) { | ||
| _validateClassName(className); | ||
| final entries = classes.cast<Object?>(); |
There was a problem hiding this comment.
This is weird. Also, your Dart API test has to be very artificial to trigger this.
Maybe a better fix would be to change parseArgs so that this classes field never contains null. Like, default a null string to ''. Then you wouldn't need this check because the existing _validateClassName check throws an error if the name is empty.
There was a problem hiding this comment.
Mapped a null entry to an empty name in parseArgs, as suggested. The class name check never rejected an empty string, and that is the one line I added.
|
Still a TypeError on main for an empty YAML classes entry. The Dart API cannot put that null into |
An empty item under classes reads as a YAML null, and the list is cast lazily, which leaves the first read of that element failing with a TypeError that never names the key.
Now parseArgs maps a null entry to an empty name and the class name check rejects it with a ConfigException. The test writes its own YAML file, since a
-Doverride cannot express an empty list entry.Fixes #1802