[2.0.0-dev - dart2] AF-233 Consume react-dart callable class fixes#155
[2.0.0-dev - dart2] AF-233 Consume react-dart callable class fixes#155aaronlademann-wf merged 21 commits into2.0.0-devfrom
Conversation
Security InsightsNo security relevant content was detected by automated scans. Action Items
Questions or Comments? Reach out on HipChat: InfoSec Forum. |
|
@greglittlefield-wf I don't think we'll be able to get a passing travis build until https://github.com/cleandart/react-dart/pull/142/files is merged / released as |
|
Also, once https://github.com/Workiva/smithy-runner-dart/pull/48 goes through we should be able to get the smithy build passing as well. |
greglittlefield-wf
left a comment
There was a problem hiding this comment.
Looks good, mostly some comments about the map class stuff
| @mustCallSuper | ||
| @override | ||
| void redraw([callback()]) { | ||
| void redraw([Function callback]) { |
There was a problem hiding this comment.
This should be changed back (is this leftover from when it was typed to Function previously in react-dart?)
| /// > Necessary for eventual upgrade to the Dart 2 SDK. | ||
| abstract class _OverReactMapBase<K, V> extends Object implements MapViewMixin<K, V>, Map<K, V> { | ||
| // Manually implement members from `Map` that appear in the Dart 2 SDK | ||
| // without having to extend from `MapBase`. |
There was a problem hiding this comment.
#nit I think this comment implies the wrong thing; we don't want to extend from MapBase because we want to just proxy that map.
Perhaps this class should be called _MapProxy or _OverReactMapView
|
|
||
| // Manually implement members from `MapViewMixin`, | ||
| // since mixing that class in doesn't play well with the DDC. | ||
| // TODO find out root cause and reduced test case. |
There was a problem hiding this comment.
I think this block of comments is now outdated and can be removed, right?
| /// > Note: Implements [MapViewMixin] instead of extending it so that the abstract [Props] declarations | ||
| /// don't need a constructor. The generated implementations can mix that functionality in. | ||
| abstract class UiProps extends MapBase | ||
| abstract class UiProps<K, V> extends _OverReactMapBase<K, V> |
There was a problem hiding this comment.
Is there a reason generic parameters were added to UiProps/UiState (and other places)? I'm concerned that that might introduce type complexity in props class inheritances (which can be problematic in dart2js; see dart-lang/sdk#14729) without providing much benefit.
| @override remove(Object key) => _map.remove(key); | ||
| @override Iterable get values => _map.values; | ||
|
|
||
| // Manually implement members from `StateMapViewMixin`, |
There was a problem hiding this comment.
(I think StateMapViewMixin is a typo and should say PropsMapViewMixin.)
Could we try mixing in `PropsMapViewMixin instead and see how it works with Dart 2's DDC?
| }); | ||
| // TODO: The typing for `customFactory` is an analyzer error in Dart 2 (dev.49), is this DDC workaround + test still necessary or can it be removed? | ||
| // | ||
| // NOTE: This is no longer supportable in Dart 2 (should advertise as a breaking change in release notes) |
There was a problem hiding this comment.
Actually, can we just remove this test? We don't intend on doing anything with it, and we know this is going to break.
|
|
||
| @override | ||
| void setState(_, [callback()]) { | ||
| void setState(_, [Function callback]) { |
There was a problem hiding this comment.
This and its friends should be reverted as well.
| when(mock.addAll(any)).thenReturn('value'); | ||
|
|
||
| expect(proxy.addAll(testMap), isNull); | ||
| expect(() => proxy.addAll(testMap), isNull); |
There was a problem hiding this comment.
Huh, you can pass in a function and expect will evaluate it and match the result? Is this documented somewhere?
There was a problem hiding this comment.
That I don't know for sure @greglittlefield-wf ... I did this to address a dart 2 analyzer error, and the test didn't fail. I didn't dig too much further into it.
There was a problem hiding this comment.
In addition, these test are currently not run in the DDC because they us mirrors.
There was a problem hiding this comment.
It looks like it doesn't work. This is causing failures in Dart 1:
00:16 +245 -20: [Chrome] test/over_react_component_declaration_test.dart: component base: UiState provides Map functionality: proxies the Map member: forEach [E]
Expected: null
Actual: <Closure: () => void from: () => proxy[$forEach](callback)>
package:test expect
over_react/shared/map_proxy_tests.dart 86:7 test.test.dart.fn
We'll have to find a different workaround for this issue; perhaps we just shouldn't assert the return value. Or just comment out the tests until we're running them in Dart 2.
There was a problem hiding this comment.
@greglittlefield-wf this branch is targeting an SDK version of 2.0.0-dev.49.0, I wouldn't expect a lot of tests in this branch to pass using the dart 1 SDK.
| expect(() => proxy.forEach(callback), isNull); | ||
| verify(mock.forEach(callback)); | ||
| }); | ||
|
|
There was a problem hiding this comment.
We should add tests for the new Dart 2 Map members as well
There was a problem hiding this comment.
@greglittlefield-wf agreed, but currently, these tests are skipped in the DDC because they make use of mirrors.
There was a problem hiding this comment.
Yeah, at some point, we need to update these tests to use DDC-compatible mocks, or to not use mocks at all.
We do need some kind of test coverage around these methods; we should at least stub out these tests with FIXMEs or something so that we add them by the time we release these changes as stable.
| import 'package:over_react/over_react.dart'; | ||
| import 'package:test/test.dart'; | ||
|
|
||
| typedef dynamic ChainFunction([_, __, ___, ____, _____, ______]); |
There was a problem hiding this comment.
I think this ended up being unused.
2eac0f7 to
492c653
Compare
greglittlefield-wf
left a comment
There was a problem hiding this comment.
A couple things, but should be ready after this pass!
| when(mock.addAll(any)).thenReturn('value'); | ||
|
|
||
| expect(proxy.addAll(testMap), isNull); | ||
| expect(() => proxy.addAll(testMap), isNull); |
There was a problem hiding this comment.
It looks like it doesn't work. This is causing failures in Dart 1:
00:16 +245 -20: [Chrome] test/over_react_component_declaration_test.dart: component base: UiState provides Map functionality: proxies the Map member: forEach [E]
Expected: null
Actual: <Closure: () => void from: () => proxy[$forEach](callback)>
package:test expect
over_react/shared/map_proxy_tests.dart 86:7 test.test.dart.fn
We'll have to find a different workaround for this issue; perhaps we just shouldn't assert the return value. Or just comment out the tests until we're running them in Dart 2.
| expect(() => proxy.forEach(callback), isNull); | ||
| verify(mock.forEach(callback)); | ||
| }); | ||
|
|
There was a problem hiding this comment.
Yeah, at some point, we need to update these tests to use DDC-compatible mocks, or to not use mocks at all.
We do need some kind of test coverage around these methods; we should at least stub out these tests with FIXMEs or something so that we add them by the time we release these changes as stable.
| } | ||
| } | ||
|
|
||
| // Manually implement members from `MapViewMixin`, |
There was a problem hiding this comment.
This branch looks so much better than what we currently have!
There are a few more things that could be cleaned up, though, and since they're hard to explain I've just made a PR into this branch: #158.
Clean up the rest of the Map grossness left over from DDC workarounds
|
@greglittlefield-wf I've merged in your changes, and your comments about the I have tests passing locally - although there is likely still some work to be done getting them passing in Travis. I think this is a good first step though, and I'd like to get this merged unless there are major objections by you or @clairesarsam-wf. |
|
@aaronlademann-wf I'd rather us just comment out the tests than check in invalid changes just to fix syntax errors.
I also think we should stub those in so we don't forget about it. |
|
+10
|
Problem(s):
.callmethod of the object. This is not compatible with howReactComponentFactoryworks.MapBaseadditions from #151are no longer the best way to satisfy the missing concreteMapclass impls.2.0.0-devbranch ready to support further Dart 2 SDK testing /2.0.0-dev.<n>releases as the Dart team moves closer and closer to a production release of the Dart 2 SDK.Solution(s):
MapBaseadditions from AF-223 Begin preparations for Dart SDK 2 #151 were reverted and the new fields / getters / methods from that are present on theMapclass in the Dart 2 SDK were instead implemented individually so we don't add a bunch of stuff fromdart:collectionthat we don't actually need.>=2.0.0-dev.0 <=2.0.0-dev.49.0w.0.0-dev.49.0runsTesting Instructions:
2.0.0-dev.49.0http://localhost:8080and play around with the example components.Known Issues:
There are some issues present that, upon some investigation, appear to be unrelated to these changes:
testpackage issue, or if we need to do away with some of our "shared" test suites.FYA: @greglittlefield-wf @clairesarsam-wf
FYI: @dustinlessard-wf @sebastianmalysa-wf @robbecker-wf