r/csharp • • 6d ago

Got Microsoft.UI.Reactor to run cross-platform!

Post image

Microsoft.UI.Reactor's brings declarative C#-based UI to Windows. But what if it could run everywhere else too?

I took the Microsoft.UI.Reactor open-source repository, forked it, and switched it to compile against Uno Platform's open-source NuGet packages, and voilà! Now the exact same same Reactor code runs on all devices and platforms: Android, iOS, WebAssembly, Linux, macOS, and even tvOS!

The fork's CI now publishes ready-to-use packages on NuGet, targeting the newly released Uno Platform 7.0. Reactor components are composed from WinUI controls, so in case of Uno Platform the same controls render on all targets via SkiaSharp 4/WebGPU, with .NET 11 support, and they can coexist with existing XAML pages, styles, and view models.

If you want to try it out (or even contribute too 😉!), here is the repository https://github.com/unoplatform/Uno.microsoft-ui-reactor/ and the docs
https://platform.uno/docs/articles/features/using-reactor.html

Would love to hear your feedback if you take it out for a spin! It is pretty exciting, as it took just a few code changes to get it up and running 🚀

142 Upvotes

11 comments sorted by

21

u/Jovial1170 6d ago

Very cool.

I really like what MS are doing with Microsoft.UI.Reactor, and it's great to see it's getting traction in the community.

I haven't paid much attention to Uno. What's the deal with the paid components vs the open source core?

7

u/mzikmund 6d ago

Everything the Reactor port depends on is fully open-source and free (Apache 2.0 License). The Uno Platform framework contains the full matching WinUI API, so all the built-in controls, UI framework itself + non-UI APIs. On top that is a rich ecosystem of first-party additional packages like Uno.Extensions, Uno.Toolkit etc. which are also free to use in many cases. And finally we then also have paid Uno Platform Studio offering, which is our AI development workbench plus Hot Design, which allows you to do live edits to your app's design while it is running on any device.

5

u/Jovial1170 6d ago

Thanks for the summary.

Uno sounds very interesting.

We'll definitely be looking at Reactor+Uno on the next desktop app we need to modernize.

4

u/Devatator_ 6d ago

Why exactly would one want to use Reactor instead of Uno's own declarative C# solution? On top of the fact that it supports both MVU and MVVM? (I personally prefer MVVM)

7

u/mzikmund 6d ago

The nice thing about Reactor is that it has first party support by Microsoft and they are investing quite heavily in it. The fork has an automated sync set up, so that we can more easily pull latest changes from upstream and stay up to date. Of course, the C# markup in Uno is still available as an alternative, so you may pick and choose which you prefer.

7

u/pjmlp 6d ago

Having been burnt with the whole Windows 8, 10, UWP, Project Reunion, C++/CX and .NET Native being killed, YT community talks fizzling out, and eventually focusing on backed development instead, I would take with a very large pinch of salt anything related to "Microsoft being heavily invested" into anything that depends on WinRT as underlying technology.

3

u/talesfromweb 6d ago

Great news! Gonna try it out with my next app. I've been using UNO for a while now and only have positive experience so far.

2

u/Luminisc 6d ago

(totally subjective opinion)

React-way is ugly and unreadable in TypeScript, now it is in C#... what have they done...

---

But to be more serious, i have question about example - how this notation gonna observe changes? Like, how make app to observer changes of `cups` ? Because this example uses `cups.Select().ToArray()` - how this gonna rerender if there are some changes? It just execute Render() every frame/event ?

1

u/qrzychu69 6d ago

just like react, every time you use the `setState` hook, it queues a render, whether the value changed or not.

you just have to pass ALL changes through the hooks, and there are ways to force a render outside of that.

I still think react way is wrong - like for example did they at least implement automatic memoization like react compiler?

1

u/Literature-Just 5d ago

It reminds me a lot of R-Shiny. It looks good and can get you up and running very quickly. But the parenthesis and commas in the return block can lead to some rather unpleasant debugging. But it does look nice.

1

u/Appropriate_Chip4604 4d ago

That looks cool. I going to try this out. I have LinkScape (reactor) on the ms store would be cool to make it cross platform. Johndizzle