Skip to content

Use implicit AbsolutePath conversions in built-in tasks - #15202

Merged
AR-May merged 3 commits into
dotnet:mainfrom
AR-May:ar-may-absolutepath-implicit-conversions
Oct 20, 2026
Merged

AR-May merged 3 commits into
dotnet:mainfrom
AR-May:ar-may-absolutepath-implicit-conversions

Conversation

@AR-May

@AR-May AR-May commented Oct 5, 2026 •

Copy link
Copy Markdown
Member

Related issue(s): Fixes #15072

Context

Built-in tasks sometimes pass AbsolutePath.Value to file APIs. Accessing .Value turns the path into a plain string, so the analyzer loses the proof that it is absolute and reports a diagnostic.

Pass AbsolutePath directly instead. Its implicit conversion produces the same string while preserving enough type information for analyzer verification. This is an alternative to #15073.

Changes Made

  • Replace redundant .Value accesses at path-consuming APIs with implicit conversions, while retaining .Value for string-specific operations.
  • Add direct and transitive analyzer coverage.

Compatibility

No runtime or analyzer behavior change. Bare AbsolutePath.Value remains untrusted.

Testing

  • Full build passed.
  • Analyzer tests: 375 passed.
  • Scoped task tests: 1,027 passed, 1 expected skip.
  • Bootstrap sample build passed.

Replace redundant Value reads at path consumers with the existing implicit string conversion instead of widening task analyzer recognition. Keep canonicalization and nullable unwrapping unchanged, document the preferred pattern, and cover direct and transitive analyzer calls.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@AR-May
AR-May requested a review from a team as a code owner October 5, 2026 09:01
Copilot AI balanced review requested due to automatic review settings October 5, 2026 09:01
@AR-May
AR-May temporarily deployed to copilot-pat-pool October 5, 2026 09:01 — with GitHub Actions Inactive
@AR-May
AR-May temporarily deployed to copilot-pat-pool October 5, 2026 09:02 — with GitHub Actions Inactive
@AR-May
AR-May temporarily deployed to copilot-pat-pool October 5, 2026 09:04 — with GitHub Actions Inactive
@AR-May
AR-May temporarily deployed to copilot-pat-pool October 5, 2026 09:05 — with GitHub Actions Inactive
@AR-May
AR-May temporarily deployed to copilot-pat-pool October 5, 2026 09:05 — with GitHub Actions Inactive

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

The changes preserve path values, include regression coverage for the unchanged analyzer contract, and have no identified blocking issues.

Review effort: Balanced
Findings: None

What changed in this PR

Updates built-in tasks to use implicit AbsolutePath conversions, preserving analyzer recognition without changing runtime path values or analyzer rules.

Changes:

  • Replace redundant .Value accesses with implicit conversions.
  • Add direct and transitive regression tests for accepted conversions and rejected bare .Value access.
  • Document the recommended analyzer-safe pattern.
File Description
src/​Tasks/​XmlTaskUtility.cs Pass the absolute path directly to OpenRead.
src/​Tasks/​WriteCodeFragment.cs Use implicit conversion for filename extraction.
src/​Tasks/​Untar.cs Simplify source and destination path conversions.
src/​Tasks/​TaskEnvironmentExtensions.cs Simplify conversions and update helper documentation.
src/​Tasks/​TarDirectory.cs Pass absolute paths directly to filesystem constructors.
src/​Tasks/​SystemState.cs Simplify cache path assignment.
src/​Tasks/​SGen.cs Simplify assembly path conversions.
src/​Tasks/​RedistList.cs Simplify redist path assignment.
src/​Tasks/​ManifestUtil/​LauncherBuilder.cs Use implicit conversions for launcher file operations.
src/​Tasks/​InstalledSDKResolver.cs Simplify SDK directory assignment.
src/​Tasks/​BootstrapperUtil/​Util.cs Simplify project directory conversion.
src/​Tasks/​BootstrapperUtil/​ResourceUpdater.cs Simplify resource file path assignment.
src/​Tasks/​AxTlbBaseTask.cs Simplify tool path conversion.
src/​Tasks/​AssemblyDependency/​ReferenceTable.cs Simplify canonical reference path assignment.
src/​Tasks/​AssemblyDependency/​Reference.cs Pass framework paths directly to directory checks.
src/​Tasks/​AssemblyDependency/​RawFilenameResolver.cs Simplify raw filename resolution.
src/​Tasks/​AssemblyDependency/​Node/​RarNodeExecuteRequest.cs Simplify captured project directory assignment.
src/​Tasks/​AssemblyDependency/​HintPathResolver.cs Simplify hint path conversion.
src/​Tasks/​AssemblyDependency/​AssemblyFoldersFromConfig/​AssemblyFoldersFromConfigResolver.cs Simplify configured directory conversions.
src/​Tasks/​AssemblyDependency/​AssemblyFoldersFromConfig/​AssemblyFoldersFromConfigCache.cs Preserve absolute path types through directory selection.
src/​TaskAnalyzer/​README.md Explain implicit conversions and bare .Value handling.
src/​TaskAnalyzer.Tests/​TransitiveCallChainAnalyzerTests.cs Cover conversions in source helpers.
src/​TaskAnalyzer.Tests/​MultiThreadableTaskAnalyzerTests.cs Cover conversions directly in tasks.

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

@AR-May
AR-May marked this pull request as draft October 5, 2026 09:10
@AR-May
AR-May force-pushed the ar-may-absolutepath-implicit-conversions branch from 6325c36 to 4bf7510 Compare October 5, 2026 09:20
Fold the direct and transitive cases into compact data-driven tests that compare implicit conversions with bare Value access.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@AR-May
AR-May force-pushed the ar-may-absolutepath-implicit-conversions branch from 4bf7510 to bac3c79 Compare October 5, 2026 12:16
@AR-May
AR-May marked this pull request as ready for review October 5, 2026 12:19
@AR-May
AR-May temporarily deployed to copilot-pat-pool October 5, 2026 12:19 — with GitHub Actions Inactive
@AR-May
AR-May temporarily deployed to copilot-pat-pool October 5, 2026 12:19 — with GitHub Actions Inactive
@AR-May
AR-May temporarily deployed to copilot-pat-pool October 5, 2026 12:20 — with GitHub Actions Inactive
@AR-May
AR-May temporarily deployed to copilot-pat-pool October 5, 2026 12:34 — with GitHub Actions Inactive
@AR-May
AR-May temporarily deployed to copilot-pat-pool October 5, 2026 12:36 — with GitHub Actions Inactive

@github-actions github-actions Bot 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.

✅ 24/24 dimensions clean — no findings.

Warning

Firewall blocked 3 domains

The following domains were blocked by the firewall during workflow execution:

  • api.github.com
  • github.com
  • raw.githubusercontent.com

[!TIP]
api.github.com is blocked because GitHub API access uses the built-in GitHub tools by default. Instead of adding api.github.com to network.allowed, use tools.github.mode: gh-proxy for direct pre-authenticated GitHub CLI access without requiring network access to api.github.com:

tools:
  github:
    mode: gh-proxy

See GitHub Tools for more information on gh-proxy mode.

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "api.github.com"
    - "github.com"
    - "raw.githubusercontent.com"

See Network Configuration for more information.

Generated by Expert Code Review (on open) for #15202 · copilot · gpt56 · 784.9 AIC · ⌖ 4.94 AIC · ⊞ 24.5K

@AR-May
AR-May temporarily deployed to copilot-pat-pool October 5, 2026 12:36 — with GitHub Actions Inactive
Comment thread src/Tasks/WriteCodeFragment.cs Resolved
Comment thread src/Tasks/TaskEnvironmentExtensions.cs Resolved
Comment thread src/Tasks/RedistList.cs Resolved
@AR-May AR-May self-assigned this Oct 6, 2026
@AR-May
AR-May requested a review from rainersigwald October 15, 2026 13:07
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@AR-May

AR-May commented Oct 19, 2026

Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).

@rainersigwald rainersigwald left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The theme here is "if we're going to use AbsolutePath, should we keep it around longer, not just for immediate normalization into a string that we then lose type-level absolute-path-ness on?"

Comment thread src/Tasks/SGen.cs Resolved
Comment thread src/Tasks/RedistList.cs Resolved
Comment thread src/Tasks/BootstrapperUtil/Util.cs Resolved
Comment thread src/Tasks/BootstrapperUtil/Util.cs Resolved
@AR-May

AR-May commented Oct 19, 2026 •

Copy link
Copy Markdown
Member Author

The PR's theme is not exactly "if we're going to use AbsolutePath, should we keep it around longer, not just for immediate normalization into a string that we then lose type-level absolute-path-ness on?" But rather "Unblock running analyzer as a warning not as a suggestion". I would like to separate those concerns and make a separate follow up PR that addresses the first theme (which is for sure is a correct thing to do).

@rainersigwald rainersigwald left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That makes sense to me.

@AR-May
AR-May enabled auto-merge (squash) October 19, 2026 13:59
@AR-May
AR-May merged commit 91446ef into dotnet:main Oct 20, 2026
14 checks passed
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.

Task analyzer reports false positives for AbsolutePath.Value

3 participants