Skip to content

Commit ed11093

Browse files
authored
replace homegrown sln parser with library (#222)
1 parent 912538a commit ed11093

31 files changed

+107
-9107
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.69.0] - 2025-01-02
9+
10+
### Changed
11+
12+
* We now use the [Microsoft.VisualStudio.SolutionPersistence](https://github.com/microsoft/vs-solutionpersistence) library to parse solution files. This should be more reliable and faster than the previous implementation.
13+
814
## [0.68.0] - 2024-11-18
915

1016
### Added

Directory.Packages.props

+7-9
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<NuGetAuditMode>direct</NuGetAuditMode>
1515
</PropertyGroup>
1616
<ItemGroup>
17-
<!-- Packaing Dependencies -->
17+
<!-- Packaging Dependencies -->
1818
<PackageVersion Include="Dotnet.ReproducibleBuilds" Version="1.2.25" PrivateAssets="All" />
1919
<PackageVersion Include="Ionide.KeepAChangelog.Tasks" Version="0.1.8" PrivateAssets="All" />
2020
<!-- Main Project Dependencies -->
@@ -24,18 +24,16 @@
2424
<PackageVersion Include="Fsharp.Control.Reactive" Version="5.0.5" />
2525
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
2626
<PackageVersion Include="Argu" Version="6.2.4" />
27+
<!-- Solution-parser library. Important question: since this is also usable my MSbuild, is it subject to the same PrivateAssets stuff? -->
28+
<PackageVersion Include="Microsoft.VisualStudio.SolutionPersistence" Version="1.0.28" />
2729
<!-- MSBuild dependency - important: this should always be ExcludeAssets="runtime", and it
2830
should be kept low based
2931
on the SDK versions we want to support. See https://aka.ms/dotnet/matrixofpaine for version
3032
details. -->
31-
<PackageVersion Include="Microsoft.Build" Version="$(MicrosoftBuildPackageVersion)"
32-
PrivateAssets="All" />
33-
<PackageVersion Include="Microsoft.Build.Framework" Version="$(MicrosoftBuildPackageVersion)"
34-
PrivateAssets="All" />
35-
<PackageVersion Include="Microsoft.Build.Utilities.Core"
36-
Version="$(MicrosoftBuildPackageVersion)" PrivateAssets="All" />
37-
<PackageVersion Include="Microsoft.Build.Tasks.Core" Version="$(MicrosoftBuildPackageVersion)"
38-
PrivateAssets="All" />
33+
<PackageVersion Include="Microsoft.Build" Version="$(MicrosoftBuildPackageVersion)" PrivateAssets="All" />
34+
<PackageVersion Include="Microsoft.Build.Framework" Version="$(MicrosoftBuildPackageVersion)" PrivateAssets="All" />
35+
<PackageVersion Include="Microsoft.Build.Utilities.Core" Version="$(MicrosoftBuildPackageVersion)" PrivateAssets="All" />
36+
<PackageVersion Include="Microsoft.Build.Tasks.Core" Version="$(MicrosoftBuildPackageVersion)" PrivateAssets="All" />
3937
<!-- Test Project Dependencies -->
4038
<PackageVersion Include="Expecto" Version="$(ExpectoVersion)" />
4139
<PackageVersion Include="Expecto.Diff" Version="$(ExpectoVersion)" />

README.md

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
Parsing and evaluating of `.fsproj` files. This repository contains several packages:
66
* `Ionide.ProjInfo` - library for parsing and evaluating `.fsproj` files, using `Microsoft.Build` libraries
7-
* `Ionide.ProjInfo.Sln` - library for parsing `.sln` files
87
* `Ionide.ProjInfo.FCS` - library providing utility for mapping project data types used by `Ionide.ProjInfo` into `FSharpProjectOptions` type used by `FSharp.Compiler.Service`
98
* `Ionide.ProjInfo.ProjectSystem` - library providing high level project system component that can be used by editor tooling. It supports features like tracking changes, event-driven notifications about project loading status, and persistent caching of the data for fast initial load.
109
* `Ionide.ProjInfo.Tool` - a CLI tool intended to help with debugging the cracking of various projects easily

ionide-proj-info.sln

-15
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{0EF20E50-D07
77
EndProject
88
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Ionide.ProjInfo", "src\Ionide.ProjInfo\Ionide.ProjInfo.fsproj", "{B86D70F6-12F9-42E7-8A04-2C21FC91DF9C}"
99
EndProject
10-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ionide.ProjInfo.Sln", "src\Ionide.ProjInfo.Sln\Ionide.ProjInfo.Sln.csproj", "{7C01A809-1EA9-43A4-BEDC-5488084A22B1}"
11-
EndProject
1210
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{E53FFF53-7874-40D6-8070-EB4E6F5067B9}"
1311
EndProject
1412
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Ionide.ProjInfo.Tests", "test\Ionide.ProjInfo.Tests\Ionide.ProjInfo.Tests.fsproj", "{84BB0C5F-EE12-41C4-ADC9-05FBF54CB7CC}"
@@ -46,18 +44,6 @@ Global
4644
{B86D70F6-12F9-42E7-8A04-2C21FC91DF9C}.Release|x64.Build.0 = Release|Any CPU
4745
{B86D70F6-12F9-42E7-8A04-2C21FC91DF9C}.Release|x86.ActiveCfg = Release|Any CPU
4846
{B86D70F6-12F9-42E7-8A04-2C21FC91DF9C}.Release|x86.Build.0 = Release|Any CPU
49-
{7C01A809-1EA9-43A4-BEDC-5488084A22B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
50-
{7C01A809-1EA9-43A4-BEDC-5488084A22B1}.Debug|Any CPU.Build.0 = Debug|Any CPU
51-
{7C01A809-1EA9-43A4-BEDC-5488084A22B1}.Debug|x64.ActiveCfg = Debug|Any CPU
52-
{7C01A809-1EA9-43A4-BEDC-5488084A22B1}.Debug|x64.Build.0 = Debug|Any CPU
53-
{7C01A809-1EA9-43A4-BEDC-5488084A22B1}.Debug|x86.ActiveCfg = Debug|Any CPU
54-
{7C01A809-1EA9-43A4-BEDC-5488084A22B1}.Debug|x86.Build.0 = Debug|Any CPU
55-
{7C01A809-1EA9-43A4-BEDC-5488084A22B1}.Release|Any CPU.ActiveCfg = Release|Any CPU
56-
{7C01A809-1EA9-43A4-BEDC-5488084A22B1}.Release|Any CPU.Build.0 = Release|Any CPU
57-
{7C01A809-1EA9-43A4-BEDC-5488084A22B1}.Release|x64.ActiveCfg = Release|Any CPU
58-
{7C01A809-1EA9-43A4-BEDC-5488084A22B1}.Release|x64.Build.0 = Release|Any CPU
59-
{7C01A809-1EA9-43A4-BEDC-5488084A22B1}.Release|x86.ActiveCfg = Release|Any CPU
60-
{7C01A809-1EA9-43A4-BEDC-5488084A22B1}.Release|x86.Build.0 = Release|Any CPU
6147
{84BB0C5F-EE12-41C4-ADC9-05FBF54CB7CC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
6248
{84BB0C5F-EE12-41C4-ADC9-05FBF54CB7CC}.Debug|Any CPU.Build.0 = Debug|Any CPU
6349
{84BB0C5F-EE12-41C4-ADC9-05FBF54CB7CC}.Debug|x64.ActiveCfg = Debug|Any CPU
@@ -121,7 +107,6 @@ Global
121107
EndGlobalSection
122108
GlobalSection(NestedProjects) = preSolution
123109
{B86D70F6-12F9-42E7-8A04-2C21FC91DF9C} = {0EF20E50-D076-480D-BC88-951E5AC8643E}
124-
{7C01A809-1EA9-43A4-BEDC-5488084A22B1} = {0EF20E50-D076-480D-BC88-951E5AC8643E}
125110
{84BB0C5F-EE12-41C4-ADC9-05FBF54CB7CC} = {E53FFF53-7874-40D6-8070-EB4E6F5067B9}
126111
{AFEB904E-2ACD-4144-BD4B-BEC5772CCFA7} = {0EF20E50-D076-480D-BC88-951E5AC8643E}
127112
{5156E51B-B489-4E0A-865B-79BADB009BD1} = {0EF20E50-D076-480D-BC88-951E5AC8643E}

src/Ionide.ProjInfo.ProjectSystem/WorkspacePeek.fs

+13-29
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,13 @@ module WorkspacePeek =
2020
| FsProj
2121
| Sln
2222
| Slnf
23+
| Slnx
2324
| Fsx
2425

26+
[<return:Struct>]
27+
let inline (|HasExt|_|) (ext: string) (file: FileInfo) =
28+
if file.Extension = ext then ValueSome() else ValueNone
29+
2530
let private partitionByChoice3 =
2631
let foldBy (a, b, c) t =
2732
match t with
@@ -76,26 +81,11 @@ module WorkspacePeek =
7681
topLevelFiles
7782
|> Seq.choose (fun s ->
7883
match s with
79-
| x when
80-
x
81-
|> hasExt ".sln"
82-
->
83-
Some(UsefulFile.Sln, x)
84-
| x when
85-
x
86-
|> hasExt ".slnf"
87-
->
88-
Some(UsefulFile.Slnf, x)
89-
| x when
90-
x
91-
|> hasExt ".fsx"
92-
->
93-
Some(UsefulFile.Fsx, x)
94-
| x when
95-
x
96-
|> hasExt ".fsproj"
97-
->
98-
Some(UsefulFile.FsProj, x)
84+
| HasExt ".sln" -> Some(UsefulFile.Sln, s)
85+
| HasExt ".slnf" -> Some(UsefulFile.Slnf, s)
86+
| HasExt ".fsx" -> Some(UsefulFile.Fsx, s)
87+
| HasExt ".fsproj" -> Some(UsefulFile.FsProj, s)
88+
| HasExt ".slnx" -> Some(UsefulFile.Slnx, s)
9989
| _ -> None
10090
)
10191
|> Seq.toArray
@@ -141,20 +131,14 @@ module WorkspacePeek =
141131
let getInfo (t, (f: FileInfo)) =
142132
match t with
143133
| UsefulFile.Sln
144-
| UsefulFile.Slnf ->
134+
| UsefulFile.Slnf
135+
| UsefulFile.Slnx ->
145136
match InspectSln.tryParseSln f.FullName with
146-
| Ok(p, d) -> Some(Choice1Of3(p, d))
137+
| Ok(d) -> Some(Choice1Of3(f.FullName, d))
147138
| Error e ->
148-
let addInfo l =
149-
match e with
150-
| :? Ionide.ProjInfo.Sln.Exceptions.InvalidProjectFileException as ipfe -> Log.addContextDestructured "data" ipfe l
151-
152-
| _ -> l
153-
154139
logger.warn (
155140
Log.setMessage "Failed to load file: {filePath} : {data}"
156141
>> Log.addContext "filePath" f.FullName
157-
>> addInfo
158142
>> Log.addExn e
159143
)
160144

src/Ionide.ProjInfo.Sln/ExceptionHandling.cs

-35
This file was deleted.

0 commit comments

Comments
 (0)