diff --git a/src/Ionide.ProjInfo/Library.fs b/src/Ionide.ProjInfo/Library.fs index 2742addf..a3e70e5b 100644 --- a/src/Ionide.ProjInfo/Library.fs +++ b/src/Ionide.ProjInfo/Library.fs @@ -733,10 +733,18 @@ type WorkspaceLoaderViaProjectGraph private (toolsPath, ?globalProperties: (stri handleProjectGraphFailures <| fun () -> paths |> Seq.iter (fun p -> loadingNotification.Trigger(WorkspaceProjectState.Loading p)) - let graph = match paths |> List.ofSeq with - | [ x ] -> ProjectGraph(x, projectCollection = ProjectCollection.GlobalProjectCollection, projectInstanceFactory = projectInstanceFactory) + | [ x ] -> + let g = ProjectGraph(x, projectCollection = ProjectCollection.GlobalProjectCollection, projectInstanceFactory = projectInstanceFactory) + // When giving ProjectGraph a singular project, g.EntryPointNodes only contains that project. + // To get it to build the Graph with all the dependencies we need to look at all the ProjectNodes + // and tell the graph to use all as potentially an entrypoint + let nodes = + g.ProjectNodes + |> Seq.map(fun pn -> ProjectGraphEntryPoint pn.ProjectInstance.FullPath) + ProjectGraph(nodes, projectCollection = ProjectCollection.GlobalProjectCollection, projectInstanceFactory = projectInstanceFactory) + | xs -> let entryPoints = paths |> Seq.map ProjectGraphEntryPoint |> List.ofSeq ProjectGraph(entryPoints, projectCollection = ProjectCollection.GlobalProjectCollection, projectInstanceFactory = projectInstanceFactory) @@ -789,23 +797,18 @@ type WorkspaceLoaderViaProjectGraph private (toolsPath, ?globalProperties: (stri |> 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} " >> Log.addContextDestructured "count" (buildProjs |> Seq.length) - >> Log.addContextDestructured "projects" (buildProjs) >> Log.addContextDestructured "overallCode" result.OverallResult >> Log.addExn result.Exception ) - let projects = buildProjs - |> List.distinctBy (fun (p: ProjectInstance) -> p.FullPath) - |> Seq.map (fun (p: ProjectInstance) -> - + |> Seq.map(fun p -> p.FullPath, ProjectLoader.getLoadedProjectInfo p.FullPath customProperties (ProjectLoader.LoadedProject p)) |> Seq.choose (fun (projectPath, projectOptionResult) -> diff --git a/test/Ionide.ProjInfo.Tests/Tests.fs b/test/Ionide.ProjInfo.Tests/Tests.fs index 5e6558ba..67cb43b3 100644 --- a/test/Ionide.ProjInfo.Tests/Tests.fs +++ b/test/Ionide.ProjInfo.Tests/Tests.fs @@ -849,8 +849,10 @@ let testFCSmapManyProj toolsPath workspaceLoader (workspaceFactory: ToolsPath -> loader.Notifications.Add (function | WorkspaceProjectState.Loaded (po, knownProjects, _) -> pos <- Map.add po.ProjectFileName po pos) - - let fcsPo = FCS.mapToFSharpProjectOptions parsed.Head parsed + let parsedC1 = parsed |> Seq.find(fun x -> + x.ProjectFileName.EndsWith(``sample3 Netsdk projs``.ProjectFile) + ) + let fcsPo = FCS.mapToFSharpProjectOptions parsedC1 parsed let hasCSharpRef = fcsPo.OtherOptions |> Seq.exists (fun opt -> opt.StartsWith "-r:" && opt.EndsWith "l1.dll") let hasCSharpProjectRef = fcsPo.ReferencedProjects |> Seq.exists (fun ref -> ref.OutputFile.EndsWith "l1.dll") let hasFSharpRef = fcsPo.OtherOptions |> Seq.exists (fun opt -> opt.StartsWith "-r:" && opt.EndsWith "l2.dll") @@ -1241,13 +1243,21 @@ let debugTests toolsPath workspaceLoader (workspaceFactory: ToolsPath -> IWorksp ptestCase |> withLog (sprintf "debug - %s" workspaceLoader) (fun logger fs -> - let projPath = @"D:\Programowanie\Projekty\Ionide\dotnet-proj-info\src\Ionide.ProjInfo.Sln\Ionide.ProjInfo.Sln.csproj" - let loader = workspaceFactory toolsPath - let parsed = loader.LoadProjects [ projPath ] |> Seq.toList + // let projPath = @"D:\Programowanie\Projekty\Ionide\dotnet-proj-info\src\Ionide.ProjInfo.Sln\Ionide.ProjInfo.Sln.csproj" + // let parsedProjs = loader.LoadProjects [ projPath ] |> Seq.toList + + // printfn "%A" parsedProjs - printfn "%A" parsed + let slnPath = @"C:\Users\JimmyByrd\Documents\Repositories\public\TheAngryByrd\FsToolkit.ErrorHandling\FsToolkit.ErrorHandling.sln" + let parsedProjs = loader.LoadSln slnPath |> Seq.toList + + // printfn "%A" parsedProjs + parsedProjs + |> Seq.iter(fun p -> + Expect.isGreaterThan p.SourceFiles.Length 0 $"{p.ProjectFileName} Should have SourceFiles" + ) ) let expensiveTests toolsPath (workspaceFactory: ToolsPath -> IWorkspaceLoader) =