Skip to content

Comments

Switch to precompiled projection .dll for the Windows SDK#2260

Draft
Sergio0694 wants to merge 12 commits intostaging/3.0from
user/sergiopedri/precompiled-sdk-projection
Draft

Switch to precompiled projection .dll for the Windows SDK#2260
Sergio0694 wants to merge 12 commits intostaging/3.0from
user/sergiopedri/precompiled-sdk-projection

Conversation

@Sergio0694
Copy link
Member

Title. This saves a lot of build time to generate the merged projections.

Introduce a new required property WinRTSdkProjectionAssemblyPath (WinRT.Projection.Sdk.dll) and clarify WinRTProjectionAssemblyPath to refer to the merged projection (WinRT.Projection.dll). Update validation to check the SDK projection path and adjust response-file arguments to emit --winrt-sdk-projection-assembly-path (required) while keeping --winrt-projection-assembly-path optional. Update warning text accordingly.
Introduce a distinct --winrt-sdk-projection-assembly-path argument and plumbing to handle the separate WinRT.Projection.Sdk.dll alongside WinRT.Projection.dll. Changes include:

- Add required WinRTSdkProjectionAssemblyPath property to InteropGeneratorArgs and make WinRTProjectionAssemblyPath nullable.
- Update argument parsing and formatting to emit/consume the new SDK projection argument and to conditionally include the (optional) projection assembly argument.
- Wire up InteropGenerator.DebugRepro to copy/hash the SDK projection assembly, track its hashed name, and pass it through the generated InteropGeneratorArgs instances.

This enables using a distinct SDK projection assembly while preserving optional support for a separate projection assembly.
Add explicit support for the precompiled SDK projection assembly (WinRT.Sdk.Projection.dll). Introduces a new InteropNames constant for the SDK projection, a backing field and accessor in InteropGeneratorDiscoveryState, and a TrackWinRTSdkProjectionModuleDefinition method. LoadWinRTModules was updated to always load the SDK projection first and treat WinRT.Projection.dll and WinRT.Component.dll as optional, and the module validation/skip logic was adjusted accordingly. Minor doc/comment updates in RunCsWinRTInteropGenerator and InteropGeneratorArgs to reflect the new assembly name.
Introduce support for a separate Windows SDK projection module (WinRT.Sdk.Projection.dll) and use it when resolving projected types. Changes include:

- Add a WindowsRuntimeSdkProjectionModule property and parameter to InteropDefinitions, make WindowsRuntimeProjectionModule nullable.
- Update InteropGenerator.Emit call site to pass the new SDK projection module argument.
- Update SignatureGenerator to pick the correct projection module based on the type namespace (types in "Windows.*" use the SDK projection), handle delegates and null namespaces, and perform safe lookups to avoid null refs.
- Minor doc/comment clarifications in InteropNames.

These changes allow the generator to resolve GUIDs and default interfaces from the appropriate projection assembly (SDK vs general projection) and improve robustness for types without namespaces.
Add distinct assembly references for the precompiled Windows SDK projection and the merged projection, and choose which to use based on the exported type's namespace. Types with a namespace starting with "Windows." are routed to the SDK projection; others use the merged projection created on the fly. Also skip exported types with a null namespace. This mirrors the selection logic used by cswinrtinteropgen and ensures Windows SDK types reference the precompiled projection while other WinRT types use the merged projection.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request introduces a significant optimization by switching from generating merged projections for the Windows SDK to using a precompiled WinRT.Sdk.Projection.dll. The PR implements a namespace-based routing mechanism where types in Windows.* namespaces are served from the precompiled SDK projection, while custom Windows Runtime types continue to use the generated WinRT.Projection.dll (now optional).

Changes:

  • Adds WinRT.Sdk.Projection.dll as a new required precompiled projection assembly for Windows SDK types
  • Makes WinRT.Projection.dll optional, now only needed for non-Windows SDK WinRT types
  • Implements namespace-based routing logic (Windows.* → SDK projection, others → regular projection) across multiple components

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/WinRT.Interop.Generator/References/InteropNames.cs Added constant for new WinRT.Sdk.Projection.dll name and fixed spacing in comments
src/WinRT.Interop.Generator/References/InteropDefinitions.cs Added SDK projection module parameter and property, made regular projection module optional
src/WinRT.Interop.Generator/Helpers/SignatureGenerator.cs Implemented namespace-based routing to select correct projection module for IID and default interface lookups
src/WinRT.Interop.Generator/Generation/InteropGeneratorDiscoveryState.cs Added tracking for SDK projection module definition
src/WinRT.Interop.Generator/Generation/InteropGeneratorArgs.cs Added required SDK projection path parameter, made regular projection path optional
src/WinRT.Interop.Generator/Generation/InteropGeneratorArgs.Parsing.cs Updated parsing to handle both SDK and regular projection paths
src/WinRT.Interop.Generator/Generation/InteropGeneratorArgs.Formatting.cs Updated formatting to conditionally include optional regular projection path
src/WinRT.Interop.Generator/Generation/InteropGenerator.Emit.cs Passed SDK projection module to InteropDefinitions during emission
src/WinRT.Interop.Generator/Generation/InteropGenerator.Discover.cs Added loading logic for SDK projection, made regular projection conditional
src/WinRT.Interop.Generator/Generation/InteropGenerator.DebugRepro.cs Updated debug repro to handle both SDK and regular projection assemblies
src/WinRT.Impl.Generator/Generation/ImplGenerator.cs Implemented namespace-based type forwarding to correct projection assembly
src/WinRT.Generator.Tasks/RunCsWinRTInteropGenerator.cs Added SDK projection path as required parameter, made regular projection path optional with validation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sergio0694 and others added 7 commits February 17, 2026 23:25
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Introduce ITypeDescriptor.IsProjectedWindowsSdkType extension to centralize logic for detecting projected Windows SDK types (optimized to handle Utf8 namespace values). Refactor SignatureGenerator to use this helper when selecting the appropriate projection module for delegates and default-interface lookups, removing duplicated namespace checks and redundant UTF8 transcoding.
Add an IgnoresAccessChecksTo attribute for "WinRT.Sdk.Projection" (the precompiled Windows SDK projection DLL) and update the comment to note both the precompiled projection and the generated "WinRT.Projection" assembly. The existing attribute for "WinRT.Projection" is retained.
Add a WinRTSdkProjection AssemblyReference and route ABI/marshaller/impl lookups to the correct projection assembly based on type.IsProjectedWindowsSdkType. Updates WindowsRuntimeExtensions, InteropImplTypeResolver, and InteropMarshallerTypeResolver to choose between WinRTSdkProjection and WinRTProjection when creating ABI type references, and adds the new property to InteropReferences.
Introduce optional winRTProjectionModule and winRTComponentModule parameters to AssemblyAttributes and update XML docs. Only add IgnoresAccessChecksTo for WinRT.Projection and WinRT.Component when the corresponding module is present (passed in), preventing unnecessary attributes when those DLLs are not part of the inputs. Update call site to pass discoveryState.WinRTProjectionModuleDefinition and WinRTComponentModuleDefinition.
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 this pull request may close these issues.

1 participant