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

Don't hook up SerilogTraceListener in FantomasDaemon. #2777

Merged
merged 1 commit into from
Feb 22, 2023
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
1 change: 1 addition & 0 deletions src/Fantomas.Tests/Fantomas.Tests.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<Compile Include="Integration\WriteTests.fs" />
<Compile Include="Integration\DaemonTests.fs" />
<Compile Include="Integration\ForceTests.fs" />
<Compile Include="ToolLocatorTests.fs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="FSharp.Core" Version="$(FSharpCoreVersion)" />
Expand Down
25 changes: 25 additions & 0 deletions src/Fantomas.Tests/ToolLocatorTests.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module Fantomas.CoreGlobalTool.Tests.ToolLocatorTests

open Fantomas.Client
open Fantomas.Client.LSPFantomasServiceTypes
open Fantomas.Client.Contracts
open NUnit.Framework

[<Explicit "This is meant to troubleshoot local problems">]
[<Test>]
let ``locate fantomas tool`` () =
let pwd = @"C:\Users\nojaf\Projects"
let result = FantomasToolLocator.findFantomasTool (Folder pwd)

match result with
| Error error -> Assert.Fail $"Could not locate tool: %A{error}"
| Ok(FantomasToolFound(FantomasVersion(version), startInfo)) ->
let result = FantomasToolLocator.createFor startInfo

match result with
| Error error -> Assert.Fail $"Could not start tool: %A{error}"
| Ok runningFantomasTool ->
let version2 =
runningFantomasTool.RpcClient.InvokeAsync<string>(Methods.Version).Result

Assert.AreEqual(version, $"v{version2}")
9 changes: 5 additions & 4 deletions src/Fantomas/Daemon.fs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@ open Fantomas.EditorConfig

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

do
// hook up request/response logging for debugging
rpc.TraceSource <- TraceSource(typeof<FantomasDaemon>.Name, SourceLevels.Verbose)

rpc.TraceSource.Listeners.Add(new SerilogTraceListener.SerilogTraceListener(typeof<FantomasDaemon>.Name))
|> ignore<int>
rpc.TraceSource.Listeners.Add traceListener |> ignore<int>

let disconnectEvent = new ManualResetEvent(false)

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

interface IDisposable with
member this.Dispose() = disconnectEvent.Dispose()
member this.Dispose() =
traceListener.Dispose()
disconnectEvent.Dispose()

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