Skip to content
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

Refactor ViewManagers to detect unimplemented properties #4575

Merged
merged 32 commits into from
Apr 13, 2020

Conversation

asklar
Copy link
Member

@asklar asklar commented Apr 11, 2020

This lays the groundwork for being able to test whether properties are implemented or not.

The meat of the change is to refactor ViewManager classes, so that the only thing view managers should implement is UpdateProperty (i.e. handle a single property, as opposed to UpdateProperties for multiple properties). This factors out the iteration of the property map onto the ViewManagerBase class. In addition to this, UpdateProperty will return bool so that we can detect when nobody in the inheritance chain was able to handle a property.

With this, the test hook will currently print unimplemented properties to the debugger (this will be later augmented to enable us to write tests that check the fact that a property must be implemented, as well as to enable us to measure the % of implemented API surface, see #3587 )

[UnimplementedProperty] ViewManager = RCTScrollView elementClass = Windows.UI.Xaml.Controls.ScrollViewer propertyName = overflow value = scroll
[UnimplementedProperty] ViewManager = RCTScrollView elementClass = Windows.UI.Xaml.Controls.ScrollViewer propertyName = flexDirection value = column
[UnimplementedProperty] ViewManager = RCTScrollView elementClass = Windows.UI.Xaml.Controls.ScrollViewer propertyName = keyboardDismissMode value = interactive
[UnimplementedProperty] ViewManager = RCTScrollView elementClass = Windows.UI.Xaml.Controls.ScrollViewer propertyName = snapToStart value = 1
[UnimplementedProperty] ViewManager = RCTScrollView elementClass = Windows.UI.Xaml.Controls.ScrollViewer propertyName = snapToEnd value = 1
[UnimplementedProperty] ViewManager = RCTScrollView elementClass = Windows.UI.Xaml.Controls.ScrollViewer propertyName = pagingEnabled value = 0

I'm also adding some heuristics to have RedBox point the developer to a page which we hope to augment with more details on how to debug Metro bundling issues.

image

I'm also detecting a new type of Metro error which is an html document. To display these, we will host a WebView and tell it to navigate to the provided HTML. The trickiest part is sizing the webview since there is currently no way for XAML to measure the element. The HTML we get is also not styled so normally it would display as black text on white background whereas the rest of the redbox is red. To achieve the desired effect and set the right height for the webview, I devised a somewhat clever trick to run some JavaScript on the hosted WebView to get the rendered height and set the background/foreground.
Result:
image

Fixes #4572 #4573

Microsoft Reviewers: Open in CodeFlow

acoates-ms and others added 26 commits April 10, 2020 16:34
* Created new Microsoft.ReactNative.sln
* Update PR to build vnext/Microsoft.ReactNative.sln
* Add params to disable ReactUWP nuget pack during PR
* Move playground app to use Microsoft.ReactNative

* formatting

* Bunch of code review feedback

* Change files

* formatting

* Delete unneeded gitignore

* Minor removal of diff

* Minor changes to try to avoid having to update cert all the time

* Fix bundle command

* No need to build rntester seperately, the release build of playground will do it from msbuild

* Remove test property
* Disable .net native for managed unit tests

* Change files

* Enable managed unit tests in ci loop

* re-merge unit test tasks, can't run arm anyway

* Remove prefer 32bit from 64bit flavors

* Update mstest dependencies

* Managed tests are separate again

* Add comment

* Add test adapter path

* x86 debug again

* Update test adapter folder

* Try again

* remove frameworkuap10

* Switch to appxrecipie

* Try to switch to installed version of vstest

* Remove installer task
* Prototype mockable MessageQueueThread and JSExecutor

* Declare MockJSExecutor::CallFunctionFunctor

* Add missing using std::unique_ptr

* Use WebSocketModule::MethodId

* clang format

* Make WebSocketModule methods override instead of virtual.

* Allow WebSocketModule to use custom resource factory

* Rename *Impl to *Mock

* Move Instance mocks into separate source files

* Move Instance mocks into separate source files

* Change files

* clang format

* Define WebSocketModule::SetResourceFactory
-Surface msbuild errors (shows as undefined right now)
-downloading nuget with Invoke-WebRequest will usually take a long time because of the PS progress bar (which sadly gets updated for every byte), so I'm disabling the progress bar (it only takes a second to download when the progress bar is turned off)
retry once if nuget failed since if you cancel at just the right time, you could end up with a truncated nuget.exe and are wedged unless you know which file to delete. Learned that the hard way.
-factor out calling onto powershell functions
-we were not exposing whether the function failed or not
* Don't set readyState on connection error

* Change files
* Simplified C++ macros and improved their comments

* Change files
@asklar asklar added Developer First Experience Issues that are going to be hit by a new developer as they first try out RNW Area: Test Infrastructure labels Apr 11, 2020
@asklar asklar marked this pull request as ready for review April 12, 2020 03:42
@asklar asklar requested a review from a team as a code owner April 12, 2020 03:42
@acoates-ms
Copy link
Contributor

acoates-ms commented Apr 12, 2020

I like the webview when the error message is clearly an html doc. #Resolved

m_stackPanel.Children().Clear();
m_stackPanel.Children().Append(webView);

auto dispatcher = winrt::Windows::System::DispatcherQueue::GetForCurrentThread();
Copy link
Contributor

@kmelmon kmelmon Apr 13, 2020

Choose a reason for hiding this comment

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

winrt::Windows::System::DispatcherQueue::GetForCurrentThread(); [](start = 26, length = 63)

Thanks for changing this to DispatcherQueue! Strange... I was literally 5 seconds away from suggesting this when I saw your latest revision. #Closed

Copy link
Contributor

@kmelmon kmelmon left a comment

Choose a reason for hiding this comment

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

:shipit:

This was linked to issues Apr 13, 2020
@asklar asklar merged commit 31bed1c into microsoft:master Apr 13, 2020
asklar added a commit to asklar/react-native-windows that referenced this pull request Apr 19, 2020
)

* Refactor View managers to detect unimplemented props and add a simple test hook
* Add display of HTML metro errors with proper WebView sizing/styling
* Add display of internal metro errors and direct users to an aka.ms link for troubleshooting
NickGerleman added a commit to NickGerleman/react-native-windows that referenced this pull request Apr 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Test Infrastructure Developer First Experience Issues that are going to be hit by a new developer as they first try out RNW
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve Metro diagnosability Ability to test which properties are implemented Improve dev inner loop
7 participants