Skip to content

Commit f4e7b98

Browse files
committed
Don't hook up SerilogTraceListener in FantomasDaemon. (#2777)
1 parent ae0d6c6 commit f4e7b98

File tree

3 files changed

+31
-4
lines changed

3 files changed

+31
-4
lines changed

src/Fantomas.Tests/Fantomas.Tests.fsproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
<Compile Include="Integration\WriteTests.fs" />
2828
<Compile Include="Integration\DaemonTests.fs" />
2929
<Compile Include="Integration\ForceTests.fs" />
30+
<Compile Include="ToolLocatorTests.fs" />
3031
</ItemGroup>
3132
<ItemGroup>
3233
<PackageReference Include="FSharp.Core" Version="$(FSharpCoreVersion)" />
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
module Fantomas.CoreGlobalTool.Tests.ToolLocatorTests
2+
3+
open Fantomas.Client
4+
open Fantomas.Client.LSPFantomasServiceTypes
5+
open Fantomas.Client.Contracts
6+
open NUnit.Framework
7+
8+
[<Explicit "This is meant to troubleshoot local problems">]
9+
[<Test>]
10+
let ``locate fantomas tool`` () =
11+
let pwd = @"C:\Users\nojaf\Projects"
12+
let result = FantomasToolLocator.findFantomasTool (Folder pwd)
13+
14+
match result with
15+
| Error error -> Assert.Fail $"Could not locate tool: %A{error}"
16+
| Ok(FantomasToolFound(FantomasVersion(version), startInfo)) ->
17+
let result = FantomasToolLocator.createFor startInfo
18+
19+
match result with
20+
| Error error -> Assert.Fail $"Could not start tool: %A{error}"
21+
| Ok runningFantomasTool ->
22+
let version2 =
23+
runningFantomasTool.RpcClient.InvokeAsync<string>(Methods.Version).Result
24+
25+
Assert.AreEqual(version, $"v{version2}")

src/Fantomas/Daemon.fs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,12 @@ open Fantomas.EditorConfig
1616

1717
type FantomasDaemon(sender: Stream, reader: Stream) as this =
1818
let rpc: JsonRpc = JsonRpc.Attach(sender, reader, this)
19+
let traceListener = new DefaultTraceListener()
1920

2021
do
2122
// hook up request/response logging for debugging
2223
rpc.TraceSource <- TraceSource(typeof<FantomasDaemon>.Name, SourceLevels.Verbose)
23-
24-
rpc.TraceSource.Listeners.Add(new SerilogTraceListener.SerilogTraceListener(typeof<FantomasDaemon>.Name))
25-
|> ignore<int>
24+
rpc.TraceSource.Listeners.Add traceListener |> ignore<int>
2625

2726
let disconnectEvent = new ManualResetEvent(false)
2827

@@ -33,7 +32,9 @@ type FantomasDaemon(sender: Stream, reader: Stream) as this =
3332
do rpc.Disconnected.Add(fun _ -> exit ())
3433

3534
interface IDisposable with
36-
member this.Dispose() = disconnectEvent.Dispose()
35+
member this.Dispose() =
36+
traceListener.Dispose()
37+
disconnectEvent.Dispose()
3738

3839
/// returns a hot task that resolves when the stream has terminated
3940
member this.WaitForClose = rpc.Completion

0 commit comments

Comments
 (0)