@@ -4,6 +4,7 @@ open System.Threading
44
55open NUnit.Framework
66open Ionide.LanguageServerProtocol .Types
7+ open Ionide.LanguageServerProtocol .Server
78
89open CSharpLanguageServer.Tests .Tooling
910
@@ -117,3 +118,83 @@ let testPullDiagnosticsWork () =
117118 Assert.AreEqual( 0 , report.Items.Length)
118119 | _ -> failwith " U2.C1 is expected"
119120 ()
121+
122+
123+ [<TestCase>]
124+ let testWorkspaceDiagnosticsWork () =
125+ use client = setupServerClient defaultClientProfile
126+ " TestData/testWorkspaceDiagnosticsWork"
127+ client.StartAndWaitForSolutionLoad()
128+
129+ let diagnosticParams : WorkspaceDiagnosticParams =
130+ { WorkDoneToken = None
131+ PartialResultToken = None
132+ Identifier = None
133+ PreviousResultIds = Array.empty }
134+
135+ let report0 : WorkspaceDiagnosticReport option =
136+ client.Request( " workspace/diagnostic" , diagnosticParams)
137+
138+ match report0 with
139+ | Some report0 ->
140+ Assert.AreEqual( 3 , report0.Items.Length)
141+
142+ match report0.Items[ 0 ] with
143+ | U2.C1 fullReport ->
144+ Assert.AreEqual( " full" , fullReport.Kind)
145+ Assert.AreEqual( None, fullReport.ResultId)
146+ Assert.AreEqual( 3 , fullReport.Items.Length)
147+
148+ let diagnostic0 = fullReport.Items[ 0 ]
149+ Assert.AreEqual( true , diagnostic0.Code.IsSome)
150+ Assert.AreEqual( " Identifier expected" , diagnostic0.Message)
151+
152+ | _ -> failwith " 'U2.C1' was expected"
153+
154+ | _ -> failwith " 'Some' was expected"
155+
156+
157+ [<TestCase>]
158+ let testWorkspaceDiagnosticsWorkWithStreaming () =
159+ use client = setupServerClient defaultClientProfile
160+ " TestData/testWorkspaceDiagnosticsWork"
161+ client.StartAndWaitForSolutionLoad()
162+
163+ let partialResultToken : ProgressToken =
164+ System.Guid.NewGuid() |> string |> U2.C2
165+
166+ let diagnosticParams : WorkspaceDiagnosticParams =
167+ { WorkDoneToken = None
168+ PartialResultToken = Some partialResultToken
169+ Identifier = None
170+ PreviousResultIds = Array.empty }
171+
172+ let report0 : WorkspaceDiagnosticReport option =
173+ client.Request( " workspace/diagnostic" , diagnosticParams)
174+
175+ // report should have 0 results, all of them streamed to lsp client via $/progress instead
176+ match report0 with
177+ | Some report0 ->
178+ Assert.AreEqual( 0 , report0.Items.Length)
179+ | _ -> failwith " 'Some' was expected"
180+
181+ let progress = client.GetProgressParams partialResultToken
182+ Assert.AreEqual( 3 , progress.Length)
183+
184+ let report0 = progress[ 0 ]. Value |> deserialize< WorkspaceDiagnosticReport>
185+ Assert.AreEqual( 1 , report0.Items.Length)
186+
187+ match report0.Items[ 0 ] with
188+ | U2.C1 fullReport ->
189+ Assert.AreEqual( " full" , fullReport.Kind)
190+ Assert.AreEqual( None, fullReport.ResultId)
191+ Assert.AreEqual( 3 , fullReport.Items.Length)
192+
193+ let diagnostic0 = fullReport.Items[ 0 ]
194+ Assert.AreEqual( true , diagnostic0.Code.IsSome)
195+ Assert.AreEqual( " Identifier expected" , diagnostic0.Message)
196+
197+ | _ -> failwith " 'U2.C1' was expected"
198+
199+ let report1 = progress[ 1 ]. Value |> deserialize< WorkspaceDiagnosticReportPartialResult>
200+ Assert.AreEqual( 1 , report1.Items.Length)
0 commit comments