@@ -176,7 +176,7 @@ void ValidateResolveParams(DelegatedCompletionItemResolveParams @params)
176
176
public async Task ResolveAsync_CSharp_Resolves ( )
177
177
{
178
178
// Arrange & Act
179
- var resolvedItem = await ResolveCompletionItemAsync ( "@$$" , itemToResolve : "typeof" , DisposalToken ) ;
179
+ var resolvedItem = await ResolveCompletionItemAsync ( "@$$" , itemToResolve : "typeof" , supportsVisualStudioExtensions : true , DisposalToken ) ;
180
180
181
181
// Assert
182
182
Assert . NotNull ( resolvedItem . Description ) ;
@@ -197,23 +197,22 @@ Task FooAsync()
197
197
""" ;
198
198
TestFileMarkupParser . GetPosition ( input , out var documentContent , out _ ) ;
199
199
var originalSourceText = SourceText . From ( documentContent ) ;
200
- var expectedSourceText = SourceText . From (
201
- """
200
+ var expected = """
202
201
@{
203
202
async Task FooAsync()
204
203
{
205
204
await
206
205
}
207
206
}
208
- """ ) ;
207
+ """ ;
209
208
210
209
// Act
211
- var resolvedItem = await ResolveCompletionItemAsync ( input , itemToResolve : "await" , DisposalToken ) ;
210
+ var resolvedItem = await ResolveCompletionItemAsync ( input , itemToResolve : "await" , supportsVisualStudioExtensions : true , DisposalToken ) ;
212
211
213
212
// Assert
214
213
var textChange = originalSourceText . GetTextChange ( resolvedItem . TextEdit . Value . First ) ;
215
214
var actualSourceText = originalSourceText . WithChanges ( textChange ) ;
216
- Assert . True ( expectedSourceText . ContentEquals ( actualSourceText ) ) ;
215
+ AssertEx . EqualOrDiff ( expected , actualSourceText . ToString ( ) ) ;
217
216
}
218
217
219
218
[ Fact ]
@@ -232,16 +231,15 @@ Task FooAsync()
232
231
233
232
// Admittedly the result here is not perfect, but only because our tests don't implement the full LSP editor logic. The key thing
234
233
// is the addition of the using directive.
235
- var expectedSourceText = SourceText . From (
236
- """
234
+ var expected = """
237
235
@using System.Text
238
236
@{
239
237
Task FooAsync()
240
238
{
241
239
String
242
240
}
243
241
}
244
- """ ) ;
242
+ """ ;
245
243
246
244
var codeDocument = CreateCodeDocument ( input . Text , filePath : "C:/path/to/file.razor" ) ;
247
245
// Roslyn won't send unimported types if SupportsVisualStudioExtensions is true
@@ -275,7 +273,37 @@ Task FooAsync()
275
273
var originalSourceText = SourceText . From ( input . Text ) ;
276
274
var textChange = originalSourceText . GetTextChange ( resolvedItem . AdditionalTextEdits . Single ( ) ) ;
277
275
var actualSourceText = originalSourceText . WithChanges ( textChange ) ;
278
- AssertEx . EqualOrDiff ( expectedSourceText . ToString ( ) , actualSourceText . ToString ( ) ) ;
276
+ AssertEx . EqualOrDiff ( expected , actualSourceText . ToString ( ) ) ;
277
+ }
278
+
279
+ [ Fact ]
280
+ public async Task ResolveAsync_CSharp_OverrideCompletion ( )
281
+ {
282
+ // Arrange
283
+ var input =
284
+ """
285
+ @code {
286
+ override $$
287
+ }
288
+ """ ;
289
+ TestFileMarkupParser . GetPosition ( input , out var documentContent , out _ ) ;
290
+ var originalSourceText = SourceText . From ( documentContent ) ;
291
+ var expected = """
292
+ @using System.Threading.Tasks
293
+ @code {
294
+ protected override Task OnInitializedAsync()
295
+ {
296
+ return base.OnInitializedAsync();
297
+ }
298
+ }
299
+ """ ;
300
+
301
+ // Act
302
+ var resolvedItem = await ResolveCompletionItemAsync ( input , itemToResolve : "OnInitializedAsync()" , supportsVisualStudioExtensions : false , DisposalToken ) ;
303
+
304
+ var textChange = originalSourceText . GetTextChange ( ( TextEdit ) resolvedItem . Command . Arguments [ 1 ] ) ;
305
+ var actualSourceText = originalSourceText . WithChanges ( textChange ) ;
306
+ AssertEx . EqualOrDiff ( expected , actualSourceText . ToString ( ) ) ;
279
307
}
280
308
281
309
[ Fact ]
@@ -306,11 +334,11 @@ void ValidateResolveParams(DelegatedCompletionItemResolveParams @params)
306
334
}
307
335
}
308
336
309
- private async Task < VSInternalCompletionItem > ResolveCompletionItemAsync ( string content , string itemToResolve , CancellationToken cancellationToken )
337
+ private async Task < VSInternalCompletionItem > ResolveCompletionItemAsync ( string content , string itemToResolve , bool supportsVisualStudioExtensions , CancellationToken cancellationToken )
310
338
{
311
339
TestFileMarkupParser . GetPosition ( content , out var documentContent , out var cursorPosition ) ;
312
340
var codeDocument = CreateCodeDocument ( documentContent , filePath : "C:/path/to/file.razor" ) ;
313
- await using var csharpServer = await CreateCSharpServerAsync ( codeDocument , supportsVisualStudioExtensions : true ) ;
341
+ await using var csharpServer = await CreateCSharpServerAsync ( codeDocument , supportsVisualStudioExtensions ) ;
314
342
315
343
var clientConnection = CreateClientConnectionForResolve ( csharpServer ) ;
316
344
var documentContextFactory = new TestDocumentContextFactory ( "C:/path/to/file.razor" , codeDocument ) ;
0 commit comments