feat(Shared): UIManager Migration#831
Conversation
* initial work migrating Network module * Progress on Networking Module * more progress on Network module * fix csproj * migrating more devsupport * migrating more devsupport * Migrate DevOptionDialog * migrated Progress Dialog * migrated RedBoxDialog * migrated WebSocketJavaScriptExecutor * migrate DevSupportManager * saved changes from last commit -- oops. * implement feedback from @rozele * a little more cleanup * switched to in-memory settings strategy * tweaks to try to fix AppVeyor build * fixed build path for Facebook.CSSLayout * remove unwanted comment * migrating easy UIManager files * migrating moderate UIManager files * refactored Networking module to shared per @rozele feedback * starting migration of pointers in touch * Touch basics needs circular references * update csproj * migrated difficult UIManager files * implemented more feedback from @rozele * fix(Linking): Adds `getInitialUrl` and `url` events to LauncherModule (microsoft#798) Using the ProtocolActivatedEventArgs, this changeset adds the `getInitialUrl` API implementation for the Linking module (aka the LauncherModule in native code) and the `url` event, which is called each time the app is activated with a new protocol URI. Fixes microsoft#301 Fixes microsoft#687 * imlemented more @rozele feedback * implement @rozele feedback * implemented feedback from @matthargett * removed another unnecessary if/def * small tweaks to wrap up UIModule migration * migrated uimanager tests - all but 2 pass * Revert "Merge pull request microsoft#787 from infinitered/shared-project-network" This reverts commit 4b78183, reversing changes made to 8da1824. * Revert "merge upstream" This reverts commit 1fd5fdf, reversing changes made to 249c6f7. * tweaks for tests * tweak I18N setting read * fix spacing changes * adding touch handling * diverge BaseViewManager for UWP/WPF * implemented feedback from @rozele * added reactprop to no-op todo comments * allow ReactShadowNode dirty override for Net46 * more tweaks per feedback * added missing files * add csproj change * abstracted platform specific window finding code from UIManagerModule * cleanup * implemented @rozele feedback for touch
|
|
||
| class NullDisposable : IDisposable | ||
| public class NullDisposable : IDisposable | ||
| { |
There was a problem hiding this comment.
Actually, can you just use Disposable.Empty from System.Reactive?
|
|
||
| [SetUp] | ||
| // ToDo: Conflicts with UIManagerModule tests [SetUp] | ||
| public void SetUp() |
There was a problem hiding this comment.
SetUp [](start = 20, length = 5)
Why don't you just create a singleton class for initializing the Application and expose a method called Initialize that is idempotent?
| } | ||
|
|
||
| [Apartment(ApartmentState.STA)] | ||
| public static async Task<T> CallOnDispatcherAsync<T>(Func<T> func) |
There was a problem hiding this comment.
What does this do? Can you leave a comment about it's purpose?
| @@ -0,0 +1,38 @@ | |||
| using NMock; | |||
| using NUnit.Framework; | |||
There was a problem hiding this comment.
Where are you using NMock in here?
|
|
||
| namespace ReactNative.Tests.UIManager | ||
| { | ||
| [TestFixture, RequiresSTA] |
There was a problem hiding this comment.
RequiresSTA [](start = 18, length = 11)
This smells of something being very wrong. I've never seen a need for an attribute like this in unit tests...
| @@ -0,0 +1,486 @@ | |||
| using NMock; | |||
| using NUnit.Framework; | |||
There was a problem hiding this comment.
I'm seeing the reference to NMock in a few files but not quite sure where it's being used.
| var result = default(bool); | ||
| var parsed = bool.TryParse(ConfigurationManager.AppSettings[AllowRTL], out result); | ||
| return (bool)(object)(parsed && result); | ||
| #endif |
There was a problem hiding this comment.
Make sense to abstract this into a helper? These getter/setter patterns are used in a few places in this file.
There was a problem hiding this comment.
I started to do that but then didn't because it was going to make the file larger.
There was a problem hiding this comment.
I'd rather make it larger and have the #ifs isolated to a smaller number of locations.
In reply to: 85239327 [](ancestors = 85239327)
| var target = VisualTreeHelper.FindElementsInHostCoordinates(new Point(touchX, touchY), uiElement) | ||
| #else | ||
| var sources = new List<DependencyObject>(); | ||
| VisualTreeHelper.HitTest( |
There was a problem hiding this comment.
Might be useful to put a TODO here to consider a pooled data structure. You'll be allocating a lot of lists here in case of a touch heavy application
There was a problem hiding this comment.
Honestly, since you're doing FirstOrDefault() below anyway, I would separate the UWP and .NET 4.6 behaviors a bit more. With the HitTest approach, you can inline the HasTag() test in the HitTest delegate body.
In reply to: 85234608 [](ancestors = 85234608)
| uiElement, | ||
| null, | ||
| new HitTestResultCallback( | ||
| (HitTestResult hit) => |
There was a problem hiding this comment.
You should just use type inference here, remove the new HitTestResultCallback constructor wrapper and also remove the (HitTestResult hit) parameter type from the lambda parameters (i.e., just write hit =>
| using ReactNative.UIManager.Events; | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Windows; |
There was a problem hiding this comment.
Is System.Windows a valid namespace in WINDOWS_UWP? Rather, is it actually being used in UWP?
There was a problem hiding this comment.
VS wasn't complaining, but it wasn't being used anyways, so I'll remove it.
There was a problem hiding this comment.
Or rather, VS was lying to me... it was being used. I'll just move it into the if/def to be sure.
| /// <param name="viewManagers">The view managers.</param> | ||
| /// <param name="uiImplementation">The UI implementation.</param> | ||
| /// <param name="window">The ApplicationView/Framework Element.</param> | ||
| public UIManagerModule( |
There was a problem hiding this comment.
Can we have a separate comments for each platform?
| ApplicationView window) | ||
| #else | ||
| FrameworkElement window) | ||
| #endif |
There was a problem hiding this comment.
Can't we just pass change the constructor signature for .NET 4.6 only? I really don't want to have to think through all the implications of not grabbing the ApplicationView when it's used. Basically, this would be better if you parameterized constructor on the window parameter only for .NET 4.6
There was a problem hiding this comment.
We could, but that's going to make this file a lot more messy.
There was a problem hiding this comment.
I'd prefer not to change the behavior of UWP. Previously, each time the bounds changed, we grabbed the instance from the APplicationView singleton method, now we cache it, so we could hae failure cases that would occur in different ways if these callbacks somehow end up on the wrong thread.
In reply to: 85238878 [](ancestors = 85238878)
There was a problem hiding this comment.
What about passing the dimensions into the UIManager module and managing the size changed behavior somewhere else where we have a ReactContext available?
In reply to: 85242918 [](ancestors = 85242918,85238878)
There was a problem hiding this comment.
This is the most centralized way to decouple this class from the concrete type, and eliminate a global instance access. This approach will allow for parallelization of all tests being run without the worry of conflicts in global mutable state.
| public class UIManagerModuleTests | ||
| { | ||
| [TestMethod] | ||
| [TestMethod, STAThread] |
There was a problem hiding this comment.
STAThread [](start = 21, length = 9)
I'd rather not use this attribute until I understand it more. It shouldn't be needed if you take the suggestion in UIManager to only parameterize for .NET 4.6 (since we can get the application view at any time from UWP).
| using System; | ||
| using System.Configuration; | ||
| using static System.FormattableString; | ||
| #endif |
There was a problem hiding this comment.
Where is FormattableString being used? #Closed
| { | ||
|
|
||
| } | ||
| public IDisposable Create() |
There was a problem hiding this comment.
Add a doc comment for this public API
| using System; | ||
| using System.Collections.Generic; | ||
| using Windows.UI.ViewManagement; | ||
|
|
| @@ -5,6 +5,7 @@ | |||
| using ReactNative.UIManager.Events; | |||
| using System; | |||
| using System.Collections.Generic; | |||
There was a problem hiding this comment.
Whitespace below should be removed.
| } | ||
|
|
||
| [TestMethod] | ||
| [TestMethod, STAThread] |
There was a problem hiding this comment.
STAThread [](start = 21, length = 9)
Remove STAThread
| } | ||
|
|
||
| [TestMethod] | ||
| [TestMethod, STAThread] |
There was a problem hiding this comment.
STAThread [](start = 21, length = 9)
Remove STAThread
| using System.Collections.Generic; | ||
| using System.Threading.Tasks; | ||
| using Windows.UI.ViewManagement; | ||
|
|
matthargett
left a comment
There was a problem hiding this comment.
looks like all @rozele feedback implemented. 👍
getInitialUrlandurlevents to LauncherModule (fix(Linking): AddsgetInitialUrlandurlevents to LauncherModule #798)Using the ProtocolActivatedEventArgs, this changeset adds the
getInitialUrlAPI implementation for the Linking module (aka the LauncherModule in native code) and theurlevent, which is called each time the app is activated with a new protocol URI.Fixes Implement Linking
getInitialURLAPI #301Fixes Implement Linking #687
This reverts commit 4b78183, reversing
changes made to 8da1824.
This reverts commit 1fd5fdf, reversing
changes made to 249c6f7.