Skip to content

Conversation

Metadorius
Copy link
Contributor

What kind of change does this PR introduce?

Bug fix?

What is the current behavior?

Originally the InitializeReactiveUI function didn't account for order of passed registration, because the allowed namespace dictionary was enumerated instead of the array (which is kind of backwards if you think about it).

What is the new behavior?

Order of the namespaces is preserved when registering.

What might this PR break?
Multi-platform projects that rely on current non-determinant order may break because of different order of registrations.

Please check if the PR fulfills these requirements

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

Other information:
Not sure on what kind of tests/docs are expected, so I am leaving it as draft for now, feel free to undraft if you feel this is OK.

@glennawatson
Copy link
Contributor

we'll discuss as a team if we want to keep this PR.

If we bring it across would you be okay just adding some simple unit tests for it?

@Metadorius
Copy link
Contributor Author

If we bring it across would you be okay just adding some simple unit tests for it?

Sure, I just was not sure what specifically needs to be tested here (or how, because the effect can vary in different setups), so would not mind an idea on what to write tests for.

Copy link

codecov bot commented Sep 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 67.82%. Comparing base (d75f999) to head (2880317).
Report is 124 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3887      +/-   ##
==========================================
+ Coverage   59.03%   67.82%   +8.78%     
==========================================
  Files         160      138      -22     
  Lines        5847     4805    -1042     
  Branches     1031      777     -254     
==========================================
- Hits         3452     3259     -193     
+ Misses       2007     1344     -663     
+ Partials      388      202     -186     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Yinimi
Copy link

Yinimi commented Jun 11, 2025

I think I had the same issue. When loading data async and trying to update the properties I got a System.InvalidOperationException: 'The calling thread cannot access this object because a different thread owns it.'
So it looks like .ObserveOn(RxApp.MainThreadScheduler) is just ignored.

I managed to fix this by setting RxApp.MainThreadScheduler manually:
ElementHost parent (WinForms UserControl):

public void ShowWpfContent()
{
    RxApp.MainThreadScheduler = new ControlScheduler(this);
    var myViewModel= Resolve<MyViewModel>();
    var myView = new MyView()
    { DataContext = myViewModel };
    WpfHost.Child = myView;
}

Looks like an ugly workaround but it works for me...

@glennawatson glennawatson marked this pull request as ready for review October 4, 2025 02:21
@glennawatson glennawatson requested a review from Copilot October 4, 2025 02:21
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a bug in the InitializeReactiveUI method where registration namespaces were being processed in the wrong order. The fix ensures that when multiple namespaces are passed for registration, they are processed in the order specified by the caller rather than in the order they appear in the internal dictionary.

Key Changes

  • Changed the enumeration source from possibleNamespaces dictionary to registrationNamespaces array
  • Updated the filtering logic to preserve the original order of namespaces
  • Modified the selection logic to lookup namespace values from the dictionary

@glennawatson glennawatson changed the title Fixup InitRxUI to account for order of passed registration namespaces Fix InitRxUI to account for order of passed registration namespaces Oct 4, 2025
@glennawatson glennawatson merged commit 073e07e into reactiveui:main Oct 4, 2025
4 checks passed
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.

3 participants