Skip to content

Apply --pathmap to source file names compiled into the assembly - #21022

Draft
majocha wants to merge 2 commits into
dotnet:mainfrom
majocha:pathmap-literals
Draft

majocha wants to merge 2 commits into
dotnet:mainfrom
majocha:pathmap-literals

Conversation

@majocha

@majocha majocha commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Fixes #21020
Fixes #21021

Description

The compiler wrote unmapped source paths into the assembly in three places. Thus a --deterministic+ build with --pathmap gave a different assembly in each directory that it was compiled from.

The fix uses PathMap.apply only, without GetFullPathShim. Thus the output does not change when no path map is set.

Hash directive arguments (for example #r __SOURCE_DIRECTORY__ + "/x.dll") continue to use the unmapped path, because the compiler uses them to find files on disk.

Tests

A new theory in CompilerOptions/fsc/determinism/determinism.fs has one case for each location. Each case compiles the same source in two directories with --pathmap. Then it makes sure that:

  • the DLL does not contain the unmapped directory (UTF-8 or UTF-16),
  • the two DLLs are byte-identical.

All four cases fail without the compiler change and pass with it.

Checklist

  • Test cases added
  • Release notes entry updated

🤖 Generated with Claude Code

The compiler wrote unmapped source paths into the assembly in three places.
Thus a deterministic build with a path map gave a different assembly in each
directory.

- The DebugRange of quotations and reflected definitions (dotnet#21020).
- The file name of MatchFailureException for an incomplete match (dotnet#21021).
- __SOURCE_DIRECTORY__ after a #line directive.

Hash directive arguments continue to use the unmapped path, because the
compiler uses them to find files on disk.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: New

1 participant