Skip to content
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

[WIP] Lazy load projects #198

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
15 changes: 10 additions & 5 deletions src/Ionide.ProjInfo.ProjectSystem/WorkspacePeek.fs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ module WorkspacePeek =

let rec logger = LogProvider.getLoggerByQuotation <@ logger @>

type FsprojData = { Path: string; CompileItems: string list }

[<RequireQualifiedAccess>]
type Interesting =
| Solution of string * InspectSln.SolutionData
| Directory of string * string list
| Directory of string * FsprojData list

open System.IO

Expand Down Expand Up @@ -160,7 +162,11 @@ module WorkspacePeek =

None
| UsefulFile.Fsx -> Some(Choice2Of3(f.FullName))
| UsefulFile.FsProj -> Some(Choice3Of3(f.FullName))
| UsefulFile.FsProj ->
// TODO: Read the fsproj file and get the compile items
let compileItems = Ionide.ProjInfo.ProjectLoader.getFsprojCompileItemPaths f.FullName

Some(Choice3Of3(f.FullName, compileItems))

let found =
dirs
Expand All @@ -175,13 +181,12 @@ module WorkspacePeek =
let dir =
rootDir,
(fsprojs
|> List.sort)
|> List.sortBy (fun (p, _) -> p))

[
yield!
slns
|> List.map Interesting.Solution
yield
dir
|> Interesting.Directory
Interesting.Directory (fst dir, (snd dir) |> List.map (fun (p, c) -> { Path = p; CompileItems = c |> List.ofSeq }))
]
8 changes: 8 additions & 0 deletions src/Ionide.ProjInfo/Library.fs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ open System.Diagnostics
open System.Runtime.InteropServices
open Ionide.ProjInfo.Logging
open Patterns
open System.Xml

/// functions for .net sdk probing
module SdkDiscovery =
Expand Down Expand Up @@ -599,6 +600,13 @@ module ProjectLoader =
}
)

let getFsprojCompileItemPaths (fsprojPath: string) =
use pc = new ProjectCollection(null)
let pi = pc.LoadProject(fsprojPath)
let pi = pi.CreateProjectInstance()
let compileItems = getCompileItems (LoadedProject pi)
compileItems |> Seq.map(fun i -> i.FullPath)

let getNuGetReferences (LoadedProject project) =
project.Items
|> Seq.filter (fun p ->
Expand Down