Skip to content

Commit 65a4143

Browse files
authored
Make InspectSln.parseFolder return the list of files in a folder (#233)
* Return a list of files from parseFolder * Tweak tests
1 parent dc7cd54 commit 65a4143

File tree

5 files changed

+71
-3
lines changed

5 files changed

+71
-3
lines changed

src/Ionide.ProjInfo/InspectSln.fs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,16 @@ module InspectSln =
9797
not (isNull item.Parent)
9898
&& item.Parent.Id = folder.Id
9999
)
100-
|> Seq.map (fun p -> parseItem p, string p.Id)
101-
|> List.ofSeq
102-
|> List.unzip
100+
|> Seq.map (fun p -> parseItem p)
101+
|> List.ofSeq,
102+
103+
folder.Files
104+
|> Option.ofObj
105+
|> Option.map (
106+
Seq.map makeAbsoluteFromSlnDir
107+
>> List.ofSeq
108+
)
109+
|> Option.defaultValue []
103110
)
104111
}
105112

test/Ionide.ProjInfo.Tests/TestAssets.fs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,3 +349,11 @@ let ``sample 12 slnf with one project`` = {
349349
}
350350
]
351351
}
352+
353+
let ``sample 13 sln with solution files`` = {
354+
ProjDir = "sample13-solution-with-solution-files"
355+
AssemblyName = ""
356+
ProjectFile = "sample13-solution-with-solution-files.sln"
357+
TargetFrameworks = Map.empty
358+
ProjectReferences = []
359+
}

test/Ionide.ProjInfo.Tests/Tests.fs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2303,6 +2303,34 @@ let sample12SlnFilterTest toolsPath loaderType workspaceFactory =
23032303
Expect.equal parsed[0].ProjectFileName fsproj "should contain the expected project"
23042304
)
23052305

2306+
let sample13SolutionFilesTest toolsPath loaderType workspaceFactory =
2307+
testCase
2308+
$"Can load sample13 sln with solution files - {loaderType}"
2309+
(fun () ->
2310+
2311+
let projPath = pathForProject ``sample 13 sln with solution files``
2312+
let projDir = Path.GetDirectoryName projPath
2313+
2314+
let expectedReadme =
2315+
projDir
2316+
/ "README.md"
2317+
2318+
let solutionContents =
2319+
InspectSln.tryParseSln projPath
2320+
|> getResult
2321+
2322+
let solutionItem = solutionContents.Items[0]
2323+
2324+
Expect.equal solutionItem.Guid (Guid("8ec462fd-d22e-90a8-e5ce-7e832ba40c5d")) "Should have the epxcted guid"
2325+
Expect.equal solutionItem.Name $"{Path.DirectorySeparatorChar}Solution Items{Path.DirectorySeparatorChar}" "Should have the expected folder name"
2326+
2327+
match solutionItem.Kind with
2328+
| InspectSln.Folder(_, files) ->
2329+
Expect.hasLength files 1 "Should have one file"
2330+
Expect.sequenceEqual files [ expectedReadme ] "Should contain the expected readme.md"
2331+
| _ -> failtestf "Expected a folder, but got %A" solutionItem.Kind
2332+
)
2333+
23062334
let tests toolsPath =
23072335
let testSample3WorkspaceLoaderExpected = [
23082336
ExpectNotification.loading "c1.fsproj"
@@ -2435,4 +2463,7 @@ let tests toolsPath =
24352463

24362464
sample12SlnFilterTest toolsPath (nameof (WorkspaceLoader)) WorkspaceLoader.Create
24372465
sample12SlnFilterTest toolsPath (nameof (WorkspaceLoaderViaProjectGraph)) WorkspaceLoaderViaProjectGraph.Create
2466+
2467+
sample13SolutionFilesTest toolsPath (nameof (WorkspaceLoader)) WorkspaceLoader.Create
2468+
sample13SolutionFilesTest toolsPath (nameof (WorkspaceLoaderViaProjectGraph)) WorkspaceLoaderViaProjectGraph.Create
24382469
]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Ionide.ProjInfo
2+
3+
Hello world
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.0.31903.59
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8EC462FD-D22E-90A8-E5CE-7E832BA40C5D}"
7+
ProjectSection(SolutionItems) = preProject
8+
README.md = README.md
9+
EndProjectSection
10+
EndProject
11+
Global
12+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
13+
Debug|Any CPU = Debug|Any CPU
14+
Release|Any CPU = Release|Any CPU
15+
EndGlobalSection
16+
GlobalSection(SolutionProperties) = preSolution
17+
HideSolutionNode = FALSE
18+
EndGlobalSection
19+
EndGlobal

0 commit comments

Comments
 (0)