@@ -25,10 +25,25 @@ This is a Razor document.
25
25
<div st$$></div>
26
26
27
27
The end.
28
- """ ) ;
28
+ """ ,
29
+ supportsVisualStudioExtensions : true ) ;
29
30
}
30
31
31
- private async Task VerifyCompletionItemResolveAsync ( TestCode input )
32
+ [ Fact ]
33
+ public async Task HtmlResolve_VSCode ( )
34
+ {
35
+ await VerifyCompletionItemResolveAsync (
36
+ input : """
37
+ This is a Razor document.
38
+
39
+ <div st$$></div>
40
+
41
+ The end.
42
+ """ ,
43
+ supportsVisualStudioExtensions : false ) ;
44
+ }
45
+
46
+ private async Task VerifyCompletionItemResolveAsync ( TestCode input , bool supportsVisualStudioExtensions )
32
47
{
33
48
var document = CreateProjectAndRazorDocument ( input . Text ) ;
34
49
@@ -54,22 +69,50 @@ private async Task VerifyCompletionItemResolveAsync(TestCode input)
54
69
OriginalCompletionListData : null ,
55
70
ProjectedKind : RazorLanguageKind . Html ) ;
56
71
57
- var request = new VSInternalCompletionItem ( )
72
+ var list = new RazorVSInternalCompletionList
58
73
{
59
- Data = JsonSerializer . SerializeToElement ( context ) ,
60
- Label = "TestItem"
74
+ Data = supportsVisualStudioExtensions ? JsonSerializer . SerializeToElement ( context ) : null ,
75
+ ItemDefaults = new ( )
76
+ {
77
+ Data = supportsVisualStudioExtensions ? null : JsonSerializer . SerializeToElement ( context ) ,
78
+ } ,
79
+ Items = [ new VSInternalCompletionItem ( )
80
+ {
81
+ Label = "TestItem"
82
+ } ]
61
83
} ;
62
- var list = new RazorVSInternalCompletionList
84
+
85
+ var clientCapabilities = new VSInternalClientCapabilities
63
86
{
64
- Items = [ request ]
87
+ SupportsVisualStudioExtensions = supportsVisualStudioExtensions ,
88
+ TextDocument = new TextDocumentClientCapabilities ( )
89
+ {
90
+ Completion = new VSInternalCompletionSetting ( )
91
+ {
92
+ CompletionList = new ( )
93
+ {
94
+ Data = supportsVisualStudioExtensions
95
+ } ,
96
+ CompletionListSetting = new ( )
97
+ {
98
+ ItemDefaults = supportsVisualStudioExtensions ? null : [ "data" ]
99
+ }
100
+ }
101
+ }
65
102
} ;
66
103
67
104
var resultId = completionListCache . Add ( list , context ) ;
68
- list . SetResultId ( resultId , clientCapabilities : new ( ) ) ;
69
- RazorCompletionResolveData . Wrap ( list , textDocumentIdentifier . TextDocumentIdentifier , clientCapabilities : new ( ) ) ;
105
+ list . SetResultId ( resultId , clientCapabilities ) ;
106
+ RazorCompletionResolveData . Wrap ( list , textDocumentIdentifier . TextDocumentIdentifier , clientCapabilities ) ;
107
+
108
+ var request = list . Items [ 0 ] ;
109
+ // Simulate the LSP client, which would receive all of the items and the list data, and send the item back to us with
110
+ // data filled in.
111
+ request . Data = JsonSerializer . SerializeToElement ( list . Data ?? list . ItemDefaults . Data , JsonHelpers . JsonSerializerOptions ) ;
70
112
71
- // We expect data to be a JsonElement, so for tests we have to _not_ strongly type
72
- request . Data = JsonSerializer . SerializeToElement ( request . Data , JsonHelpers . JsonSerializerOptions ) ;
113
+ var tdi = endpoint . GetTestAccessor ( ) . GetRazorTextDocumentIdentifier ( request ) ;
114
+ Assert . NotNull ( tdi ) ;
115
+ Assert . Equal ( document . CreateUri ( ) , tdi . Value . Uri ) ;
73
116
74
117
var result = await endpoint . GetTestAccessor ( ) . HandleRequestAsync ( request , document , DisposalToken ) ;
75
118
0 commit comments