-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[native_assets_cli] Cleanup constructors #1867
Conversation
PR HealthBreaking changes ✔️
Changelog Entry ✔️
Changes to files need to be accounted for in their respective changelogs. API leaks ✔️The following packages contain symbols visible in the public API, but not exported by the library. Export these symbols or remove them from your publicly visible API.
License Headers ✔️
All source files should start with a license header. Unrelated files missing license headers
|
This reverts commit e675b19.
Firstly & tangentially related, comment from #1824
This was by-design. The thinking behind it was that API is mainly focused on hook authors, so it's focused on reading the json and were therefore basically views on the json. The only exceptions were "leaf" nodes such as So for all API classes that are effectively read-only views on the json, they are extensible: They know only about some fields, but the json may have extensions they don't know about. It's not a problem because a) they don't take individual fields in constructor b) they don't support So by making Now we had more discussions somewhere recently about extensibility. In general we may not want to have extensions on extensions, but it could be that in some cases the added flexibility may come in handy sometimes). So from that angle I'd lean on making the API classes views on the json unless we really have strong arguments for making them closed (closed == adding constructor with all constituent fields, adding Looking at this PR, I see that the only reason we currently need => If we first prune all code of dry run (all users can upgrade to newest dart / flutter main/dev branches) then it seems to me @dcharkes would that work? Otherwise the change LGTM |
Both before this PR, Which means we have getters that simply return another view on a JSON.
It has access to In a subsequent refactoring I remove the
Authors also want to test their hooks, so they are also going to use the (*) There is currently no nested json yet. Some whiteboarding: We could consider instead of having: builder
..setupHookConfig(...)
..setupBuildConfig(...)
..setupCodeConfig(...)
..setupDataConfig(...); having this: builder.setup([
HookConfig(...),
BuildConfig(...),
CodeConfig(...),
DataConfig(...),
]); Where all these classes implement an interface have an |
Yes, it pulls out the parts (it knows about) out of the json immediately (to get syntax errors) and put them in fields. => This is exactly how So I don't think this is progressive insight, it's just how it was intentionally designed in my refactoring. |
That's somewhat a non-local side-effect. While one can see reasons why one may want it, the pattern of a I think for embedders to supply
Yes, an Though if this method is on API classes (e.g. on It would then probably builder classes (e.g. |
final AndroidConfig? _androidConfig; | ||
final MacOSConfig? _macOSConfig; | ||
|
||
CodeConfig._({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider keeping the old code here and renaming this to
// TODO: Merge with `.fromJson` once dry-run is gone.
CodeConfig._fromJsonAndDryRun(Map<String, Object?> json, bool dryRun) {}
factory CodeConfig.fromJson(Map<String, Object?) json) {
return CodeConfig._fromJsonAndDryRun(json, json.getOptional<bool>(_dryRunConfigKey) ?? false);
}
Otherwise there's high chance someone may want to make it public in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Map<String, Object?> json, bool dryRun
There is no nesting currently, so dryRun
is in the same root level as the code config fields.
Otherwise there's high chance someone may want to make it public in the future.
Left a comment to avoid someone doing this.
I'm confused, why didn't you do this with
Yeah, I think that's a good reason to get rid of
Yeah, indeed. |
Addresses:
CodeConfig
OS-specific config #1824 (comment)@mkustermann Do you prefer repeating the arguments to
CodeConfig
insetupCodeConfig
leading to the following?Or rather avoiding to repeat the arguments and have the following?
I've done the former now, but can easily revert that commit.