Skip to content
Merged
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
13 changes: 10 additions & 3 deletions src/Ionide.ProjInfo/InspectSln.fs
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,16 @@ module InspectSln =
not (isNull item.Parent)
&& item.Parent.Id = folder.Id
)
|> Seq.map (fun p -> parseItem p, string p.Id)
|> List.ofSeq
|> List.unzip
|> Seq.map (fun p -> parseItem p)
|> List.ofSeq,

folder.Files
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

folder.Files can be null here, hence the Option.ofObj stuff to turn such a case into an empty collection

|> Option.ofObj
|> Option.map (
Seq.map makeAbsoluteFromSlnDir
>> List.ofSeq
)
|> Option.defaultValue []
)
}

Expand Down
8 changes: 8 additions & 0 deletions test/Ionide.ProjInfo.Tests/TestAssets.fs
Original file line number Diff line number Diff line change
Expand Up @@ -349,3 +349,11 @@ let ``sample 12 slnf with one project`` = {
}
]
}

let ``sample 13 sln with solution files`` = {
ProjDir = "sample13-solution-with-solution-files"
AssemblyName = ""
ProjectFile = "sample13-solution-with-solution-files.sln"
TargetFrameworks = Map.empty
ProjectReferences = []
}
31 changes: 31 additions & 0 deletions test/Ionide.ProjInfo.Tests/Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2303,6 +2303,34 @@ let sample12SlnFilterTest toolsPath loaderType workspaceFactory =
Expect.equal parsed[0].ProjectFileName fsproj "should contain the expected project"
)

let sample13SolutionFilesTest toolsPath loaderType workspaceFactory =
testCase
$"Can load sample13 sln with solution files - {loaderType}"
(fun () ->

let projPath = pathForProject ``sample 13 sln with solution files``
let projDir = Path.GetDirectoryName projPath

let expectedReadme =
projDir
/ "README.md"

let solutionContents =
InspectSln.tryParseSln projPath
|> getResult

let solutionItem = solutionContents.Items[0]

Expect.equal solutionItem.Guid (Guid("8ec462fd-d22e-90a8-e5ce-7e832ba40c5d")) "Should have the epxcted guid"
Expect.equal solutionItem.Name $"{Path.DirectorySeparatorChar}Solution Items{Path.DirectorySeparatorChar}" "Should have the expected folder name"

match solutionItem.Kind with
| InspectSln.Folder(_, files) ->
Expect.hasLength files 1 "Should have one file"
Expect.sequenceEqual files [ expectedReadme ] "Should contain the expected readme.md"
| _ -> failtestf "Expected a folder, but got %A" solutionItem.Kind
)

let tests toolsPath =
let testSample3WorkspaceLoaderExpected = [
ExpectNotification.loading "c1.fsproj"
Expand Down Expand Up @@ -2435,4 +2463,7 @@ let tests toolsPath =

sample12SlnFilterTest toolsPath (nameof (WorkspaceLoader)) WorkspaceLoader.Create
sample12SlnFilterTest toolsPath (nameof (WorkspaceLoaderViaProjectGraph)) WorkspaceLoaderViaProjectGraph.Create

sample13SolutionFilesTest toolsPath (nameof (WorkspaceLoader)) WorkspaceLoader.Create
sample13SolutionFilesTest toolsPath (nameof (WorkspaceLoaderViaProjectGraph)) WorkspaceLoaderViaProjectGraph.Create
]
3 changes: 3 additions & 0 deletions test/examples/sample13-solution-with-solution-files/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Ionide.ProjInfo

Hello world
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8EC462FD-D22E-90A8-E5CE-7E832BA40C5D}"
ProjectSection(SolutionItems) = preProject
README.md = README.md
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal