Skip to content

Correct generation of ReferencedProjects #450

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 19, 2015
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
29 changes: 16 additions & 13 deletions src/fsharp/vs/service.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2762,6 +2762,9 @@ type FSharpProjectFileInfo (fsprojFileName:string, ?properties, ?enableLogging)
yield i.FinalItemSpec
for i in project.GetEvaluatedItemsByName("ChildProjectReferences") do
yield i.FinalItemSpec ]
// Duplicate slashes sometimes appear in the output here, which prevents
// them from matching keys used in FSharpProjectOptions.ReferencedProjects
|> List.map (fun (s: string) -> s.Replace("//","/"))

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

Expand Down Expand Up @@ -3155,19 +3158,19 @@ type FSharpChecker(projectCacheSize, keepAssemblyContents, keepAllBackgroundReso
#if SILVERLIGHT
#else
#if FX_ATLEAST_45
member ic.GetProjectOptionsFromProjectFile(projectFileName, ?properties : (string * string) list, ?loadedTimeStamp) =
let parsedProject = FSharpProjectFileInfo(projectFileName, ?properties=properties)
let args = parsedProject.Options |> Array.ofList

let projectOptions = ic.GetProjectOptionsFromCommandLineArgs(projectFileName, args, ?loadedTimeStamp=loadedTimeStamp)
let referencedProjectOptions =
[| for file in parsedProject.ProjectReferences do
if Path.GetExtension(file) = ".fsproj" then
yield file, ic.GetProjectOptionsFromProjectFile(file, ?properties=properties, ?loadedTimeStamp=loadedTimeStamp) |]

{ projectOptions
with ReferencedProjects = referencedProjectOptions }

member ic.GetProjectOptionsFromProjectFile(projectFileName, ?properties : (string * string) list, ?loadedTimeStamp) =
let rec getOptions file : Option<string> * FSharpProjectOptions =
let parsedProject = FSharpProjectFileInfo.Parse(file, ?properties=properties)
let projectOptions = ic.GetProjectOptionsFromCommandLineArgs(file, Array.ofList parsedProject.Options, ?loadedTimeStamp=loadedTimeStamp)
let referencedProjectOptions =
[| for file in parsedProject.ProjectReferences do
if Path.GetExtension(file) = ".fsproj" then
match getOptions file with
| Some outFile, opts -> yield outFile, opts
| None, _ -> () |]
parsedProject.OutputFile, { projectOptions with ReferencedProjects = referencedProjectOptions }

snd (getOptions projectFileName)
#endif
#endif

Expand Down
4 changes: 2 additions & 2 deletions tests/service/ProjectOptionsTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ let ``Project file parsing -- project references``() =
let options = checker.GetProjectOptionsFromProjectFile(f2)

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

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

options.ReferencedProjects |> should haveLength 1
options.ReferencedProjects.[0] |> fst |> should endWith "ConsoleApplication2.fsproj"
options.ReferencedProjects.[0] |> fst |> should endWith "ConsoleApplication2.exe"

checkOption options.OtherOptions "ConsoleApplication2.exe"
checkOption options.OtherOptions "ConsoleApplication3.exe"
Expand Down