Skip to content

Extract non-multithreading task cleanups from #17381 - #17469

Merged
ViktorHofer merged 3 commits into
dotnet:mainfrom
ViktorHofer:task-cleanup
Sep 1, 2026
Merged

ViktorHofer merged 3 commits into
dotnet:mainfrom
ViktorHofer:task-cleanup

Conversation

@ViktorHofer

Copy link
Copy Markdown
Member

Non-multithreading changes extracted out of #17381 to shrink that PR and keep the risk separable. Each commit stands alone.

  • Collapse multi-line auto-properties in ValidatePackage — formatting only.
  • Inline ExecuteImpl where it has no early returns — the Execute/ExecuteImpl split only earns its keep when ExecuteImpl returns early. In these six tasks it has no return at all. Tasks that do use early returns keep the split.
  • Include the global.json path in the task object cache keys — CheckRequiredDotNetVersion and LocateDotNet cache under a constant build-scoped key but never compare the path the entry came from, so a second project with a different RepositoryRoot can get the first one's answer. CheckRequiredDotNetVersion also ignored SdkVersion.

The cache fix is the only behavioral change.

ViktorHofer and others added 2 commits September 1, 2026 09:23
The property declarations were spread over five lines each with the
accessors on their own lines. Collapse them to the single-line form used
elsewhere in the task. UseNetPlatform keeps its block body because it has
real accessor logic.

Formatting only, no behavior change.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: be19d794-fe4f-43fe-9e6e-f6e6b13ec6e7
The Execute/ExecuteImpl split exists so ExecuteImpl can return early while
Execute still ends with 'return !Log.HasLoggedErrors;'. In these six tasks
ExecuteImpl contains no return statement at all, so the split is pure
indirection.

Tasks that do use early returns (FindLatestDrop, GenerateTrainingInputFiles,
GenerateTrainingPropsFile, LocateDotNet) keep the split.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: be19d794-fe4f-43fe-9e6e-f6e6b13ec6e7
Copilot AI lite review requested due to automatic review settings September 1, 2026 07:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review tier: Lite
Findings: 1 Medium severity

New issues introduced by this change (1)
Severity Finding
Medium severity src/​Microsoft.DotNet.Arcade.Sdk/​src/​GenerateSourcePackageSourceLinkTargetsFile.cs — GetOutputFileContent() can return null when it logs an error, but `File.WriteAllText(OutputPath,…
What changed in this PR

This PR extracts non-multithreading cleanup changes from #17381, primarily simplifying several MSBuild task implementations and tightening task-object caching to avoid cross-project reuse when RepositoryRoot (and SdkVersion) differ.

Changes:

  • Simplify several MSBuild tasks by inlining ExecuteImpl() into Execute() when there are no early returns.
  • Collapse multi-line auto-properties in ValidatePackage (formatting-only).
  • Fix task object caching to include global.json path (and SdkVersion for CheckRequiredDotNetVersion) in cache entry validation.
File Description
src/​Microsoft.DotNet.Build.Tasks.VisualStudio/​Vsix/​GetPkgDefAssemblyDependencyGuid.cs Inlines ExecuteImpl into Execute and returns based on Log.HasLoggedErrors.
src/​Microsoft.DotNet.Build.Tasks.VisualStudio/​Vsix/​FinalizeInsertionVsixFile.cs Inlines ExecuteImpl into Execute and returns based on Log.HasLoggedErrors.
src/​Microsoft.DotNet.Build.Tasks.VisualStudio/​OptProf/​GetRunSettingsSessionConfiguration.cs Inlines ExecuteImpl into Execute and returns based on Log.HasLoggedErrors.
src/​Microsoft.DotNet.Build.Tasks.Packaging/​src/​ValidatePackage.cs Formatting-only: collapses auto-properties.
src/​Microsoft.DotNet.Arcade.Sdk/​src/​ValidateLicense.cs Inlines ExecuteImpl into Execute and returns based on Log.HasLoggedErrors.
src/​Microsoft.DotNet.Arcade.Sdk/​src/​LocateDotNet.cs Adds globalJsonPath to cache entry validation to prevent incorrect cache reuse across different repo roots.
src/​Microsoft.DotNet.Arcade.Sdk/​src/​GetLicenseFilePath.cs Inlines ExecuteImpl into Execute and returns based on Log.HasLoggedErrors.
src/​Microsoft.DotNet.Arcade.Sdk/​src/​GenerateSourcePackageSourceLinkTargetsFile.cs Inlines ExecuteImpl into Execute and returns based on Log.HasLoggedErrors.
src/​Microsoft.DotNet.Arcade.Sdk/​src/​CheckRequiredDotNetVersion.cs Adds globalJsonPath and SdkVersion to cache entry validation to prevent incorrect cache reuse.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

CheckRequiredDotNetVersion and LocateDotNet both registered their cached
result under a constant key and then decided cache hits by comparing
fields stored inside the cached entry. Two problems followed from that:

- The comparison had to be kept in sync with the inputs by hand, and it
  omitted the global.json path, so a second project with a different
  RepositoryRoot could be served another root's answer.
- RegisterTaskObject is implemented as ConcurrentDictionary.TryAdd, so
  with a constant key only the first registration of a build ever takes
  effect. Every other repository root missed the cache and then failed
  to populate it, recomputing on every single invocation.

Move the identity into the key itself as a readonly record struct. The
engine's dictionary lookup now does the comparison, distinct inputs get
distinct entries, and the cached value is just the result.
Copilot AI review requested due to automatic review settings September 1, 2026 07:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

Review tier: Lite
Findings: 1 Medium severity

Pre-existing issues (1)
Severity Finding
Medium severity src/​Microsoft.DotNet.Arcade.Sdk/​src/​GenerateSourcePackageSourceLinkTargetsFile.cs — GetOutputFileContent() can return null when it logs an error, but `File.WriteAllText(OutputPath,… View comment

@ViktorHofer
ViktorHofer enabled auto-merge (squash) September 1, 2026 07:52
@ViktorHofer
ViktorHofer merged commit c4c8e26 into dotnet:main Sep 1, 2026
10 of 12 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Sep 2, 2026
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.

3 participants