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

Thoughts on Windows 11 C# Windows App SDK WinUI 3 XAML #164

Open
kaidelorenzo opened this issue Dec 3, 2023 · 7 comments
Open

Thoughts on Windows 11 C# Windows App SDK WinUI 3 XAML #164

kaidelorenzo opened this issue Dec 3, 2023 · 7 comments

Comments

@kaidelorenzo
Copy link

I'm wondering about 2 things

  1. Are there plans to build out C#/WinUI 3 support?
  2. Is that something that folks would get behind integrating into Crux?
@charypar
Copy link
Member

Hi @kaidelorenzo! Thanks for the questions.

  1. Not at present. We don't have a use for it, and it would likely depend on Custom code generation from serde-reflection metadata #145
  2. We would definitely welcome your thoughts on what if anything should be supported (beyond C# typegen) and contributions towards it.

There are a few things that depend on the custom type gen in #145, so it's relatively likely we'll start investigating options there pretty soon.

@kaidelorenzo
Copy link
Author

I haven't given much thought to what limitations would be acceptable. I've read online that the interop between c# and rust isn't great right now so that might make things more challenge.

My goal would probably be minimal typegen support so that it is possible to run the framework even if the data types sent are simple (maybe restrict to integer or string structs only).

I don't have much time right now to work on this but glad that you'd be open to contributions. To me Windows seems like the last native platform that doesn't already work with crux.

@charypar
Copy link
Member

charypar commented Jan 2, 2024

One problem for which I can't see an immediate solution is representing Rust enum's, which are quite central to how Crux communicates with the shells (for events and effects). We'd need to do something like this probably https://bugsquash.blogspot.com/2012/01/encoding-algebraic-data-types-in-c.html. I'm not very familiar with the windows ecosystem, but maybe it would make more sense to target F# and rely on its interop with C# if that's more mature?

@StuartHarris Do you know much about the state of interop in C# land?

@StuartHarris
Copy link
Member

I don't. But I'm putting this link here mainly so I can find it again to do a bit more reading on it. https://github.com/FractalFir/rustc_codegen_clr

@huwaireb
Copy link

huwaireb commented Jul 5, 2024

👋

with windows-rs and WinRT components you can integrate Rust into a C#/WinUI 3 or any WinRT based application.
I've done it the other day, works fine, just have to write an interface using MIDL 3 and then windows-rs has a bindgen that generates bindings, of which you implement for, samples (c++ no official c# as of yet).

it's pretty simple outside of having to conform to the quirks of WinRT on implementation, works well.

depends on CsWinRT (to generate the c# bindings) and Visual Studio (for midlrt.exe to generate .winmd which is then used to generate both Rust implementation and C# projection bindings).

i can share an example with C# & WinUI if anyone's interested.

I should probably mention I only got started like 3-4 days developing on Windows, so not much of an expert 🤣, in fact spent 7+ hours trying to get it to work 🤣, but eventually did.

@kaidelorenzo
Copy link
Author

Yeah an example would be great. No rush if you'd rather tidy up some code first or something

@huwaireb
Copy link

huwaireb commented Jul 5, 2024

Yeah an example would be great. No rush if you'd rather tidy up some code first or something

Screen.Recording.2024-07-06.at.03.04.32.mov

thought might as well get crux also working 😭 spent entire day, but !! works.
i'm too tired to clean up now given its 3 am 😭, will push it up tomorrow.

should clarify nothing was generally complicated, it's just my inexperience with C# as a language, and Windows as a platform. As well as getting familiar with how Crux does typegen. And how to implement state in WinUI 3.

given as i mentioned above i only started 3-4 days ago.

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 a pull request may close this issue.

4 participants