Skip to content

Commit e0a1fe8

Browse files
committed
Correct generation of ReferencedProjects
On Mono this also required removing duplicate forward slashes, which otherwise would prevent the .dll or .exe output filename in the -r: command line option matching that in ReferencedProjects.
1 parent 9208824 commit e0a1fe8

File tree

2 files changed

+18
-15
lines changed

2 files changed

+18
-15
lines changed

src/fsharp/vs/service.fs

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2762,6 +2762,9 @@ type FSharpProjectFileInfo (fsprojFileName:string, ?properties, ?enableLogging)
27622762
yield i.FinalItemSpec
27632763
for i in project.GetEvaluatedItemsByName("ChildProjectReferences") do
27642764
yield i.FinalItemSpec ]
2765+
// Duplicate slashes sometimes appear in the output here, which prevents
2766+
// them from matching keys used in FSharpProjectOptions.ReferencedProjects
2767+
|> List.map (fun (s: string) -> s.Replace("//","/"))
27652768

27662769
outFileOpt, directory, getItems, references, projectReferences, getProp project, project.FullFileName
27672770

@@ -3155,19 +3158,19 @@ type FSharpChecker(projectCacheSize, keepAssemblyContents, keepAllBackgroundReso
31553158
#if SILVERLIGHT
31563159
#else
31573160
#if FX_ATLEAST_45
3158-
member ic.GetProjectOptionsFromProjectFile(projectFileName, ?properties : (string * string) list, ?loadedTimeStamp) =
3159-
let parsedProject = FSharpProjectFileInfo(projectFileName, ?properties=properties)
3160-
let args = parsedProject.Options |> Array.ofList
3161-
3162-
let projectOptions = ic.GetProjectOptionsFromCommandLineArgs(projectFileName, args, ?loadedTimeStamp=loadedTimeStamp)
3163-
let referencedProjectOptions =
3164-
[| for file in parsedProject.ProjectReferences do
3165-
if Path.GetExtension(file) = ".fsproj" then
3166-
yield file, ic.GetProjectOptionsFromProjectFile(file, ?properties=properties, ?loadedTimeStamp=loadedTimeStamp) |]
3167-
3168-
{ projectOptions
3169-
with ReferencedProjects = referencedProjectOptions }
3170-
3161+
member ic.GetProjectOptionsFromProjectFile(projectFileName, ?properties : (string * string) list, ?loadedTimeStamp) =
3162+
let rec getOptions file : Option<string> * FSharpProjectOptions =
3163+
let parsedProject = FSharpProjectFileInfo.Parse(file, ?properties=properties)
3164+
let projectOptions = ic.GetProjectOptionsFromCommandLineArgs(file, Array.ofList parsedProject.Options, ?loadedTimeStamp=loadedTimeStamp)
3165+
let referencedProjectOptions =
3166+
[| for file in parsedProject.ProjectReferences do
3167+
if Path.GetExtension(file) = ".fsproj" then
3168+
match getOptions file with
3169+
| Some outFile, opts -> yield outFile, opts
3170+
| None, _ -> () |]
3171+
parsedProject.OutputFile, { projectOptions with ReferencedProjects = referencedProjectOptions }
3172+
3173+
snd (getOptions projectFileName)
31713174
#endif
31723175
#endif
31733176

tests/service/ProjectOptionsTests.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ let ``Project file parsing -- project references``() =
207207
let options = checker.GetProjectOptionsFromProjectFile(f2)
208208

209209
options.ReferencedProjects |> should haveLength 1
210-
fst options.ReferencedProjects.[0] |> should endWith "Test1.fsproj"
210+
fst options.ReferencedProjects.[0] |> should endWith "Test1.dll"
211211
snd options.ReferencedProjects.[0] |> should equal (checker.GetProjectOptionsFromProjectFile(f1))
212212

213213
[<Test>]
@@ -217,7 +217,7 @@ let ``Project file parsing -- multi language project``() =
217217
let options = checker.GetProjectOptionsFromProjectFile(f)
218218

219219
options.ReferencedProjects |> should haveLength 1
220-
options.ReferencedProjects.[0] |> fst |> should endWith "ConsoleApplication2.fsproj"
220+
options.ReferencedProjects.[0] |> fst |> should endWith "ConsoleApplication2.exe"
221221

222222
checkOption options.OtherOptions "ConsoleApplication2.exe"
223223
checkOption options.OtherOptions "ConsoleApplication3.exe"

0 commit comments

Comments
 (0)