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

Will this project support AOT in .Net 5? #2714

Closed
ismlsmile opened this issue Jan 15, 2020 · 9 comments
Closed

Will this project support AOT in .Net 5? #2714

ismlsmile opened this issue Jan 15, 2020 · 9 comments
Assignees
Labels
area-ILLinker/AOT question General question, not a problem in source code or documentation (yet)

Comments

@ismlsmile
Copy link

In .Net 5, CoreFX will be extended to support AOT. So I wonder if WinForms could support AOT in .Net 5? Thanks.

@Symbai
Copy link

Symbai commented Jan 19, 2020

@ismlsmile Do you have any source about this? I am curios to read what exactly is planned because as far as I know AOT is only "something that the .NET Core team takes a look at it" and one of them replied in a blog comment a month ago they already have a working winforms prototype. But I couldn't find any information that it is definitely planned for .NET 5.

@merriemcgaw
Copy link
Member

@OliaG can you follow up on whether there are any plans in this space, and if we'll be able to leverage what the rest of .NET Core is doing?

@merriemcgaw merriemcgaw added the question General question, not a problem in source code or documentation (yet) label Jan 23, 2020
@OliaG
Copy link
Member

OliaG commented Mar 6, 2020

@ismlsmile, thanks for the feedback. The team is still working on a plan for AOT, so it's too early to say which parts will support AOT for .NET 5, but eventually we'd like WinForms to support it too.

@OliaG OliaG added this to the Future milestone Mar 6, 2020
@wjk
Copy link
Contributor

wjk commented Feb 19, 2021

Just a quick update on the current state of this issue:

I have tried running the NativeAOT compiler over a simple Windows Forms application. When I run the resulting AOT’d binary, it displays a fully working form with button. I click the button… and get an unhandled exception. NativeAOT does not currently support ComImportAttribute, which WinForms uses extensively to provide accessibility support. If I manipulate a custom control that I wrote from scratch (without accessibility support), everything works perfectly.

Unfortunately, properly implementing ComImportAttribute support in NativeAOT is a very difficult proposition. Moving WinForms to a CsWin32-like solution using machine-generated unsafe code would probably be easier (and still be compatible with the regular runtime-JIT CLR), but changing to that technique would be extremely disruptive. Also, the requisite tooling doesn’t quite exist yet (cf microsoft/CsWin32#86).

@RussKie
Copy link
Member

RussKie commented Feb 19, 2021

/cc: @AaronRobinsonMSFT @AArnott FYI

@AArnott
Copy link
Contributor

AArnott commented Feb 19, 2021

@wjk For my own enlightenment, what is it about ComImportAttribute that makes any difference at runtime at all? Is it the type equivalence when it is embedded?

@AaronRobinsonMSFT
Copy link
Member

@AArnott It isn't really anything specific with ComImportAttribute, it is what it implies - COM. COM isn't AOT friendly because of all the dynamic code gen at runtime - marshalling stubs et al. It is even more complicated when IDispatch is involved because that is basically reflection for COM and not feasible in AOT in practice. The key issue is around removing all code gen at run time.

The C#/WinRT tooling does a fairly decent job of that but even it uses expression trees in some cases. The concrete problem is the plug-in model. If any COM type can be loaded then it isn't known what interfaces it may expose or how so it is hard to know what to generate ahead of time. If the full transitive closure of types is known then it can be done with immense effort - see .NET Native and the UWP ecosystem.

@kant2002
Copy link
Contributor

I think there is a good chance that currently NativeAOT can run you WinForms application. There some work happens to improve situation, and make Winforms works as is.

@RussKie
Copy link
Member

RussKie commented Jul 28, 2021

I think we can close this question with an answer - no, .NET 5.0 is done, and won't support NativeAOT.
With all the awesome work that @kant2002 is currently doing .NET 6.0 is likely to provide (at least limited) support for NativeAOT.

However this is not an official promise, the team is aware of the desire to have this capability available, but we have multiple competing priorities, and some things have higher priorities than others.

@RussKie RussKie closed this as completed Jul 28, 2021
@ghost ghost removed this from the Future milestone Jul 28, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Feb 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-ILLinker/AOT question General question, not a problem in source code or documentation (yet)
Projects
None yet
Development

No branches or pull requests

10 participants