Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Use the file name relative to the response file without the extension.
  • Loading branch information
nojaf committed Jan 30, 2024
commit 1749ffee4fddca9e583bfde86bb90b4723bd8e07
Original file line number Diff line number Diff line change
Expand Up @@ -831,8 +831,12 @@ let ``TypeCheck last file in project with transparent compiler`` useTransparentC

let lastFile =
syntheticProject.SourceFiles
|> List.last
|> fun sf -> sf.Id
|> List.tryLast
|> Option.map (fun sf -> sf.Id)

match lastFile with
| None -> failwithf "Last file of project could not be found"
| Some lastFile ->

workflow {
clearCache
Expand Down
19 changes: 16 additions & 3 deletions tests/FSharp.Test.Utilities/ProjectGeneration.fs
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,14 @@ type SyntheticSourceFile =
Source: string
ExtraSource: string
EntryPoint: bool
/// The absolute path of an existing F# file.
PhysicalFileName: string option
}

member this.FileName =
if File.Exists this.Id then this.Id else $"File%s{this.Id}.fs"
match this.PhysicalFileName with
| Some f -> f
| None -> $"File%s{this.Id}.fs"

member this.SignatureFileName = $"{this.FileName}i"
member this.TypeName = $"T{this.Id}V_{this.PublicVersion}"
Expand All @@ -218,7 +222,8 @@ let sourceFile fileId deps =
HasErrors = false
Source = ""
ExtraSource = ""
EntryPoint = false }
EntryPoint = false
PhysicalFileName = None }


let OptionsCache = ConcurrentDictionary()
Expand Down Expand Up @@ -505,8 +510,15 @@ let mkSyntheticProjectForResponseFile (responseFile: FileInfo) : SyntheticProjec
let sourceFiles =
implementationFiles
|> List.map (fun implPath ->
let id =
let fileNameWithoutExtension = Path.GetFileNameWithoutExtension implPath
let directoryOfFile = FileInfo(implPath).DirectoryName
let relativeUri = Uri(responseFile.FullName).MakeRelativeUri(Uri(directoryOfFile))
let relativeFolderPath = Uri.UnescapeDataString(relativeUri.ToString()).Replace('/', Path.DirectorySeparatorChar)
Path.Combine(relativeFolderPath, fileNameWithoutExtension)

{
Id = implPath
Id = id
PublicVersion = 1
InternalVersion = 1
DependsOn = []
Expand All @@ -518,6 +530,7 @@ let mkSyntheticProjectForResponseFile (responseFile: FileInfo) : SyntheticProjec
Source = File.ReadAllText implPath
ExtraSource = ""
EntryPoint = false
PhysicalFileName = Some implPath
}
)

Expand Down