Skip to content

feat(Shared): UIManager Migration#831

Merged
rozele merged 7 commits intomicrosoft:masterfrom
infinitered:shared-project-uimanager
Oct 28, 2016
Merged

feat(Shared): UIManager Migration#831
rozele merged 7 commits intomicrosoft:masterfrom
infinitered:shared-project-uimanager

Conversation

@kevinvangelder
Copy link
Copy Markdown
Contributor

  • 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 (fix(Linking): Adds getInitialUrl and url events to LauncherModule #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 Implement Linking getInitialURL API #301
    Fixes Implement Linking #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 feat(Portable): Migrate network module #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

* 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
{
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, can you just use Disposable.Empty from System.Reactive?


[SetUp]
// ToDo: Conflicts with UIManagerModule tests [SetUp]
public void SetUp()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this do? Can you leave a comment about it's purpose?

@@ -0,0 +1,38 @@
using NMock;
using NUnit.Framework;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where are you using NMock in here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bad habit.


namespace ReactNative.Tests.UIManager
{
[TestFixture, RequiresSTA]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sense to abstract this into a helper? These getter/setter patterns are used in a few places in this file.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I started to do that but then didn't because it was going to make the file larger.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) =>
Copy link
Copy Markdown
Contributor

@rozele rozele Oct 26, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Copy Markdown
Contributor

@rozele rozele Oct 26, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is System.Windows a valid namespace in WINDOWS_UWP? Rather, is it actually being used in UWP?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VS wasn't complaining, but it wasn't being used anyways, so I'll remove it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have a separate comments for each platform?

ApplicationView window)
#else
FrameworkElement window)
#endif
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could, but that's going to make this file a lot more messy.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Copy Markdown
Contributor

@rozele rozele Oct 26, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is FormattableString being used? #Closed

{

}
public IDisposable Create()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a doc comment for this public API

using System;
using System.Collections.Generic;
using Windows.UI.ViewManagement;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete this namespace.

@@ -5,6 +5,7 @@
using ReactNative.UIManager.Events;
using System;
using System.Collections.Generic;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whitespace below should be removed.

}

[TestMethod]
[TestMethod, STAThread]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

STAThread [](start = 21, length = 9)

Remove STAThread

}

[TestMethod]
[TestMethod, STAThread]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

STAThread [](start = 21, length = 9)

Remove STAThread

using System.Collections.Generic;
using System.Threading.Tasks;
using Windows.UI.ViewManagement;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove unused namespace.

Copy link
Copy Markdown
Contributor

@matthargett matthargett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like all @rozele feedback implemented. 👍

@rozele rozele merged commit 8c47f40 into microsoft:master Oct 28, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement Linking Implement Linking getInitialURL API

3 participants