Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/Fable.Compiler/ProjectCracker.fs
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,9 @@ let private extractUsefulOptionsAndSources
// Only forward the nullness flag if it is coming from the main project
elif line.StartsWith("--checknulls+", StringComparison.Ordinal) && isMainProj then
accSources, line :: accOptions
// Forward pathmap from the main project so CallerFilePath respects <PathMap>/<DeterministicSourcePaths>
elif line.StartsWith("--pathmap:", StringComparison.Ordinal) && isMainProj then
accSources, line :: accOptions
elif
line.StartsWith("--nowarn", StringComparison.Ordinal)
|| line.StartsWith("--warnon", StringComparison.Ordinal)
Expand Down
14 changes: 14 additions & 0 deletions tests/Integration/Integration/data/pathMap/CallerFilePathTest.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module CallerFilePathTest

open System.Runtime.CompilerServices
open System.Runtime.InteropServices

type Log =
static member info
(
message: string,
[<CallerFilePath; Optional; DefaultParameterValue("")>] path: string
) =
printfn "%s: %s" path message

Log.info "hello"
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

import { class_type } from "./fable_modules/fable-library-js/Reflection.js";
import { printf, toConsole } from "./fable_modules/fable-library-js/String.js";

export class Log {
constructor() {
}
}

export function Log_$reflection() {
return class_type("CallerFilePathTest.Log", undefined, Log);
}

export function Log_info_Z384F8060(message, path = "") {
toConsole(printf("%s: %s"))(path)(message);
}

Log_info_Z384F8060("hello", "./CallerFilePathTest.fs");

18 changes: 18 additions & 0 deletions tests/Integration/Integration/data/pathMap/pathMap.fsproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<RollForward>Major</RollForward>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PathMap>$(MSBuildThisFileDirectory)=.</PathMap>
</PropertyGroup>

<ItemGroup>
<Compile Include="CallerFilePathTest.fs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Fable.Core" Version="4.5.0" />
</ItemGroup>

</Project>
Loading