Switch to precompiled projection .dll for the Windows SDK#2260
Merged
Sergio0694 merged 15 commits intostaging/3.0from Mar 13, 2026
Merged
Switch to precompiled projection .dll for the Windows SDK#2260Sergio0694 merged 15 commits intostaging/3.0from
Sergio0694 merged 15 commits intostaging/3.0from
Conversation
There was a problem hiding this comment.
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.dllas a new required precompiled projection assembly for Windows SDK types - Makes
WinRT.Projection.dlloptional, 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.
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.
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.
Introduce support for a new 'WinRT.Sdk.Xaml.Projection.dll' precompiled projection assembly for Windows SDK XAML types (Windows.UI.Xaml.* namespace). This assembly is optional and only present when UseWindowsUIXamlProjections is enabled. Changes mirror the existing 'WinRT.Sdk.Projection.dll' support: - Add WinRTSdkXamlProjectionAssemblyPath parameter through the full pipeline (args, parsing, formatting, MSBuild task, debug repro save/unpack) - Add InteropGeneratorDiscoveryState tracking for the module - Add InteropDefinitions.WindowsRuntimeSdkXamlProjectionModule property - Add InteropReferences.WinRTSdkXamlProjection assembly reference - Add InteropNames.WindowsRuntimeSdkXamlProjectionDllName constant - Add IsProjectedWindowsSdkXamlType extension (namespace starts with 'Windows.UI.Xaml') to route types to the correct projection assembly - Update SignatureGenerator, InteropImplTypeResolver, and InteropMarshallerTypeResolver to use 3-way routing: Windows.UI.Xaml.* -> WinRT.Sdk.Xaml.Projection, Windows.* -> WinRT.Sdk.Projection, others -> WinRT.Projection - Update IgnoresAccessChecksToBuilder to emit attribute when module present - Update ImplGenerator type forwarding with XAML assembly routing - Load/skip the new assembly in InteropGenerator.Discover Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Replace pattern matches that referenced Module.Assembly.Name with DeclaringModule.Assembly.Name to reliably determine the declaring assembly for types (fixing SDK and XAML projection detection). Also add a file-level #pragma warning disable IDE0046 at the top of WindowsRuntimeExtensions.cs.
24ec23b to
ef4ef36
Compare
manodasanW
approved these changes
Mar 13, 2026
* Impl SDK projection generation * Make the SDK versions be able to be set by pipeline * Add ability to handle new versions * Update to latest * Fix * Remove unneeded winmds * Add additional feed * Fix build * Fix build * Fix build * Fix build * Handle case when xaml projection is not generated * Address merged projection compilation without adding to refpath * Recognize WinRT SDK projection assemblies Update WindowsRuntimeExtensions to also treat types coming from WinRT SDK projection assemblies as projected types. Add checks for WindowsRuntimeSdkProjection and WindowsRuntimeSdkXamlProjection assembly names and document the rationale (type descriptors can come from type signatures used in attributes on resolved projected types). This prevents losing the original ref-assembly context and avoids failures when computing type signatures. * Use type.Scope.GetAssembly() to obtain assembly name Replace pattern matching on TypeDefinition.DeclaringModule.Assembly.Name with type.Scope?.GetAssembly() checks in WindowsRuntimeExtensions. This makes the assembly-name lookup work for non-TypeDefinition cases and avoids losing the original assembly context (e.g. ref assemblies), ensuring projected type detection — including XAML projection — remains correct. * Check IsProjectedWindowsSdkType before IsProjectedWindowsSdkXamlType in interop generator Swap the check order in all ternary expressions that resolve projection assembly/module so that IsProjectedWindowsSdkType is checked first, as SDK types are far more common than XAML types. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add missing type mape attributes for new pre-compiled projections * Fix variables * Improve log message for .winmd processing Replace the single generic log line with a switch-based message that reports more specific processing info. When WindowsSdkOnly is true it now logs "Processing Windows SDK .winmd references", and when both WindowsSdkOnly and WindowsUIXamlProjection are true it logs "Processing 'Windows.UI.Xaml' .winmd references"; otherwise it falls back to the previous "Processing N .winmd reference(s)" message. This makes build output clearer (the generator can run multiple times during builds) and provides more context to users. Changes in ProjectionGenerator.cs. * Fix location of cswinrtprojgen --------- Co-authored-by: Sergio Pedri <sergio0694@live.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Title. This saves a lot of build time to generate the merged projections.