@@ -124,5 +124,168 @@ public partial class Registration
124
124
125
125
await Verify ( GenerationHelpers . GenerateAll ( source ) ) ;
126
126
}
127
+
128
+ [ Fact ]
129
+ public async Task Supports_Nullable_Params_With_Typed_Data ( )
130
+ {
131
+ var source = @"
132
+ using System.Diagnostics;
133
+ using System.Linq;
134
+ using MediatR;
135
+ using Newtonsoft.Json.Linq;
136
+ using OmniSharp.Extensions.JsonRpc;
137
+ using OmniSharp.Extensions.JsonRpc.Generation;
138
+ using OmniSharp.Extensions.LanguageServer.Protocol.Client;
139
+ using OmniSharp.Extensions.LanguageServer.Protocol.Client.Capabilities;
140
+ using OmniSharp.Extensions.LanguageServer.Protocol.Document;
141
+ using OmniSharp.Extensions.LanguageServer.Protocol.Generation;
142
+ using OmniSharp.Extensions.LanguageServer.Protocol.Serialization;
143
+ using OmniSharp.Extensions.LanguageServer.Protocol.Server;
144
+ using OmniSharp.Extensions.LanguageServer.Protocol.Server.Capabilities;
145
+ using OmniSharp.Extensions.LanguageServer.Protocol;
146
+ using OmniSharp.Extensions.LanguageServer.Protocol.Models;
147
+
148
+ // ReSharper disable once CheckNamespace
149
+ namespace OmniSharp.Extensions.LanguageServer.Protocol.Test
150
+ {
151
+ namespace Models
152
+ {
153
+ [Parallel]
154
+ [Method(TextDocumentNames.CodeLens, Direction.ClientToServer)]
155
+ [GenerateHandler(""OmniSharp.Extensions.LanguageServer.Protocol.Document.Test"")]
156
+ [GenerateHandlerMethods]
157
+ [GenerateRequestMethods(typeof(ITextDocumentLanguageClient), typeof(ILanguageClient))]
158
+ [RegistrationOptions(typeof(SubLensRegistrationOptions))]
159
+ [Capability(typeof(SubLensCapability))]
160
+ [Resolver(typeof(SubLens))]
161
+ public partial record SubLensParams : ITextDocumentIdentifierParams, IWorkDoneProgressParams, IPartialItemsRequest<SubLensContainer?, SubLens>
162
+ {
163
+ /// <summary>
164
+ /// The document to request code lens for.
165
+ /// </summary>
166
+ public TextDocumentIdentifier TextDocument { get; init; } = null!;
167
+ }
168
+
169
+ public partial class SubLensContainer {}
170
+
171
+ /// <summary>
172
+ /// A code lens represents a command that should be shown along with
173
+ /// source text, like the number of references, a way to run tests, etc.
174
+ ///
175
+ /// A code lens is _unresolved_ when no command is associated to it. For performance
176
+ /// reasons the creation of a code lens and resolving should be done in two stages.
177
+ /// </summary>
178
+ [DebuggerDisplay(""{"" + nameof(DebuggerDisplay) + "",nq}"")]
179
+ [Parallel]
180
+ [Method(TextDocumentNames.CodeLensResolve, Direction.ClientToServer)]
181
+ [GenerateHandler(""OmniSharp.Extensions.LanguageServer.Protocol.Document.Test"", Name = ""SubLensResolve"")]
182
+ [GenerateHandlerMethods]
183
+ [GenerateRequestMethods(typeof(ITextDocumentLanguageClient), typeof(ILanguageClient))]
184
+ [GenerateTypedData]
185
+ [GenerateContainer]
186
+ [Capability(typeof(SubLensCapability))]
187
+ public partial record SubLens : IRequest<SubLens>, ICanBeResolved, IDoesNotParticipateInRegistration
188
+ {
189
+ /// <summary>
190
+ /// The range in which this code lens is valid. Should only span a single line.
191
+ /// </summary>
192
+ public Range Range { get; init; } = null!;
193
+
194
+ /// <summary>
195
+ /// The command this code lens represents.
196
+ /// </summary>
197
+ [Optional]
198
+ public Command? Command { get; init; }
199
+
200
+ /// <summary>
201
+ /// A data entry field that is preserved on a code lens item between
202
+ /// a code lens and a code lens resolve request.
203
+ /// </summary>
204
+ [Optional]
205
+ public JToken? Data { get; init; }
206
+
207
+ private string DebuggerDisplay => $""{Range}{( Command != null ? $"" {Command}"" : """" )}"";
208
+
209
+ /// <inheritdoc />
210
+ public override string ToString()
211
+ {
212
+ return DebuggerDisplay;
213
+ }
214
+ }
215
+
216
+ [GenerateRegistrationOptions(nameof(ServerCapabilities.SubLensProvider))]
217
+ [RegistrationOptionsConverter(typeof(SubLensRegistrationOptionsConverter))]
218
+ [RegistrationName(TextDocumentNames.CodeLens)]
219
+ public partial class SubLensRegistrationOptions : IWorkDoneProgressOptions, ITextDocumentRegistrationOptions
220
+ {
221
+ /// <summary>
222
+ /// Code lens has a resolve provider as well.
223
+ /// </summary>
224
+ [Optional]
225
+ public bool ResolveProvider { get; set; }
226
+
227
+ private class SubLensRegistrationOptionsConverter : RegistrationOptionsConverterBase<SubLensRegistrationOptions, StaticOptions>
228
+ {
229
+ private readonly IHandlersManager _handlersManager;
230
+
231
+ public SubLensRegistrationOptionsConverter(IHandlersManager handlersManager)
232
+ {
233
+ _handlersManager = handlersManager;
234
+ }
235
+
236
+ public override StaticOptions Convert(SubLensRegistrationOptions source)
237
+ {
238
+ return new()
239
+ {
240
+ ResolveProvider = source.ResolveProvider || _handlersManager.Descriptors.Any(z => z.HandlerType == typeof(ISubLensResolveHandler)),
241
+ WorkDoneProgress = source.WorkDoneProgress
242
+ };
243
+ }
244
+ }
245
+ }
246
+
247
+ [Parallel]
248
+ [Method(WorkspaceNames.CodeLensRefresh, Direction.ServerToClient)]
249
+ [GenerateHandler(""OmniSharp.Extensions.LanguageServer.Protocol.Workspace.Test"")]
250
+ [GenerateHandlerMethods]
251
+ [GenerateRequestMethods(typeof(IWorkspaceLanguageServer), typeof(ILanguageServer))]
252
+ [Capability(typeof(SubLensWorkspaceClientCapabilities))]
253
+ public partial record SubLensRefreshParams : IRequest;
254
+ }
255
+
256
+ namespace Client.Capabilities
257
+ {
258
+ [CapabilityKey(nameof(ClientCapabilities.TextDocument), nameof(TextDocumentClientCapabilities.CodeLens))]
259
+ public partial class SubLensCapability : DynamicCapability
260
+ {
261
+ }
262
+
263
+ /// <summary>
264
+ /// Capabilities specific to the code lens requests scoped to the
265
+ /// workspace.
266
+ ///
267
+ /// @since 3.16.0.
268
+ /// </summary>
269
+ [CapabilityKey(nameof(ClientCapabilities.Workspace), nameof(WorkspaceClientCapabilities.CodeLens))]
270
+ public class SubLensWorkspaceClientCapabilities : ICapability
271
+ {
272
+ /// <summary>
273
+ /// Whether the client implementation supports a refresh request send from the server
274
+ /// to the client. This is useful if a server detects a change which requires a
275
+ /// re-calculation of all code lenses.
276
+ /// </summary>
277
+ [Optional]
278
+ public bool RefreshSupport { get; set; }
279
+ }
280
+ }
281
+
282
+ namespace Document
283
+ {
284
+ }
285
+ }
286
+ " ;
287
+
288
+ await Verify ( GenerationHelpers . GenerateAll ( source ) ) ;
289
+ }
127
290
}
128
291
}
0 commit comments