-
Notifications
You must be signed in to change notification settings - Fork 58
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
AF-3082: transform static meta fields #200
Conversation
Security InsightsNo security relevant content was detected by automated scans. Action Items
Questions or Comments? Reach out on HipChat: InfoSec Forum. |
Codecov Report
@@ Coverage Diff @@
## master #200 +/- ##
==========================================
+ Coverage 94.54% 94.57% +0.03%
==========================================
Files 34 34
Lines 1648 1657 +9
==========================================
+ Hits 1558 1567 +9
Misses 90 90 |
@@ -256,6 +256,55 @@ main() { | |||
reason: 'should preserve existing inheritance'); | |||
}); | |||
|
|||
test('with static PropsMeta declaration', () { |
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.
we should also have a test which verifies this functionality on props/state mixins:
test('with static PropsMeta declaration in PropsMixin', () {
final transformedLine = 'static const PropsMeta meta = \$Props(FooPropsMixin);';
setUpAndGenerate('''
@PropsMixin()
class FooPropsMixin {
static const PropsMeta meta = \$metaForFooPropsMixin;
}
'''
);
var transformedSource = transformedFile.getTransformedText();
expect(transformedSource, contains(transformedLine));
});
); | ||
|
||
var transformedSource = transformedFile.getTransformedText(); | ||
expect(transformedSource, contains(transformedLine)); |
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.
I think it might make sense to also verify that the original meta line is not longer present to ensure that the transformer is replacing and not simply adding a line.
expect(transformedSource, contains(transformedLine)); | ||
}); | ||
|
||
test('with static StateMeta declaration', () { |
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.
I think we can combine the StateMeta and PropsMeta tests into 1 test, since any instance of a component will have at least a props class with a meta
field.
.forEach((_field) { | ||
final field = _field as FieldDeclaration; // ignore: avoid_as | ||
|
||
annotations.Accessor accessorMeta = instantiateAnnotation(field, annotations.Accessor); |
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.
Can we skip lines 417-425? I don't think there should ever be an instance where a doNotGenerate()
annotation is added to a meta
field
…aration in PropsMixin and remove unnecessary check for doNotGenerate
final transformedLine = 'static const PropsMeta meta = \$Props(FooPropsMixin);'; | ||
|
||
setUpAndGenerate(''' | ||
@PropsMixin() |
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.
Can we get one more test added that tests this functionality on StateMixin
s?
QA +1
Merging into master. |
Proposed solution to https://jira.atl.workiva.net/browse/AF-3082
Ultimate problem:
In anticipation of the Dart 2 transition, all props and state classes will have a static meta getter that is implemented to point to some symbol that needs to be generated, for example:
The transformer will need to transform this meta static field inline:
How it was fixed:
meta
variable name and replace the initializer to use the appropriateProps()
orState()
implementation within the source file .Testing suggestions:
Code changes and tests make sense
CI passes
@corwinsheahan-wf @evanweible-wf @greglittlefield-wf