Skip to content

Allow dropping native host for NativeAOT WinRT components#1395

Merged
manodasanW merged 72 commits into
staging/AOTfrom
user/sergiopedri/naot-winrt-exports
Jan 10, 2024
Merged

Allow dropping native host for NativeAOT WinRT components#1395
manodasanW merged 72 commits into
staging/AOTfrom
user/sergiopedri/naot-winrt-exports

Conversation

@Sergio0694
Copy link
Copy Markdown
Member

Closes #1387

Overview

This PR adds a new CsWinRTAotExportsEnabled MSBuild property that can be set in authoring scenarios (and is automatically set if PublishAot is already set). This triggers the generator to emit the native exports for WinRT .dll-s directly into the same binary, with the correct logic, and also skips adding all references and copying all files related to the native host infrastructure.

Keeping as a draft as I'm not entirely sure how to set up unit tests for this just yet 😅

@Sergio0694 Sergio0694 added enhancement New feature or request authoring Related to authoring feature work AOT labels Nov 22, 2023
@@ -1,258 +1,342 @@
using Microsoft.CodeAnalysis;
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: I normalized whitespaces in this file, review with whitespace diff off.
The actual changes are just a few lines of code being added.

Comment thread src/Authoring/WinRT.SourceGenerator/Generator.cs Outdated
Comment thread src/Authoring/WinRT.SourceGenerator/Generator.cs
Comment thread nuget/Microsoft.Windows.CsWinRT.Authoring.targets Outdated
Comment thread src/Authoring/WinRT.SourceGenerator/Generator.cs
Comment thread src/Authoring/WinRT.SourceGenerator/Generator.cs Outdated
@Sergio0694 Sergio0694 marked this pull request as ready for review November 25, 2023 19:49
Comment thread src/Tests/AuthoringConsumptionTest/AuthoringConsumptionTest.vcxproj
@Sergio0694 Sergio0694 force-pushed the user/sergiopedri/naot-winrt-exports branch from 4d5281b to 38098bf Compare November 30, 2023 22:17
@Sergio0694 Sergio0694 force-pushed the user/sergiopedri/naot-winrt-exports branch from fa62a4c to f02bf33 Compare January 9, 2024 00:27
…-authoringtestfixes2

Fix test issues discovered from enabling AOT for authoring scenarios
@manodasanW
Copy link
Copy Markdown
Member

Just to note in the PR, there is one remaining authoring test failure for AOT (AuthoringTest.CustomTypes). That would be addressed in a separate PR.

@manodasanW manodasanW merged commit f01956b into staging/AOT Jan 10, 2024
@hez2010
Copy link
Copy Markdown
Contributor

hez2010 commented Jan 10, 2024

If you're using CoreCLR and a native host, then you don't need these exports.

We will still need the generated int GetActivationFactory(void*, void**) so that we can pass it to RoRegsiterActivationFactories.

See: https://github.com/hez2010/WinRTServer/blob/master/WinRTServer/InternalModule.cs

@Sergio0694 Sergio0694 deleted the user/sergiopedri/naot-winrt-exports branch March 19, 2026 20:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AOT authoring Related to authoring feature work enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Drop native host when publishing WinRT components with NativeAOT

4 participants