Repository navigation
Make projection generation incremental across reference assembly changes - #2652
Open
Sergio Pedri (Sergio0694) wants to merge 8 commits into
Open
Sergio Pedri (Sergio0694) wants to merge 8 commits into
Sergio Pedri (Sergio0694) wants to merge 8 commits into
Conversation
Restrict the Roslyn compilation references of the projection generator to the ones each projection mode needs, so generated bytes no longer depend on unrelated references. Narrow the Inputs of the projection generation targets so they no longer re-run when an unrelated project reference's reference assembly changes. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Sergio Pedri (Sergio0694)
requested a review
from Manodasan Wignarajah (manodasanW)
November 11, 2026 18:23
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Sergio Pedri (Sergio0694)
marked this pull request as ready for review
November 11, 2026 21:58
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.
Summary
Make the projection generation targets incremental when an unrelated project reference's reference assembly changes, and keep the generated projection
.dll-s byte-stable so the interop generator cache keeps hitting.Motivation
Whenever the reference assembly of any project reference of an app changed, the SDK, SDK XAML, merged and component projection generators re-ran, even though nothing they consume had changed. The regenerated
.dll-s were also not byte-identical to the previous ones: Roslyn records every compilation reference (name and MVID) in the embedded PDB, so an unrelated reference changing its MVID changed the output. The interop generator fingerprints those.dll-s by whole-file hash, so its cache then missed too (Generating interop codeinstead ofCached interop code). On a large app (the Microsoft Store client, 62 projects) this cost roughly 50 seconds per incremental build.Changes
src/WinRT.Projection.Generator/: select the Roslyn compilation references by projection mode (newProjectionGenerator.ReferenceAssemblies.cs), so generated bytes no longer depend on unrelated references. SDK mode keeps only framework references andWinRT.Runtime(plusWinRT.Sdk.Projectionfor the XAML projection). Merged and component modes keep the WinRT reference assemblies, components, and their dependency closure. References are deduplicated and ordered by name then path, and embedded PDBs are preserved. The generator also writes a<AssemblyName>.referencesfile next to each projection, listing exactly what it compiled against.nuget/Microsoft.Windows.CsWinRT.CsWinRTGen.targets: narrow theInputsof the four projection targets (renaming_CsWinRTComputeProjectionGenWinMDInputsto_CsWinRTComputeProjectionGenInputs)..winmdfiles are now listed as items so their timestamps count, the.referencesfiles are read intoInputs, the XAML target now tracksWinRT.Sdk.Projection.dll, and the input hash covers every reference path with its reference-projection classification and the Windows SDK metadata. The.referencesfiles are registered inFileWrites, and the precompiled SDK copy path deletes stale ones.src/Tests/ProjectionWriterTest/: newTest_ProjectionReferences.cswith determinism tests (unrelated, changed and reordered references produce identical bytes, for base SDK, XAML and component modes), plus small test infrastructure changes (deterministic helper compilation,WinRT.Internalmetadata path).Validation
Cached interop code. A.winmdchange, reference projection change,WinRT.Runtimechange or component change still regenerates.Known limitations
cswinrtwinmdgenwrites different.winmdbytes even after an implementation-only edit (needs a WinMD generator change).