Skip to content

Commit

Permalink
Simplify getting the build projects from the GraphBuildResult. (#144)
Browse files Browse the repository at this point in the history
  • Loading branch information
nojaf authored Apr 16, 2022
1 parent 6de6afe commit f17dcc5
Showing 1 changed file with 10 additions and 17 deletions.
27 changes: 10 additions & 17 deletions src/Ionide.ProjInfo/Library.fs
Original file line number Diff line number Diff line change
Expand Up @@ -788,19 +788,12 @@ type WorkspaceLoaderViaProjectGraph private (toolsPath, ?globalProperties: (stri

bm.EndBuild()

let rec walkResults (known: String Set) (results: ProjectGraphNode seq) =
seq {
for nodeKey in results do
if known |> Set.contains nodeKey.ProjectInstance.FullPath |> not then
yield nodeKey
let cache = Set.add nodeKey.ProjectInstance.FullPath known
yield! walkResults cache nodeKey.ProjectReferences
else
yield! walkResults known nodeKey.ProjectReferences
}

let resultsByNode = walkResults Set.empty (result.ResultsByNode |> Seq.map (fun kvp -> kvp.Key)) |> Seq.cache
let buildProjs = resultsByNode |> Seq.map (fun p -> p.ProjectInstance.FullPath) |> Seq.toList
let buildProjs =
result.ResultsByNode.Keys
|> Seq.collect (fun (pgn: ProjectGraphNode) ->
seq { yield pgn.ProjectInstance
yield! Seq.map (fun (pr:ProjectGraphNode) -> pr.ProjectInstance) pgn.ProjectReferences })
|> Seq.toList

logger.info (
Log.setMessage "{overallCode}, projects built {count} {projects} "
Expand All @@ -811,11 +804,11 @@ type WorkspaceLoaderViaProjectGraph private (toolsPath, ?globalProperties: (stri
)

let projects =
resultsByNode
|> Seq.distinctBy (fun p -> p.ProjectInstance.FullPath)
|> Seq.map (fun p ->
buildProjs
|> List.distinctBy (fun (p:ProjectInstance) -> p.FullPath)
|> Seq.map (fun (p:ProjectInstance) ->

p.ProjectInstance.FullPath, ProjectLoader.getLoadedProjectInfo p.ProjectInstance.FullPath customProperties (ProjectLoader.LoadedProject p.ProjectInstance))
p.FullPath, ProjectLoader.getLoadedProjectInfo p.FullPath customProperties (ProjectLoader.LoadedProject p))

|> Seq.choose (fun (projectPath, projectOptionResult) ->
match projectOptionResult with
Expand Down

0 comments on commit f17dcc5

Please sign in to comment.