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

Support for UWP and System XAML #723

Open
asklar opened this issue Feb 5, 2021 · 21 comments
Open

Support for UWP and System XAML #723

asklar opened this issue Feb 5, 2021 · 21 comments
Labels
cswinmd enhancement New feature or request
Milestone

Comments

@asklar
Copy link
Member

asklar commented Feb 5, 2021

Filing this here to track a dependency on cswinrt from microsoft/react-native-windows#6539
We would like to be able to move away from C# UWP but we still need to target system xaml. So we would like the ability for cswinrt to target UWP apps and system XAML so that we can avoid a whole bunch of issues related to .net native and consuming nugets from C++ apps.

Related: microsoft/react-native-windows#6539

@asklar asklar added the enhancement New feature or request label Feb 5, 2021
@AdamBraden AdamBraden added this to the Future milestone Feb 9, 2021
@AdamBraden
Copy link
Contributor

This would require custom type mapping for xaml to map onto inbox System XAML. Right now the custom type mappings go against WinUI.

@yoshiask
Copy link

yoshiask commented Aug 3, 2021

I'm a little surprised that C#/WinRT doesn't already support system XAML. Just a noob here, but I had assumed that "lifting this projection support out of the compiler and runtime" would also entail decoupling from WinUI. Are there technical reasons why it can't/won't be done?

@driver1998
Copy link

Also this will unblock the XAML islands on .NET 5+ scenario, without this we'll have to wait for WinUI 3 XAML islands which is "scheduled to a later release".

@asklar asklar added the cswinmd label Sep 1, 2021
@JaiganeshKumaran
Copy link

JaiganeshKumaran commented Dec 28, 2021

I have a component that exposes a few platform XAML types. Before I could just use them from C# but now with C#/WinRT, it blacklists all those types from the projection, unlike every other WinRT projection. Even if you reserve certain mappings to Microsoft.UI.Xaml (eg: INotifyPropertyChanged), Windows.UI.Xaml types must be available even if you have Microsoft.UI.Xaml (from WinUI 3) referenced. C#/WinRT shouldn't be framework dependent. If you don't want people from using types from Windows.UI.Xaml, you should add a deprecated attribute (at least in the C#/WinRT projection), instead of not projecting them entirely.

@ghost
Copy link

ghost commented Feb 25, 2022

@angelazhangmsft This issue is hanging on thin air and should be dropped right away.

UWP/CoreWindow was doomed to oblivion a loooong time ago.
As .NET 5 / .NET 6 / .NET 7 and upwards versions themselves will never support it , CsWinRT can't do very much, can it ?

@driver1998
Copy link

.NET 5 / 6 / 7 won't be compatible with AppContainer and UAP-only environments anytime soon, so UWP is not actually relevant here.
This is mainly for XAML islands.

@ghost
Copy link

ghost commented Feb 25, 2022

so the title be modified to reflect XAML Island only. (Support for UWP and System XAML for XAML Islands.

<RE> well contrary to MS marketing, AppContainer is not tied to any Window specific tech (CoreWindow aka UWP)</RE>

@dongle-the-gadget
Copy link
Contributor

dongle-the-gadget commented Mar 7, 2022

I don't think that it is necessary, you can actually create UWP apps with .NET 6, however the incompatibility with System XAML in stock C#/WinRT blocks that.

(see https://github.com/gus33000/CsUWP)

@driver1998
Copy link

That sounds like great news, I am always baffled by the lack of XAML islands support in .NET 5/6.

@driver1998
Copy link

driver1998 commented Mar 16, 2022

For those are interested, @gus33000's fork of CsWinRT is at https://github.com/gus33000/CsWinRT/tree/wux.

@gus33000
Copy link

There are some roadblocks at the moment for having both Windows.UI.Xaml and Microsoft.UI.Xaml support in CsWinRT, which is why I haven't tried to do a PR yet for this. Mainly you have interop classes for .NET/WinRT that can currently only be applied to Windows.UI.Xaml or Microsoft.UI.Xaml. (As an example, CollectionChanged) It would be a bit messy at the moment to have support for both in the code. Maybe someone has an idea in order to make this a bit better?

@dongle-the-gadget
Copy link
Contributor

There are some roadblocks at the moment for having both Windows.UI.Xaml and Microsoft.UI.Xaml support in CsWinRT, which is why I haven't tried to do a PR yet for this. Mainly you have interop classes for .NET/WinRT that can currently only be applied to Windows.UI.Xaml or Microsoft.UI.Xaml. (As an example, CollectionChanged) It would be a bit messy at the moment to have support for both in the code. Maybe someone has an idea in order to make this a bit better?

Is there any specific reason why WinUI 3 needs C#/WinRT coupling? If no then I think the best approach is to just remove that coupling.

@JaiganeshKumaran
Copy link

@gus33000 Most of the types eg: CollectionChanged are very similar across both WinUI 2.x and WinUI 3 so those can be projected as the same type while other types will be projected separately.

@lhak
Copy link

lhak commented Mar 23, 2022

This should definitely be addressed because .net core 3.1 is going out of support by the end of the year and I doubt that winui 3 will be a good replacement for it by that time.

@dongle-the-gadget
Copy link
Contributor

C#/WinRT 1.6.1 should already support building projections for system XAML, however building projections for libraries like the XamlApplication Toolkit or WinUI 2 causes the "class not registered" exception.

@driver1998
Copy link

driver1998 commented Sep 28, 2022

Mainly you have interop classes for .NET/WinRT that can currently only be applied to Windows.UI.Xaml or Microsoft.UI.Xaml

I guess it should be fine to split CsWinRT into two libraries right? CsWinRT for the core WinRT projection, and CsWinRT.WinUI for XAML related stuff (with separated assembly for system XAML and WinUI 3 XAML).

Now with trimming working the worry of yet another DLL is not that relevant anymore.

@driver1998
Copy link

Friendly reminder: .NET Core 3.1 is now EOL, there is no officially supported way to use XAML islands on .NET now.

@dongle-the-gadget
Copy link
Contributor

dongle-the-gadget commented Jan 12, 2023

Maybe someone has an idea in order to make this a bit better?

How about adding a new property (i.e. CsWinRTXamlNamespace), like C++/WinRT is currently doing? Of course, the property would be set to Microsoft.UI.Xaml by default.

But rather unfortunately, WinRT.Runtime would not be able to know whatever we set here, which would be a dealbreaker. I can only think of shipping separate binaries of WinRT.Runtime: one for Microsoft.UI.Xaml and one for Windows.UI.Xaml.

@driver1998
Copy link

How much code in WinRT.Runtime is dependent on the XAML implementation? Can we generate entire classes like C++/WinRT does and eliminate the issue all together?

@dongle-the-gadget
Copy link
Contributor

It powers some XAML types, as well as properly managing some error codes.

@Sergio0694
Copy link
Member

If someone wants to try this out, #1421 adds System XAML support to CsWinRT, and Windows.UI.Xaml projections 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cswinmd enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

9 participants