Repository navigation
Recognize AbsolutePath.Value canonicalization in task analyzers - #14970
Merged
Merged
Conversation
Accept the same Path.GetFullPath sink used by AbsolutePath.GetCanonicalForm in direct and transitive task analysis, while retaining diagnostics for unproven inputs and lookalike APIs. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
JanProvaznik
temporarily deployed
to
copilot-pat-pool
September 7, 2026 16:55 — with
GitHub Actions
Inactive
JanProvaznik
temporarily deployed
to
copilot-pat-pool
September 7, 2026 16:55 — with
GitHub Actions
Inactive
JanProvaznik
temporarily deployed
to
copilot-pat-pool
September 7, 2026 16:56 — with
GitHub Actions
Inactive
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The change is narrowly scoped, well-documented, and covered by targeted tests across both direct and transitive analyzer paths.
Pull request overview
This PR updates the MSBuild task analyzers to recognize the specific canonicalization pattern Path.GetFullPath(absolutePath.Value) as equivalent to AbsolutePath.GetCanonicalForm() behavior, avoiding false positives in both direct (MSBuildTask0002) and transitive (MSBuildTask0005) analysis while still treating the resulting string as absolute for MSBuildTask0003.
Changes:
- Add a narrowly-scoped exemption for
Path.GetFullPath(AbsolutePath.Value)in bothMultiThreadableTaskAnalyzerandTransitiveCallChainAnalyzer. - Teach the absolute-path proof logic (MSBuildTask0003) that this exact canonicalization yields a safe absolute string.
- Document the exception and add unit tests covering safe/unsafe inputs and “lookalike”
System.IO.Pathscenarios.
File summaries
| File | Description |
|---|---|
| src/TaskAnalyzer/TransitiveCallChainAnalyzer.cs | Skips recording a banned-API violation when the invocation matches the AbsolutePath canonicalization pattern. |
| src/TaskAnalyzer/SharedAnalyzerHelpers.cs | Introduces IsAbsolutePathCanonicalization and uses it to treat the canonicalization result as safely absolute. |
| src/TaskAnalyzer/README.md | Documents the new narrow canonicalization exception and its boundaries. |
| src/TaskAnalyzer/MultiThreadableTaskAnalyzer.cs | Avoids reporting MSBuildTask0002/0004 for the canonicalization call when it matches the approved pattern. |
| src/TaskAnalyzer.Tests/TransitiveCallChainAnalyzerTests.cs | Adds coverage ensuring polyfills/helpers performing canonicalization don’t trigger diagnostics and unsafe variants still do. |
| src/TaskAnalyzer.Tests/MultiThreadableTaskAnalyzerTests.cs | Adds direct analyzer coverage for canonicalization, unsafe variants, and “lookalike Path” negative cases. |
Review details
- Files reviewed: 6/6 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
ViktorHofer
approved these changes
Sep 8, 2026
Member
|
I'm gonna merge this in so that I can consume an updated analyzer in arcade soon. |
ViktorHofer
deleted the
janprovaznik-taskanalyzer-arcade-investigation
branch
September 8, 2026 10:09
This was referenced Sep 8, 2026
This was referenced Nov 11, 2026
Merged
Closed
Closed
This was referenced Nov 16, 2026
Closed
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.
Fixes #14955
Context
Path.GetFullPath(absolutePath.Value)canonicalizes an already fully qualified value; it does not resolve a relative path against the process working directory. This is the underlying BCL operation used by MSBuild itself.AbsolutePath.GetCanonicalForm()returns:The analyzer already accepts native
GetCanonicalForm()results through theirAbsolutePathtype. However, writing the normalization directly in a task produces MSBuildTask0002, and writing it in a source polyfill/helper produces MSBuildTask0005. This prevents downlevel consumers such as Arcade from implementing the operation without suppression.The exception belongs at
Path.GetFullPath(AbsolutePath.Value), not at a helper namedGetCanonicalForm.Changes Made
Path.GetFullPathcall over the resolvedMicrosoft.Build.Framework.AbsolutePathinstance stringValueproperty between direct and transitive analysis.Paththrough the intrinsic string type's assembly, rejecting source-defined and aliased-metadata lookalikes rather than comparing display names.OriginalValue, unrelatedValueproperties, unproven/reassigned strings, transformed inputs, and other overloads. No helper name whitelist or general-purpose dataflow exemption is added.Testing
Built
TaskAnalyzer.Tests.csprojand ranMultiThreadableTaskAnalyzerTests,TransitiveCallChainAnalyzerTests, andMultiThreadableTaskCodeFixProviderTests: 143 passed, zero failed or skipped.Used Arcade as the real-project reproduction at
f1ce2c65fd8036c495df221b7257e2680e15b4a2, retaining its Framework/Utilities 18.8.2 references and existingmultithreadable_onlyconfiguration. Rebuilt the actual Templating project using isolated variants ofGenerateFileFromTemplate, with I/O rooted and retained asAbsolutePath. A compile-item overlay kept the original Arcade snapshot unchanged.Path.GetFullPath(outputPath.Value)GetCanonicalFormextensionNo suppressions or broad-scope overrides were used. Compiler logs confirm the 18.8.2 references and the locally built analyzer. Both variants were rebuilt after tightening BCL symbol identity.
Notes
System.IO.Path. This was fixed and covered for source and referenced lookalikes; the follow-up review found no remaining actionable or blocking issues.AbsolutePathcontract. It adds no runtime/API changes, diagnostic IDs, or severity changes, so no ChangeWave is needed.OriginalValueremain separate compatibility concerns. No Arcade production changes are included.