Skip to content

Commit 5c68800

Browse files
authored
enable deserialization of cached project file data and fix legacy project tests (#139)
1 parent ea2184b commit 5c68800

File tree

7 files changed

+183
-116
lines changed

7 files changed

+183
-116
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
run: dotnet tool restore
2323
- name: Install latest F# from mono (.net 4.x)
2424
if: runner.os == 'Linux'
25-
run: ./install_mono_from_microsoft_deb_packages.sh
25+
run: ./install_mono_from_microsoft_deb_packages.sh && which msbuild
2626
- name: Run build
2727
run: dotnet fake build -t Pack
2828
- name: Upload NuGet packages

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ x86/
2020
bld/
2121
[Bb]in/
2222
[Oo]bj/
23+
*.binlog
2324

2425
# Visual Studio 2015 cache/options directory
2526
.vs/

src/Ionide.ProjInfo.ProjectSystem/Project.fs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ open FSharp.Compiler.CodeAnalysis
66
open Newtonsoft.Json
77
open Ionide.ProjInfo
88

9-
type internal ProjectCrackerCache =
9+
// need to expose this so that json.net can serialize it
10+
type ProjectCrackerCache =
1011
{ Options: FSharpProjectOptions
1112
OutFile: string option
1213
References: string list

src/Ionide.ProjInfo.ProjectSystem/Workspace.fs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,11 @@ let internal loadInBackground onLoaded (loader: IWorkspaceLoader) (projects: Pro
5353

5454
for project in resProjects do
5555
match project.Response with
56-
| Some res -> onLoaded (ProjectSystemState.Loaded(res.Options, res.ExtraInfo, res.Items, false))
56+
| Some res ->
57+
// if we have project data already then that means it was cached.
58+
// fire a loading/loaded event pair so that outside observers get the correct loading experience
59+
onLoaded (ProjectSystemState.Loading project.FileName )
60+
onLoaded (ProjectSystemState.Loaded(res.Options, res.ExtraInfo, res.Items, true))
5761
| None -> () //Shouldn't happen
5862

5963
otherProjects |> List.map (fun n -> n.FileName) |> getProjectOptions loader onLoaded binaryLogs

src/Ionide.ProjInfo/Library.fs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,11 @@ module LegacyFrameworkDiscovery =
133133
// example: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe
134134
let msbuildExe =
135135
SdkDiscovery.execDotnet vsWhereDir vsWhereExe [ "-find"; "MSBuild\**\Bin\MSBuild.exe" ]
136-
|> Seq.last
137-
|> FileInfo
138-
if msbuildExe.Exists then
139-
msbuildExe |> Some
140-
else
141-
None
136+
|> Seq.tryHead
137+
|> Option.map FileInfo
138+
match msbuildExe with
139+
| Some exe when exe.Exists -> Some exe
140+
| _ -> None
142141

143142
let internal msbuildLibPath(msbuildDir: DirectoryInfo) =
144143
if isLinux then
@@ -219,7 +218,7 @@ module Init =
219218
let internal setupForLegacyFramework (msbuildPathDir: DirectoryInfo) =
220219
let msbuildLibPath = LegacyFrameworkDiscovery.msbuildLibPath msbuildPathDir
221220

222-
// gotta set some env variables so msbuild interop works
221+
// gotta set some env variables so msbuild interop works
223222
if LegacyFrameworkDiscovery.isUnix then
224223
Environment.SetEnvironmentVariable("MSBuildBinPath", "/usr/lib/mono/msbuild/Current/bin")
225224
Environment.SetEnvironmentVariable("FrameworkPathOverride", "/usr/lib/mono/4.5")
@@ -369,7 +368,7 @@ module ProjectLoader =
369368
"_ComputeNonExistentFileProperty"
370369
"CoreCompile" |]
371370
else
372-
[|
371+
[|
373372
"ResolveAssemblyReferencesDesignTime"
374373
"ResolveProjectReferencesDesignTime"
375374
"ResolvePackageDependenciesDesignTime"

test/Ionide.ProjInfo.Tests/Ionide.ProjInfo.Tests.fsproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717
<ProjectReference Include="..\..\src\Ionide.ProjInfo.ProjectSystem\Ionide.ProjInfo.ProjectSystem.fsproj" />
1818
</ItemGroup>
1919
<Import Project="..\..\.paket\Paket.Restore.targets" />
20-
</Project>
20+
</Project>

0 commit comments

Comments
 (0)