Skip to content

Commit 3878ffb

Browse files
committed
Formatting
1 parent de4036c commit 3878ffb

File tree

5 files changed

+66
-52
lines changed

5 files changed

+66
-52
lines changed

.config/dotnet-tools.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"isRoot": true,
44
"tools": {
55
"fantomas": {
6-
"version": "7.0.0",
6+
"version": "7.0.1",
77
"commands": [
88
"fantomas"
99
],

src/Ionide.ProjInfo.ProjectSystem/WorkspacePeek.fs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,12 @@ module WorkspacePeek =
2323
| Slnx
2424
| Fsx
2525

26-
[<return:Struct>]
26+
[<return: Struct>]
2727
let inline (|HasExt|_|) (ext: string) (file: FileInfo) =
28-
if file.Extension = ext then ValueSome() else ValueNone
28+
if file.Extension = ext then
29+
ValueSome()
30+
else
31+
ValueNone
2932

3033
let private partitionByChoice3 =
3134
let foldBy (a, b, c) t =

src/Ionide.ProjInfo/InspectSln.fs

Lines changed: 56 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ module InspectSln =
4747

4848
let private tryLoadSolutionModel (slnFilePath: string) =
4949
// use the VS library to parse the solution
50-
match SolutionSerializers.GetSerializerByMoniker(slnFilePath) with
51-
| null -> Error (exn $"Unsupported solution file format %s{Path.GetExtension(slnFilePath)}")
52-
| serializer ->
53-
try
54-
let model = serializer.OpenAsync(slnFilePath, CancellationToken.None).GetAwaiter().GetResult()
55-
Ok(model)
56-
with
57-
| ex -> Error ex
50+
match SolutionSerializers.GetSerializerByMoniker(slnFilePath) with
51+
| null -> Error(exn $"Unsupported solution file format %s{Path.GetExtension(slnFilePath)}")
52+
| serializer ->
53+
try
54+
let model = serializer.OpenAsync(slnFilePath, CancellationToken.None).GetAwaiter().GetResult()
55+
Ok(model)
56+
with ex ->
57+
Error ex
5858

5959
/// Parses a file on disk and returns data about its contents. Supports sln, slnf, and slnx files.
6060
let tryParseSln (slnFilePath: string) =
@@ -74,41 +74,55 @@ module InspectSln =
7474
normalizeDirSeparators
7575
>> makeAbs
7676

77-
let parseItem (item: Model.SolutionItemModel): SolutionItem =
78-
{
79-
Guid = item.Id
80-
Name = ""
81-
Kind = SolutionItemKind.Unknown
82-
}
83-
84-
let parseProject (project: Model.SolutionProjectModel): SolutionItem =
85-
{ Guid = project.Id
86-
Name= makeAbsoluteFromSlnDir project.FilePath
87-
Kind = SolutionItemKind.MSBuildFormat [] // TODO: could theoretically parse configurations here
88-
}
89-
90-
let parseFolder (folder: Model.SolutionFolderModel): SolutionItem =
91-
{
92-
Guid = folder.Id
93-
Name = makeAbsoluteFromSlnDir folder.Path
94-
Kind =
95-
SolutionItemKind.Folder (
96-
sln.SolutionItems |> Seq.filter (fun item -> not (isNull item.Parent) && item.Parent.Id = folder.Id) |> Seq.map (fun p -> parseItem p, string p.Id) |> List.ofSeq |> List.unzip)
97-
}
77+
let parseItem (item: Model.SolutionItemModel) : SolutionItem = {
78+
Guid = item.Id
79+
Name = ""
80+
Kind = SolutionItemKind.Unknown
81+
}
82+
83+
let parseProject (project: Model.SolutionProjectModel) : SolutionItem = {
84+
Guid = project.Id
85+
Name = makeAbsoluteFromSlnDir project.FilePath
86+
Kind = SolutionItemKind.MSBuildFormat [] // TODO: could theoretically parse configurations here
87+
}
88+
89+
let parseFolder (folder: Model.SolutionFolderModel) : SolutionItem = {
90+
Guid = folder.Id
91+
Name = makeAbsoluteFromSlnDir folder.Path
92+
Kind =
93+
SolutionItemKind.Folder(
94+
sln.SolutionItems
95+
|> Seq.filter (fun item ->
96+
not (isNull item.Parent)
97+
&& item.Parent.Id = folder.Id
98+
)
99+
|> Seq.map (fun p -> parseItem p, string p.Id)
100+
|> List.ofSeq
101+
|> List.unzip
102+
)
103+
}
98104

99105
// three kinds of items - projects, folders, items
100106
// yield them all here
101107
let projectsWeCareAbout =
102108
match projectsToRead with
103109
| None -> sln.SolutionProjects :> seq<_>
104-
| Some filteredProjects -> sln.SolutionProjects |> Seq.filter (fun slnProject -> filteredProjects.Contains(makeAbsoluteFromSlnDir slnProject.FilePath))
105-
106-
let allItems =
107-
[
108-
yield! projectsWeCareAbout |> Seq.map parseProject
109-
yield! sln.SolutionFolders |> Seq.map parseFolder
110-
yield! sln.SolutionItems |> Seq.filter (fun item -> isNull item.Parent) |> Seq.map parseItem
111-
]
110+
| Some filteredProjects ->
111+
sln.SolutionProjects
112+
|> Seq.filter (fun slnProject -> filteredProjects.Contains(makeAbsoluteFromSlnDir slnProject.FilePath))
113+
114+
let allItems = [
115+
yield!
116+
projectsWeCareAbout
117+
|> Seq.map parseProject
118+
yield!
119+
sln.SolutionFolders
120+
|> Seq.map parseFolder
121+
yield!
122+
sln.SolutionItems
123+
|> Seq.filter (fun item -> isNull item.Parent)
124+
|> Seq.map parseItem
125+
]
112126

113127
let data = {
114128
Items = allItems
@@ -122,18 +136,18 @@ module InspectSln =
122136
let options = new JsonDocumentOptions(AllowTrailingCommas = true, CommentHandling = JsonCommentHandling.Skip)
123137
let text = JsonDocument.Parse(File.ReadAllText(slnfPath), options)
124138
let solutionElement = text.RootElement.GetProperty("solution")
125-
let slnPath = solutionElement.GetProperty("path").GetString();
139+
let slnPath = solutionElement.GetProperty("path").GetString()
140+
126141
let projects =
127142
solutionElement.GetProperty("projects").EnumerateArray()
128143
|> Seq.map (fun p -> p.GetString())
129144
|> Set.ofSeq
145+
130146
slnPath, projects
131147

132148
match tryLoadSolutionModel slnFilePath with
133-
| Ok sln ->
134-
Ok (parseSln sln (Some projectsToRead))
135-
| Error ex ->
136-
Error ex
149+
| Ok sln -> Ok(parseSln sln (Some projectsToRead))
150+
| Error ex -> Error ex
137151

138152
if slnFilePath.EndsWith(".slnf") then
139153
parseSlnf slnFilePath

src/Ionide.ProjInfo/Types.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ module Types =
6969
Properties: Property list
7070
CustomProperties: Property list
7171
} with
72+
7273
/// ResolvedTargetPath is the path to the primary reference assembly for this project.
7374
/// For projects that produce ReferenceAssemblies, this is the path to the reference assembly.
7475
/// For other projects, this is the same as TargetPath.
75-
member x.ResolvedTargetPath =
76-
defaultArg x.TargetRefPath x.TargetPath
76+
member x.ResolvedTargetPath = defaultArg x.TargetRefPath x.TargetPath
7777

7878
/// Represents a `<Compile>` node within an fsproj file.
7979
type CompileItem = {

test/Ionide.ProjInfo.Tests/Program.fs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,8 @@ let main argv =
1919
let toolsPath = Init.init (IO.DirectoryInfo Environment.CurrentDirectory) None
2020

2121
let args = [
22-
CLIArguments.Printer (TestPrinters.summaryPrinter defaultConfig.printer)
22+
CLIArguments.Printer(TestPrinters.summaryPrinter defaultConfig.printer)
2323
CLIArguments.Verbosity LogLevel.Verbose
2424
]
2525

26-
Tests.runTestsWithCLIArgs
27-
args
28-
argv
29-
tests
26+
Tests.runTestsWithCLIArgs args argv tests

0 commit comments

Comments
 (0)