-
Notifications
You must be signed in to change notification settings - Fork 105
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
Question: How to use locally built CsWinRT #989
Comments
@kant2002 you can find instructions on how to do a local build here. Let me know if you run into any issues. Then you can consume the test version of the projections (Windows, Reunion) that we build during the build with the built cswinrt in the unittest project or WinUIDesktopSample to try out your changes. Note that the code that you point to above in IReadOnlyList is a manual projection of that code gen, so you would probably need to update both. As for why it is done dynamically, based on what T is for IReadOnlyList, the delegate parameter types can be different like for |
Yes, I think I looking into something like that. I think I would like to put |
@manodasanW If I read code correctly, |
@kant2002 It is true that there isn't a max limit to the number of parameters in the delegates. But given For my own understanding, is your plan to replace those instances with |
Yes. That's the current plan. |
The other reason |
That's sounds unfortunate for NativeAOT case. Does that mean that instead of using |
Yes, but then you hit a problem with generic types. cc: @AaronRobinsonMSFT, we might want to reconsider interop support for generic delegates or generic unmanaged function pointers to enable making WinRT code AOT-friendly |
What kind of problem with generic types? Isn't I can create two kind of delegates. One which live in namespace, and others can live in the generic type itself. That's a bit complicated, but seems solve all problems. Am I miss something? |
A delegate in a generic type (like the following examples) are still technically generic types, so they'll hit the same problem:
|
I don't think this is needed but rather makes things cleaner in C#. I'm not against this at all but if most of the code that consumes this is source generated, is it really high priority relative to other things? These interop boundaries are always ugly in practice so I'm not sure how much better this makes things. Some good examples of what is currently required vs what it could be would be helpful. |
If we had that, how would you create the generic instantiations? Would all generic instantiations be discoverable statically, or would you use |
If it's not required (aka there's an alternative that's AOT friendly), then I'm fine doing the alternative.
I agree that doing any generic delegate work would only be worth it if we could discover the types statically. |
Aaron and I talked offline and came up with some ideas (that would be new .NET 7 work) that would provide alternative solutions without hitting issues with generic delegates in interop or |
This is proving to be far more complicated to address with the cleverness @jkoritzinsky and I came up with. We have something but it is going to be better, but not a perfect solution. Will update when the proposal is more mature. |
Is it necessary to support these reflection scenarios? I don't know the technicals here but deploying WinUI apps with AOT compilation appears to be blocked by this. |
@jkoritzinsky @AaronRobinsonMSFT can you share what's the plan how to move forward here or in near area. I think progress toward AOT in WinUI apps that's interesting. |
@kant2002 It is indeed interesting. We are starting down some other paths right now - primarily |
@AaronRobinsonMSFT obviously I will ping. Even if I probably understand why you don't want expose half-backed plan, I still would like to ask for some information, maybe about general direction of your ideas. Right now all my activity WinUI direction would be halted because I have to wait for March and maybe even more. This is risky, since right now this is first problem on the way to NativeAOT + WinUI and I bet there some other issues which will pops up after this one would be cracked. And we are talking about only NativeAOT side there. And for me at least 2 additional areas which will generate issues on my road - CsWinRT + WinUI. So that request coming just from my attempt to speedup process of finding other unknown risky areas on the road to WinUI. I was under impression that my initial plan to have explicit If answer still "no information for now", then what can I do to make you and Jeremy return to drawing board sooner? Maybe help with testing |
The current thought will be to leverage A theoretical usage of the concept: delegate void UniversalCalleeDelegate(TypedReference retValue, Span<TypedReference> args);
void RegisterCalleeFor(Type ret, IEnumerable<Type> args, UniversalCalleeDelegate callee); The reason we need to come back to it is the As far as the |
The idea behind this is to build a better interpreter than System.Linq.Expressions. It may make things work better than System.Linq.Expressions, but it is not going to match .NET Native. It may get close enough in some cases, depends. If you just want to make a demo work, you can also just use the existing System.Linq.Expressions-based implementation and augment it with rd.xml, etc. If you are looking for a solution that is on par performance-wise with .NET Native, all this code has to be generated at build time and no reflection and interpreters should be used at runtime. It is what .NET Native has done.
|
I trying to run WinRT application using NativeAOT, using this sample dotnet/runtimelab#1453.
If I start using
ToastNotificationManager.GetTemplateContent
then NativeAOT start complaining about usage ofS.L.E.Expression.GetDelegateType
. Error which i'm seeing comes from hereCsWinRT/src/WinRT.Runtime/Projections/IReadOnlyList.net5.cs
Line 209 in ad6adcb
I would like to change corresponding codegen here
CsWinRT/src/cswinrt/code_writers.h
Line 4744 in 26943b2
But I would like to test changes locally before even trying to submit something here.
Also what's rationale for making delegate type dynamically, and not using generated delegate types.
The text was updated successfully, but these errors were encountered: