Skip to content

Introduce a property to specify assemblies that should be partially R2R compiled and excluded from a composite image.#53635

Merged
jkoritzinsky merged 5 commits intodotnet:mainfrom
jkoritzinsky:r2r-partial
Apr 14, 2026
Merged

Introduce a property to specify assemblies that should be partially R2R compiled and excluded from a composite image.#53635
jkoritzinsky merged 5 commits intodotnet:mainfrom
jkoritzinsky:r2r-partial

Conversation

@jkoritzinsky
Copy link
Copy Markdown
Member

@jkoritzinsky jkoritzinsky commented Mar 30, 2026

This can be used by upstack tooling (dotnet/macios and dotnet/maui) to enable them to have crossgen2 generate a partial R2R image for Debug of a limited set of code (XAML generated code is the goal) to speed up F5 scenarios.

See dotnet/maui#34837 and dotnet/runtime#126194

…2R compiled and excluded from a composite image.
jkoritzinsky added a commit to jkoritzinsky/maui that referenced this pull request Mar 30, 2026
…cios repo and use item groups from dotnet/sdk#53635 to enable partial generation
Comment thread src/Tasks/Microsoft.NET.Build.Tasks/PrepareForReadyToRunCompilation.cs Outdated
Comment thread src/Tasks/Microsoft.NET.Build.Tasks/RunReadyToRunCompiler.cs Outdated
Comment thread src/Tasks/Microsoft.NET.Build.Tasks/PrepareForReadyToRunCompilation.cs Outdated
jkoritzinsky added a commit to jkoritzinsky/maui that referenced this pull request Mar 31, 2026
…cios repo and use item groups from dotnet/sdk#53635 to enable partial generation
…g, add warning for partial compile in composite mode

- Remove redundant eligibility.CompileSeparately check (already in parent block)
- Consolidate --composite flag emission to a single location
- Add NETSDK1237 warning when PartialCompile is set for assemblies compiled into a composite image

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jkoritzinsky jkoritzinsky requested a review from kotlarmilos April 6, 2026 22:18
@github-actions github-actions bot added the sdk-diagnostic-docs-needed Indicates that a PR introduces new diagnostic codes, which must be documented over at dotnet/docs label Apr 6, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 6, 2026

📋 SDK Diagnostic Documentation Reminder

This PR introduces 1 new SDK diagnostic code:

  • NETSDK1237

Action Required

Please ensure that documentation for this diagnostic is added or updated in the dotnet/docs repository at:

Each diagnostic should have:

  • A clear description of the error/warning
  • Possible causes
  • Recommended solutions
  • Code examples where applicable

Thank you for helping keep our documentation up to date! 🙏

@jkoritzinsky jkoritzinsky marked this pull request as ready for review April 13, 2026 20:39
Copilot AI review requested due to automatic review settings April 13, 2026 20:39
Copy link
Copy Markdown
Contributor

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

Adds support for “partial” ReadyToRun compilation of a selected set of assemblies, intended for upstack tooling scenarios (e.g., MAUI/macOS) where compiling only targeted code can speed up inner-loop Debug/F5 publishing.

Changes:

  • Plumbs a new PublishReadyToRunPartialAssemblies item list into the ReadyToRun preparation task and marks eligible compilation entries with PartialCompile.
  • Updates crossgen2 invocation to emit --partial based on per-assembly metadata.
  • Adds a new warning (NETSDK1237) when partial compilation is requested but the assembly ends up in a composite image (where partial compilation is not supported).

Reviewed changes

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

Show a summary per file
File Description
src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.CrossGen.targets Passes @(PublishReadyToRunPartialAssemblies) into PrepareForReadyToRunCompilation.
src/Tasks/Microsoft.NET.Build.Tasks/RunReadyToRunCompiler.cs Reads PartialCompile metadata and emits --partial for crossgen2; adjusts --composite emission logic.
src/Tasks/Microsoft.NET.Build.Tasks/PrepareForReadyToRunCompilation.cs Introduces PublishReadyToRunPartialAssemblies, tracks partial eligibility, sets PartialCompile metadata, and warns (NETSDK1237) when ignored under composite compilation.
src/Tasks/Common/Resources/Strings.resx Adds NETSDK1237 message and updates “latest message added” marker.
src/Tasks/Common/MetadataKeys.cs Adds PartialCompile and R2RHeaderSymbolName metadata keys.
src/Tasks/Common/Resources/xlf/Strings.cs.xlf Adds localized entry for NETSDK1237 (state=new).
src/Tasks/Common/Resources/xlf/Strings.de.xlf Adds localized entry for NETSDK1237 (state=new).
src/Tasks/Common/Resources/xlf/Strings.es.xlf Adds localized entry for NETSDK1237 (state=new).
src/Tasks/Common/Resources/xlf/Strings.fr.xlf Adds localized entry for NETSDK1237 (state=new).
src/Tasks/Common/Resources/xlf/Strings.it.xlf Adds localized entry for NETSDK1237 (state=new).
src/Tasks/Common/Resources/xlf/Strings.ja.xlf Adds localized entry for NETSDK1237 (state=new).
src/Tasks/Common/Resources/xlf/Strings.ko.xlf Adds localized entry for NETSDK1237 (state=new).
src/Tasks/Common/Resources/xlf/Strings.pl.xlf Adds localized entry for NETSDK1237 (state=new).
src/Tasks/Common/Resources/xlf/Strings.pt-BR.xlf Adds localized entry for NETSDK1237 (state=new).
src/Tasks/Common/Resources/xlf/Strings.ru.xlf Adds localized entry for NETSDK1237 (state=new).
src/Tasks/Common/Resources/xlf/Strings.tr.xlf Adds localized entry for NETSDK1237 (state=new).
src/Tasks/Common/Resources/xlf/Strings.zh-Hans.xlf Adds localized entry for NETSDK1237 (state=new).
src/Tasks/Common/Resources/xlf/Strings.zh-Hant.xlf Adds localized entry for NETSDK1237 (state=new).

Comment thread src/Tasks/Microsoft.NET.Build.Tasks/PrepareForReadyToRunCompilation.cs Outdated
- Make partialImage imply exclusion from composite image in
  CreateCompileEligibility, so partial assemblies are always compiled
  separately rather than being silently included in the composite.
- Remove now-unreachable warnings in composite branches since partial
  assemblies can no longer reach them.
- Rename composite-specific parameter names in CalculateOutputPathsForContainer
  to generic names (r2rImageRelativePath, intermediateR2RImage) since the
  method is used for both composite and non-composite outputs.
- Fix bug where variable rename was incorrectly applied at call site
  (r2rImageRelativePath was not in scope).
- Add integration tests for partial R2R compilation in both non-composite
  and composite modes.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Member

@kotlarmilos kotlarmilos left a comment

Choose a reason for hiding this comment

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

LGTM!

@jkoritzinsky
Copy link
Copy Markdown
Member Author

/ba-g work item crashes unrelated or connected to the known build errors

@jkoritzinsky jkoritzinsky merged commit ad40ca3 into dotnet:main Apr 14, 2026
18 of 24 checks passed
@jkoritzinsky jkoritzinsky deleted the r2r-partial branch April 14, 2026 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-ReadyToRun sdk-diagnostic-docs-needed Indicates that a PR introduces new diagnostic codes, which must be documented over at dotnet/docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants