Skip to content

Commit 39e7fd8

Browse files
authored
Add option to crack using msbuild project graph (#102)
1 parent 7d54224 commit 39e7fd8

File tree

9 files changed

+530
-250
lines changed

9 files changed

+530
-250
lines changed

build.fsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,18 @@ let DoNothing = ignore
9090

9191
Target.create "Clean" (fun _ -> Shell.cleanDirs [ buildDir; nugetDir ])
9292

93+
Target.create "ReplaceFsLibLogNamespaces"
94+
<| fun _ ->
95+
let replacements =
96+
[ "FsLibLog\\n", "Ionide.ProjInfo.Logging\n"
97+
"FsLibLog\\.", "Ionide.ProjInfo.Logging" ]
98+
99+
replacements
100+
|> List.iter
101+
(fun (``match``, replace) ->
102+
(!! "paket-files/TheAngryByrd/FsLibLog/**/FsLibLog*.fs")
103+
|> Shell.regexReplaceInFilesWithEncoding ``match`` replace System.Text.Encoding.UTF8)
104+
93105
Target.create "Build" (fun _ -> DotNet.build id "")
94106

95107
Target.create
@@ -160,6 +172,7 @@ Target.create "Default" DoNothing
160172
Target.create "Release" DoNothing
161173

162174
"Clean"
175+
==> "ReplaceFsLibLogNamespaces"
163176
==> "Build"
164177
==> "Test"
165178
==> "Default"

paket.dependencies

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ nuget Microsoft.Build.Locator
2020
nuget Newtonsoft.Json
2121
nuget Fsharp.Control.Reactive
2222

23+
github TheAngryByrd/FsLibLog src/FsLibLog/FsLibLog.fs
24+
2325
// [ FAKE GROUP ]
2426
group Build
2527
source https://api.nuget.org/v3/index.json

paket.lock

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,9 @@ NUGET
562562
System.Runtime.Handles (>= 4.3)
563563
System.Windows.Extensions (5.0)
564564
System.Drawing.Common (>= 5.0)
565-
565+
GITHUB
566+
remote: TheAngryByrd/FsLibLog
567+
src/FsLibLog/FsLibLog.fs (1b8121d4e8a1d1e9914abfcf9a5a1ebbc10fe3f3)
566568
GROUP Build
567569
STORAGE: NONE
568570
RESTRICTION: == netstandard2.0

src/Ionide.ProjInfo.ProjectSystem/ProjectSystem.fs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ type ProjectResponse =
3636
/// Public API for any operations related to workspace and projects.
3737
/// Internally keeps all the information related to project files in current workspace.
3838
/// It's responsible for refreshing and caching - should be used only as source of information and public API
39-
type ProjectController(toolsPath: ToolsPath) as x =
39+
type ProjectController(toolsPath: ToolsPath, workspaceLoaderFactory: ToolsPath -> IWorkspaceLoader) as x =
4040
let fileCheckOptions = ConcurrentDictionary<string, FSharpProjectOptions>()
4141
let projects = ConcurrentDictionary<string, Project>()
4242
let mutable isWorkspaceReady = false
@@ -165,7 +165,7 @@ type ProjectController(toolsPath: ToolsPath) as x =
165165
| delay when delay > TimeSpan.Zero -> do! Async.Sleep(Environment.workspaceLoadDelay().TotalMilliseconds |> int)
166166
| _ -> ()
167167

168-
let loader = WorkspaceLoader.Create(toolsPath)
168+
let loader = workspaceLoaderFactory toolsPath
169169

170170
let bindNewOnloaded (n: WorkspaceProjectState) : ProjectSystemState option =
171171
match n with
@@ -177,7 +177,8 @@ type ProjectController(toolsPath: ToolsPath) as x =
177177
| Ok optsDPW ->
178178
let view = ProjectViewer.render optsDPW
179179
Some(ProjectSystemState.Loaded(fcsOpts, optsDPW, view.Items, isFromCache))
180-
| Error _ -> None //TODO not ignore the error
180+
| Error e -> Some(ProjectSystemState.Failed(e.ProjFile, e))
181+
181182
| WorkspaceProjectState.Failed (path, e) ->
182183
let error = e
183184
Some(ProjectSystemState.Failed(path, error))

src/Ionide.ProjInfo.ProjectSystem/Workspace.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ let private bindResults isFromCache res =
3636

3737
Result.Ok(res, optsDPW, items, isFromCache))
3838

39-
let private getProjectOptions (loader: WorkspaceLoader) (onEvent: ProjectSystemState -> unit) (generateBinlog: bool) (projectFileNames: string list) =
39+
let private getProjectOptions (loader: IWorkspaceLoader) (onEvent: ProjectSystemState -> unit) (generateBinlog: bool) (projectFileNames: string list) =
4040
let existing, notExisting = projectFileNames |> List.partition (File.Exists)
4141

4242
for e in notExisting do
@@ -62,7 +62,7 @@ let private getProjectOptions (loader: WorkspaceLoader) (onEvent: ProjectSystemS
6262
use notif = loader.Notifications.Subscribe handler
6363
loader.LoadProjects(existing, [], generateBinlog) |> ignore // TODO: Maybe we should move away from event driven approach???
6464

65-
let internal loadInBackground onLoaded (loader: WorkspaceLoader) (projects: Project list) (generateBinlog: bool) =
65+
let internal loadInBackground onLoaded (loader: IWorkspaceLoader) (projects: Project list) (generateBinlog: bool) =
6666
let (resProjects, otherProjects) = projects |> List.partition (fun n -> n.Response.IsSome)
6767

6868
for project in resProjects do
Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
2-
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project Sdk="Microsoft.NET.Sdk">
33
<PropertyGroup>
44
<TargetFrameworks>net5.0; netcoreapp3.1</TargetFrameworks>
55
</PropertyGroup>
6-
76
<ItemGroup>
7+
<Compile Include="..\..\paket-files\TheAngryByrd\FsLibLog\src\FsLibLog\FsLibLog.fs">
8+
<Paket>True</Paket>
9+
<Link>paket-files/FsLibLog.fs</Link>
10+
</Compile>
811
<Compile Include="Types.fs" />
912
<Compile Include="Utils.fs" />
1013
<Compile Include="VisualTree.fs" />
1114
<Compile Include="InspectSln.fs" />
1215
<Compile Include="Library.fs" />
1316
</ItemGroup>
14-
1517
<ItemGroup>
1618
<ProjectReference Include="..\Ionide.ProjInfo.Sln\Ionide.ProjInfo.Sln.csproj" />
1719
</ItemGroup>
1820
<Import Project="..\..\.paket\Paket.Restore.targets" />
19-
</Project>
21+
</Project>

0 commit comments

Comments
 (0)