fix: forward --pathmap: option to FCS so CallerFilePath respects (PathMap)#4585
Draft
fable-repo-assist[bot] wants to merge 2 commits intomainfrom
Draft
Conversation
…hMap> 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>
24 tasks
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.
🤖 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
extractUsefulOptionsAndSourcesinProjectCracker.fsselectively 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, leavingg.pathMapempty in FCS. SincePathMap.applyis 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:previewis handled — so that FCS applies the configured path mapping when resolvingCallerFilePatharguments:Restricting this to
isMainProjmeans 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.:
With this change,
[<CallerFilePath>]should return./Api/Program.fsinstead of the full absolute path.