Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace homegrown sln parser with library #222

Merged
merged 1 commit into from
Jan 7, 2025
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.69.0] - 2025-01-02

### Changed

* 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.

## [0.68.0] - 2024-11-18

### Added
Expand Down
16 changes: 7 additions & 9 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<NuGetAuditMode>direct</NuGetAuditMode>
</PropertyGroup>
<ItemGroup>
<!-- Packaing Dependencies -->
<!-- Packaging Dependencies -->
<PackageVersion Include="Dotnet.ReproducibleBuilds" Version="1.2.25" PrivateAssets="All" />
<PackageVersion Include="Ionide.KeepAChangelog.Tasks" Version="0.1.8" PrivateAssets="All" />
<!-- Main Project Dependencies -->
Expand All @@ -24,18 +24,16 @@
<PackageVersion Include="Fsharp.Control.Reactive" Version="5.0.5" />
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
<PackageVersion Include="Argu" Version="6.2.4" />
<!-- Solution-parser library. Important question: since this is also usable my MSbuild, is it subject to the same PrivateAssets stuff? -->
<PackageVersion Include="Microsoft.VisualStudio.SolutionPersistence" Version="1.0.28" />
<!-- MSBuild dependency - important: this should always be ExcludeAssets="runtime", and it
should be kept low based
on the SDK versions we want to support. See https://aka.ms/dotnet/matrixofpaine for version
details. -->
<PackageVersion Include="Microsoft.Build" Version="$(MicrosoftBuildPackageVersion)"
PrivateAssets="All" />
<PackageVersion Include="Microsoft.Build.Framework" Version="$(MicrosoftBuildPackageVersion)"
PrivateAssets="All" />
<PackageVersion Include="Microsoft.Build.Utilities.Core"
Version="$(MicrosoftBuildPackageVersion)" PrivateAssets="All" />
<PackageVersion Include="Microsoft.Build.Tasks.Core" Version="$(MicrosoftBuildPackageVersion)"
PrivateAssets="All" />
<PackageVersion Include="Microsoft.Build" Version="$(MicrosoftBuildPackageVersion)" PrivateAssets="All" />
<PackageVersion Include="Microsoft.Build.Framework" Version="$(MicrosoftBuildPackageVersion)" PrivateAssets="All" />
<PackageVersion Include="Microsoft.Build.Utilities.Core" Version="$(MicrosoftBuildPackageVersion)" PrivateAssets="All" />
<PackageVersion Include="Microsoft.Build.Tasks.Core" Version="$(MicrosoftBuildPackageVersion)" PrivateAssets="All" />
<!-- Test Project Dependencies -->
<PackageVersion Include="Expecto" Version="$(ExpectoVersion)" />
<PackageVersion Include="Expecto.Diff" Version="$(ExpectoVersion)" />
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

Parsing and evaluating of `.fsproj` files. This repository contains several packages:
* `Ionide.ProjInfo` - library for parsing and evaluating `.fsproj` files, using `Microsoft.Build` libraries
* `Ionide.ProjInfo.Sln` - library for parsing `.sln` files
* `Ionide.ProjInfo.FCS` - library providing utility for mapping project data types used by `Ionide.ProjInfo` into `FSharpProjectOptions` type used by `FSharp.Compiler.Service`
* `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.
* `Ionide.ProjInfo.Tool` - a CLI tool intended to help with debugging the cracking of various projects easily
Expand Down
15 changes: 0 additions & 15 deletions ionide-proj-info.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{0EF20E50-D07
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Ionide.ProjInfo", "src\Ionide.ProjInfo\Ionide.ProjInfo.fsproj", "{B86D70F6-12F9-42E7-8A04-2C21FC91DF9C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ionide.ProjInfo.Sln", "src\Ionide.ProjInfo.Sln\Ionide.ProjInfo.Sln.csproj", "{7C01A809-1EA9-43A4-BEDC-5488084A22B1}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{E53FFF53-7874-40D6-8070-EB4E6F5067B9}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Ionide.ProjInfo.Tests", "test\Ionide.ProjInfo.Tests\Ionide.ProjInfo.Tests.fsproj", "{84BB0C5F-EE12-41C4-ADC9-05FBF54CB7CC}"
Expand Down Expand Up @@ -46,18 +44,6 @@ Global
{B86D70F6-12F9-42E7-8A04-2C21FC91DF9C}.Release|x64.Build.0 = Release|Any CPU
{B86D70F6-12F9-42E7-8A04-2C21FC91DF9C}.Release|x86.ActiveCfg = Release|Any CPU
{B86D70F6-12F9-42E7-8A04-2C21FC91DF9C}.Release|x86.Build.0 = Release|Any CPU
{7C01A809-1EA9-43A4-BEDC-5488084A22B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7C01A809-1EA9-43A4-BEDC-5488084A22B1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7C01A809-1EA9-43A4-BEDC-5488084A22B1}.Debug|x64.ActiveCfg = Debug|Any CPU
{7C01A809-1EA9-43A4-BEDC-5488084A22B1}.Debug|x64.Build.0 = Debug|Any CPU
{7C01A809-1EA9-43A4-BEDC-5488084A22B1}.Debug|x86.ActiveCfg = Debug|Any CPU
{7C01A809-1EA9-43A4-BEDC-5488084A22B1}.Debug|x86.Build.0 = Debug|Any CPU
{7C01A809-1EA9-43A4-BEDC-5488084A22B1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7C01A809-1EA9-43A4-BEDC-5488084A22B1}.Release|Any CPU.Build.0 = Release|Any CPU
{7C01A809-1EA9-43A4-BEDC-5488084A22B1}.Release|x64.ActiveCfg = Release|Any CPU
{7C01A809-1EA9-43A4-BEDC-5488084A22B1}.Release|x64.Build.0 = Release|Any CPU
{7C01A809-1EA9-43A4-BEDC-5488084A22B1}.Release|x86.ActiveCfg = Release|Any CPU
{7C01A809-1EA9-43A4-BEDC-5488084A22B1}.Release|x86.Build.0 = Release|Any CPU
{84BB0C5F-EE12-41C4-ADC9-05FBF54CB7CC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{84BB0C5F-EE12-41C4-ADC9-05FBF54CB7CC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{84BB0C5F-EE12-41C4-ADC9-05FBF54CB7CC}.Debug|x64.ActiveCfg = Debug|Any CPU
Expand Down Expand Up @@ -121,7 +107,6 @@ Global
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{B86D70F6-12F9-42E7-8A04-2C21FC91DF9C} = {0EF20E50-D076-480D-BC88-951E5AC8643E}
{7C01A809-1EA9-43A4-BEDC-5488084A22B1} = {0EF20E50-D076-480D-BC88-951E5AC8643E}
{84BB0C5F-EE12-41C4-ADC9-05FBF54CB7CC} = {E53FFF53-7874-40D6-8070-EB4E6F5067B9}
{AFEB904E-2ACD-4144-BD4B-BEC5772CCFA7} = {0EF20E50-D076-480D-BC88-951E5AC8643E}
{5156E51B-B489-4E0A-865B-79BADB009BD1} = {0EF20E50-D076-480D-BC88-951E5AC8643E}
Expand Down
42 changes: 13 additions & 29 deletions src/Ionide.ProjInfo.ProjectSystem/WorkspacePeek.fs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,13 @@ module WorkspacePeek =
| FsProj
| Sln
| Slnf
| Slnx
| Fsx

[<return:Struct>]
let inline (|HasExt|_|) (ext: string) (file: FileInfo) =
if file.Extension = ext then ValueSome() else ValueNone

let private partitionByChoice3 =
let foldBy (a, b, c) t =
match t with
Expand Down Expand Up @@ -76,26 +81,11 @@ module WorkspacePeek =
topLevelFiles
|> Seq.choose (fun s ->
match s with
| x when
x
|> hasExt ".sln"
->
Some(UsefulFile.Sln, x)
| x when
x
|> hasExt ".slnf"
->
Some(UsefulFile.Slnf, x)
| x when
x
|> hasExt ".fsx"
->
Some(UsefulFile.Fsx, x)
| x when
x
|> hasExt ".fsproj"
->
Some(UsefulFile.FsProj, x)
| HasExt ".sln" -> Some(UsefulFile.Sln, s)
| HasExt ".slnf" -> Some(UsefulFile.Slnf, s)
| HasExt ".fsx" -> Some(UsefulFile.Fsx, s)
| HasExt ".fsproj" -> Some(UsefulFile.FsProj, s)
| HasExt ".slnx" -> Some(UsefulFile.Slnx, s)
| _ -> None
)
|> Seq.toArray
Expand Down Expand Up @@ -141,20 +131,14 @@ module WorkspacePeek =
let getInfo (t, (f: FileInfo)) =
match t with
| UsefulFile.Sln
| UsefulFile.Slnf ->
| UsefulFile.Slnf
| UsefulFile.Slnx ->
match InspectSln.tryParseSln f.FullName with
| Ok(p, d) -> Some(Choice1Of3(p, d))
| Ok(d) -> Some(Choice1Of3(f.FullName, d))
| Error e ->
let addInfo l =
match e with
| :? Ionide.ProjInfo.Sln.Exceptions.InvalidProjectFileException as ipfe -> Log.addContextDestructured "data" ipfe l

| _ -> l

logger.warn (
Log.setMessage "Failed to load file: {filePath} : {data}"
>> Log.addContext "filePath" f.FullName
>> addInfo
>> Log.addExn e
)

Expand Down
35 changes: 0 additions & 35 deletions src/Ionide.ProjInfo.Sln/ExceptionHandling.cs

This file was deleted.

Loading
Loading