From f789e71e0db5e2968cbd4d644c9a36a754093811 Mon Sep 17 00:00:00 2001 From: Smaug123 <3138005+Smaug123@users.noreply.github.com> Date: Wed, 2 Oct 2024 19:22:10 +0100 Subject: [PATCH] Add CompileItem metadata to types --- src/Ionide.ProjInfo/Library.fs | 6 +++++- src/Ionide.ProjInfo/Types.fs | 29 ++++++++++++++++++++++++++++- src/Ionide.ProjInfo/VisualTree.fs | 4 ++-- 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/Ionide.ProjInfo/Library.fs b/src/Ionide.ProjInfo/Library.fs index bf609f86..9c2efb33 100644 --- a/src/Ionide.ProjInfo/Library.fs +++ b/src/Ionide.ProjInfo/Library.fs @@ -742,6 +742,10 @@ module ProjectLoader = Name = name FullPath = fullPath Link = link + Metadata = + p.Metadata + |> Seq.map (fun pm -> pm.Name, pm.EvaluatedValue) + |> Map.ofSeq } ) @@ -1587,7 +1591,7 @@ module ProjectViewer = sources |> List.choose ( function - | ProjectItem.Compile(name, fullPath) -> Some(name, fullPath) + | ProjectItem.Compile(name, fullPath, _) -> Some(name, fullPath) ) |> List.filter (fun (_, p) -> includeSourceFile p) diff --git a/src/Ionide.ProjInfo/Types.fs b/src/Ionide.ProjInfo/Types.fs index ec1af260..7c92a04b 100644 --- a/src/Ionide.ProjInfo/Types.fs +++ b/src/Ionide.ProjInfo/Types.fs @@ -48,7 +48,7 @@ module Types = | Exe | Custom of string - type ProjectItem = Compile of name: string * fullpath: string + type ProjectItem = Compile of name: string * fullpath: string * metadata: Map option type ProjectOptions = { ProjectId: string option @@ -75,10 +75,37 @@ module Types = member x.ResolvedTargetPath = defaultArg x.TargetRefPath x.TargetPath + /// Represents a `` node within an fsproj file. type CompileItem = { + /// The `Compile` node's Include contents, after MSBuild has finished evaluation. + /// For example: + /// * `` would have this set to "Foo.fs"; + /// * `` would have `"Bar/Baz.fs"`; + /// * (contrived): `` might have `true.fs` or `false.fs`, for example. Name: string + /// Full path on disk to the F# file this `Compile` node is telling MsBuild to compile. FullPath: string + /// Value of the `` sub-node, if one exists. + /// For example, `../bar.fshello` sets the metadata key "Something" to the value "hello". + /// * `` fails at project load time. + /// * `` sets the metadata key "Blah" to the empty string. + /// * `` sets the metadata key "Blah" to the string "". + /// + /// This map includes the `Link` value, if it exists, which was also extracted for convenience into the `Link` field + /// of this CompileItem. + /// + /// If you specify the same metadata key multiple times, the last value wins. (This is MsBuild's decision, not ours.) + Metadata: Map } type ToolsPath = ToolsPath of string diff --git a/src/Ionide.ProjInfo/VisualTree.fs b/src/Ionide.ProjInfo/VisualTree.fs index d3c9aab0..f5fa517d 100644 --- a/src/Ionide.ProjInfo/VisualTree.fs +++ b/src/Ionide.ProjInfo/VisualTree.fs @@ -75,11 +75,11 @@ module VisualTree = projPath |> getVisualPath None (Some sourceFile) sourceFile - ProjectItem.Compile(name, fullpath) + ProjectItem.Compile(name, fullpath, None) | Some p -> let (name, fullpath) = projPath |> getVisualPath p.Link (Some p.FullPath) p.Name - ProjectItem.Compile(name, fullpath) + ProjectItem.Compile(name, fullpath, Some p.Metadata)