-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix: Add RegistrationNamespace.Avalonia #2699
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
Conversation
Codecov Report
@@ Coverage Diff @@
## main #2699 +/- ##
=======================================
Coverage 63.57% 63.57%
=======================================
Files 132 132
Lines 4733 4733
=======================================
Hits 3009 3009
Misses 1724 1724 Continue to review full report at Codecov.
|
|
Wonder if a "Avalonia" enum might be better or something just because the empty array is a little meh. And on Avalonia just don't do anything. Not quite sure if that's what we want, will get others opinion. |
|
Yeah, returning nothing instead of the default could be a problem. I agree with Glenn that if Avalonia is specific, then we should open it up so that just Avaolnia returns an empty list. |
|
Thanks for the review! Added a PlatformRegistrationManager.SetRegistrationNamespaces(RegistrationNamespace.Avalonia);And then register the Avalonia-specific dependencies manually. |
|
Going to fix the approval tests soon. |
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
What kind of change does this PR introduce?
With this PR, the
InitializeReactiveUIextension method is now falling back toPlatformRegistrationManager.NamespacesToRegisterif there are no registration namespaces provided viaparamsof theInitializeReactiveUImethod. TheNamespacesToRegisterproperty is mutable as opposed toDefaultRegistrationNamespaces— if we preferNamespacesToRegisterover the read onlyDefaultRegistrationNamespacesas the default value here, our users will be able to disable implicit dependency discovery if they'd like to via a call toPlatformRegistrationManager.SetRegistrationNamespaces().What is the current behavior?
Currently, folks with the "Break on all exceptions" feature enabled in their IDE are confused by exceptions during app initialization:
System.IO.FileNotFoundException: Could not load file or assembly 'ReactiveUI.XamForms, Version=13.1.0.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.We know, that this is ordinary ReactiveUI dependency registration behavior — ReactiveUI tries to load assemblies in order to register the required services, and if the framework fails to load an assembly, then a
FileNotFoundExceptionis thrown, which is immediately caught by theMemoizingMRUCacheimplementation:ReactiveUI/src/ReactiveUI/Expression/Reflection.cs
Lines 41 to 48 in 0518c2b
This behavior is OK on most platforms, but there are folks who'd like to register the required dependencies manually and explicitly. That's why the
SetRegistrationNamespacesmethod currently exists. At the moment we allow setting the registration namespaces, but don't allow turning off the auto dependency registration via assembly loading completely. Turning off this feature might be useful in such environments as Avalonia.ReactiveUI. Avalonia folks tend to use aIAppBuilderand the.UseReactiveUI()extension method for Avalonia-specific dependency registrations. That's why they might want to turn off the implicit ReactiveUI default dependency registration behavior.What is the new behavior?
With the proposed change, one can disable implicit assembly loading by doing this:
This change would allow adding this statement to Avalonia.ReactiveUI in order to avoid performing unnecessary assembly loading in their environment. Also, this feature might be useful for folks who tend to use the "Break on all exceptions" feature in Microsoft Visual Studio or JetBrains Rider, and who might want to register the dependencies manually. In case if one disables platform registrations this way, the
InitializeReactiveUIextension method will only register default registrations and .NET Standard/.NET Core etc. platform registrations.What might this PR break?
Hopefully nothing, but let's wait for the CI?