From 9b54ec14834d0381fd761413ba56692a06997af6 Mon Sep 17 00:00:00 2001 From: "Daniel P. Purkhus" Date: Fri, 3 Nov 2023 13:55:14 +0000 Subject: [PATCH] WIP --- .../WorkspacePeek.fs | 15 ++++++++++----- src/Ionide.ProjInfo/Library.fs | 8 ++++++++ 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/Ionide.ProjInfo.ProjectSystem/WorkspacePeek.fs b/src/Ionide.ProjInfo.ProjectSystem/WorkspacePeek.fs index 625f9a0f..2452ae9e 100644 --- a/src/Ionide.ProjInfo.ProjectSystem/WorkspacePeek.fs +++ b/src/Ionide.ProjInfo.ProjectSystem/WorkspacePeek.fs @@ -9,10 +9,12 @@ module WorkspacePeek = let rec logger = LogProvider.getLoggerByQuotation <@ logger @> + type FsprojData = { Path: string; CompileItems: string list } + [] type Interesting = | Solution of string * InspectSln.SolutionData - | Directory of string * string list + | Directory of string * FsprojData list open System.IO @@ -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 @@ -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 })) ] diff --git a/src/Ionide.ProjInfo/Library.fs b/src/Ionide.ProjInfo/Library.fs index ad4769b7..45044bb8 100644 --- a/src/Ionide.ProjInfo/Library.fs +++ b/src/Ionide.ProjInfo/Library.fs @@ -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 = @@ -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 ->