-
Notifications
You must be signed in to change notification settings - Fork 58
CPLAT-4031: Make builder compatible with Dart 2 only boilerplate #227
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
Conversation
TODO: Add tests for decl parsing, impl_generation, and builder that test dart 2 only functionality. (already have integration tests for dart 2 only)
…er_react into dart2_only
Security InsightsNo security relevant content was detected by automated scans. Action Items
Questions or Comments? Reach out on Slack: #support-infosec. |
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.
Looked at everything but the tests, found a couple small things but otherwise looks great!
...eact/component_declaration/builder_integration_tests/abstract_accessor_integration_test.dart
Show resolved
Hide resolved
updateCompanionClass(name, true); | ||
validateMetaField(companionClass, isPropsClass(name) ? 'PropsMeta': 'StateMeta'); | ||
} else { | ||
if (!member.name.name.startsWith(privateSourcePrefix)) { |
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.
On Dart 2, this validation should happen regardless of whether or not the companion class exists. The class should always be prefixed with _$
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.
In other words, I think this check should be moved up to line ~145
|
||
if (variable.initializer != null && | ||
!expectedInitializer.contains(variable.initializer.toString())) { | ||
if (variable.initializer != null && expectedInitializer != variable.initializer.toString()) { |
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.
Just occurred to me that this misses empty initializers, which we shouldn't support anymore
if (variable.initializer != null && expectedInitializer != variable.initializer.toString()) { | |
if (variable.initializer == null || variable.initializer.toString() != expectedInitializer) { |
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.
This is... impressive work @corwinsheahan-wf!
So close... so very, very close!!!
if ((variable?.initializer?.toString() ?? '') != expectedInitializer) { | ||
error( | ||
'Factory variables are stubs for the generated factories, and should not have initializers ' | ||
'unless initialized with a valid variable name for Dart 2 builder compatibility. ' |
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.
This message is leaking some legacy. I think we can drop the "...should not have initializers unless initialized with..." part and just tell them that they "should be initialized with ".
@corwinsheahan-wf Just noticed this when reading the docs updates - any reason the generated factory implementation needs to be public?
|
@evanweible-wf That does need to be public. When a component is a subtype of another component, the super component's factory is referenced as part of the factory for the sub component:
The super and sub components can, and will often be, in separate libs |
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.
+1
Comments have been addressed
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.
+1 to Evan's commit
QA +1
@Workiva/release-management-p |
Ultimate problem:
Currently the
2.0.0-dev
branch only contains support for building on the transition boilerplate.How it was fixed:
@Props()
,@State()
,@AbstractProps()
and@AbstractState()
annotated classes, as well as generated consumable class for props mixins.Testing suggestions:
Potential areas of regression:
Everything