Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 23, 2026

  • Explore repository structure and locate relevant files
  • Understand the MapSourceRoots task and InitializeSourceRootMappedPaths target
  • Identify the canonicalization approach
  • Add canonicalization logic to MapSourceRoots task
  • Add comprehensive tests for path canonicalization
  • All tests pass (17/17 on net10.0)
  • Address PR review feedback
    • Simplified code by removing complex relative component detection
    • Added NestedRoot canonicalization
    • Updated test to use CombinatorialData
    • Added test for ContainingRoot and NestedRoot
  • Address code review suggestions
    • Improved comments
    • Better string comparison for path handling
  • Add WorkItem attribute to all new tests referencing issue Canonicalize SourceRoot paths before returning from InitializeSourceRootMappedPaths #82112
  • Fix trailing whitespace in both MapSourceRoots.cs and MapSourceRootTests.cs

All changes complete and tested. CI formatting issues resolved.

Original prompt

This section details on the original issue you should resolve

<issue_title>Canonicalize SourceRoot paths before returning from InitializeSourceRootMappedPaths</issue_title>
<issue_description>While digging into dotnet/sdk#52614 I found that SourceRoot items are not canonicalized - so items that users (or other MSBuild Logic) add may have relative path portions in them. If those portions are not canonicalized, then path comparisons that occur later on in the build (e.g. for applying PathMaps to embedded source items, and file paths in PDBs) may not compare as expected. This can lead to un-mapped paths in PDBs and other build artifacts.

The InitializeSourceRootMappedPaths target is the documented extension point for anyone that needs to consume SourceRoot items, so it is a logical place to do this canonicalization. We should sanitize the SourceRoot items here so that we don't have to sanitize them N times downstream.</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits January 23, 2026 09:40
Co-authored-by: jjonescz <3669664+jjonescz@users.noreply.github.com>
- Added path canonicalization logic in MapSourceRoots.Execute()
- Canonicalizes both ItemSpec and ContainingRoot metadata
- Only canonicalizes rooted paths with relative components (.. or /.)
- Preserves trailing directory separators
- Added comprehensive tests for canonicalization behavior

Co-authored-by: jjonescz <3669664+jjonescz@users.noreply.github.com>
- Extract duplication into CanonicalizePathPreservingTrailingSeparator helper
- Remove redundant length check
- Fix false positive detection for .. by checking path segment boundaries
- Also fix false positive for /. by checking if it's a single dot

Co-authored-by: jjonescz <3669664+jjonescz@users.noreply.github.com>
Copilot AI changed the title [WIP] Canonicalize SourceRoot paths in InitializeSourceRootMappedPaths Canonicalize SourceRoot paths with relative components in MapSourceRoots Jan 23, 2026
Copilot AI requested a review from jjonescz January 23, 2026 10:01
Copy link
Member

@jjonescz jjonescz left a comment

Choose a reason for hiding this comment

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

Copilot AI and others added 2 commits January 23, 2026 10:52
- Simplify by removing ContainsRelativePathComponents method
- Normalize all rooted paths unconditionally
- Add CanonicalizeRelativePathPreservingTrailingSeparator for NestedRoot
- Change PathCanonicalization_Deterministic to use CombinatorialData
- Add test for ContainingRoot and NestedRoot canonicalization

Co-authored-by: jjonescz <3669664+jjonescz@users.noreply.github.com>
- Improve comment explaining canonicalization for rooted paths
- Use StringComparison.Ordinal for StartsWith check
- Use verbatim string for dummy root path clarity

Co-authored-by: jjonescz <3669664+jjonescz@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 23, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • bcnvsblobprodcus378.vsblob.vsassets.io
    • Triggering command: /usr/share/dotnet/dotnet dotnet build src/Compilers/Core/MSBuildTask/MSBuild/Microsoft.Build.Tasks.CodeAnalysis.csproj grep -l WorkItem entationCommentTests.cs ndor/bin/grep WorkItem mentsTests.cs /usr/local/sbin/WorkItem grep -l WorkItem orDocumentationCommentTests.cs /home/REDACTED/.cargo/bin/grep WorkItem cs ndor/bin/grep grep (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title Canonicalize SourceRoot paths with relative components in MapSourceRoots Canonicalize SourceRoot paths in MapSourceRoots Jan 23, 2026
Copilot AI requested a review from jjonescz January 23, 2026 10:54
Co-authored-by: jjonescz <3669664+jjonescz@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 23, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • bcnvsblobprodcus378.vsblob.vsassets.io
    • Triggering command: /usr/share/dotnet/dotnet dotnet build src/Compilers/Core/MSBuildTaskTests/Microsoft.Build.Tasks.CodeAnalysis.UnitTests.csproj (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Co-authored-by: jjonescz <3669664+jjonescz@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 23, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • bcnvsblobprodcus378.vsblob.vsassets.io
    • Triggering command: /usr/share/dotnet/dotnet dotnet build src/Compilers/Core/MSBuildTask/MSBuild/Microsoft.Build.Tasks.CodeAnalysis.csproj (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Co-authored-by: jjonescz <3669664+jjonescz@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 23, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • bcnvsblobprodcus378.vsblob.vsassets.io
    • Triggering command: /usr/share/dotnet/dotnet dotnet build src/Compilers/Core/MSBuildTaskTests/Microsoft.Build.Tasks.CodeAnalysis.UnitTests.csproj (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@baronfel
Copy link
Member

@jjonescz the copilot implementation seems to be pretty gung-ho about not absolutizing relative paths passed in - but I think absolutizing paths is fine here. Better this explicit expansion than an implicit one at hand wave some point later on in the build. Do you have any thoughts?

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.

Canonicalize SourceRoot paths before returning from InitializeSourceRootMappedPaths

3 participants