Skip to content

fix(all): forward --pathmap: option to FCS so CallerFilePath respects (PathMap)#4585

Merged
MangelMaxime merged 1 commit into
mainfrom
repo-assist/fix-pathmap-caller-file-path-4061-0b03ef4246fe586e
May 22, 2026
Merged

fix(all): forward --pathmap: option to FCS so CallerFilePath respects (PathMap)#4585
MangelMaxime merged 1 commit into
mainfrom
repo-assist/fix-pathmap-caller-file-path-4061-0b03ef4246fe586e

Conversation

@fable-repo-assist
Copy link
Copy Markdown
Contributor

🤖 This PR was created by Repo Assist, an automated AI assistant.

Summary

Fixes #4061[<CallerFilePath>] always produces absolute paths even when the project configures <PathMap>, <DeterministicSourcePaths>, or <SourceRoot>.

Root Cause

extractUsefulOptionsAndSources in ProjectCracker.fs selectively forwards only a small set of compiler options to FCS (--langversion:, --checknulls+, --nowarn, --warnon, --define:). The --pathmap: flag emitted by MSBuild (from <PathMap> / <DeterministicSourcePaths>) was silently dropped, leaving g.pathMap empty in FCS. Since PathMap.apply is a no-op on an empty map, [<CallerFilePath>] always returned the full absolute path.

Fix

Forward --pathmap: from the main project only — mirroring how --langversion:preview is handled — so that FCS applies the configured path mapping when resolving CallerFilePath arguments:

// Forward pathmap from the main project so CallerFilePath respects <PathMap>/<DeterministicSourcePaths>
elif line.StartsWith("--pathmap:", StringComparison.Ordinal) && isMainProj then
    accSources, line :: accOptions

Restricting this to isMainProj means path mappings from referenced libraries don't bleed into the compilation of the main project (consistent with how other project-level options are handled).

Testing

This is a project-cracker-level change. The fix takes effect as soon as the fsproj contains the relevant MSBuild properties, e.g.:

<PropertyGroup>
  <Deterministic>true</Deterministic>
  <DeterministicSourcePaths>true</DeterministicSourcePaths>
  <PathMap>$(MSBuildThisFileDirectory)=.</PathMap>
</PropertyGroup>

With this change, [<CallerFilePath>] should return ./Api/Program.fs instead of the full absolute path.

Generated by 🌈 Repo Assist, see workflow run. Learn more.

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@51c8f6ad4357d2ecc06e47120031b3d75e80227d

@fable-repo-assist fable-repo-assist Bot added automation Automated changes repo-assist Created by Repo Assist labels May 1, 2026
@MangelMaxime MangelMaxime force-pushed the repo-assist/fix-pathmap-caller-file-path-4061-0b03ef4246fe586e branch from f6592bc to 825bfa3 Compare May 22, 2026 20:21
… <PathMap>

When MSBuild generates compiler options for an fsproj that uses
<PathMap>, <DeterministicSourcePaths>, or <SourceRoot>, it emits a
--pathmap:... flag. Previously, extractUsefulOptionsAndSources discarded
this flag, so FCS always used an empty PathMap and CallerFilePath always
returned absolute paths regardless of the user's configuration.

Forward --pathmap: from the main project only (mirroring how
--langversion:
is handled) so that [<CallerFilePath>] respects the configured path
mappings at compile time.

Closes #4061

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@MangelMaxime MangelMaxime force-pushed the repo-assist/fix-pathmap-caller-file-path-4061-0b03ef4246fe586e branch from 825bfa3 to 4e2a69c Compare May 22, 2026 21:13
@MangelMaxime MangelMaxime marked this pull request as ready for review May 22, 2026 21:13
@MangelMaxime MangelMaxime changed the title fix: forward --pathmap: option to FCS so CallerFilePath respects (PathMap) fix(all): forward --pathmap: option to FCS so CallerFilePath respects (PathMap) May 22, 2026
@MangelMaxime MangelMaxime merged commit 764c383 into main May 22, 2026
31 checks passed
@MangelMaxime MangelMaxime deleted the repo-assist/fix-pathmap-caller-file-path-4061-0b03ef4246fe586e branch May 22, 2026 21:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automation Automated changes repo-assist Created by Repo Assist

Projects

None yet

Development

Successfully merging this pull request may close these issues.

deterministic/relative paths in CallerFilePath

1 participant