Skip to content

Commit

Permalink
Send solution Loading/Finished Loading messages to LSP client
Browse files Browse the repository at this point in the history
  • Loading branch information
razzmatazz committed Sep 27, 2024
1 parent 191c7ee commit a49cb2c
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions src/CSharpLanguageServer/RoslynHelpers.fs
Original file line number Diff line number Diff line change
Expand Up @@ -378,27 +378,41 @@ let tryLoadSolutionOnPath
solutionPath =
let progress = ProgressReporter(lspClient)

let showMessage m =
lspClient.WindowShowMessage({
Type = MessageType.Info
Message = sprintf "csharp-ls: %s" m
})

async {
try
do! progress.Begin(sprintf "Loading solution \"%s\"..." solutionPath)
let beginMessage = sprintf "Loading solution \"%s\"..." solutionPath
do! progress.Begin(beginMessage)
do! showMessage beginMessage

let msbuildWorkspace = MSBuildWorkspace.Create(CSharpLspHostServices())
msbuildWorkspace.LoadMetadataForReferencedProjects <- true

let! _ = msbuildWorkspace.OpenSolutionAsync(solutionPath) |> Async.AwaitTask
let! solution = msbuildWorkspace.OpenSolutionAsync(solutionPath) |> Async.AwaitTask

for diag in msbuildWorkspace.Diagnostics do
logger.trace (
logger.info (
Log.setMessage "msbuildWorkspace.Diagnostics: {message}"
>> Log.addContext "message" (diag.ToString())
)

do! progress.End (sprintf "finished loading solution \"%s\"" solutionPath)
do! showMessage (sprintf "msbuildWorkspace.Diagnostics: %s" (diag.ToString()))

let endMessage = sprintf "Finished loading solution \"%s\"" solutionPath
do! progress.End endMessage
do! showMessage endMessage

return Some msbuildWorkspace.CurrentSolution
return Some solution
with
| ex ->
do! progress.End ("solution loading has failed with error: " + ex.ToString())
let errorMessage = sprintf "Solution \"%s\" could not be loaded: %s" solutionPath (ex.ToString())
do! progress.End errorMessage
do! showMessage errorMessage
return None
}

Expand Down

0 comments on commit a49cb2c

Please sign in to comment.