Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 38f6810

Browse files
committed
Merge pull request #450 from rneatherway/referenced-projects
Correct generation of ReferencedProjects
2 parents 59e2725 + e0a1fe8 commit 38f6810

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
@@ -2760,6 +2760,9 @@ type FSharpProjectFileInfo (fsprojFileName:string, ?properties, ?enableLogging)
27602760
yield i.FinalItemSpec
27612761
for i in project.GetEvaluatedItemsByName("ChildProjectReferences") do
27622762
yield i.FinalItemSpec ]
2763+
// Duplicate slashes sometimes appear in the output here, which prevents
2764+
// them from matching keys used in FSharpProjectOptions.ReferencedProjects
2765+
|> List.map (fun (s: string) -> s.Replace("//","/"))
27632766

27642767
outFileOpt, directory, getItems, references, projectReferences, getProp project, project.FullFileName
27652768

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

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)