5
5
#nullable disable
6
6
7
7
using System . Collections . Generic ;
8
+ using System . Diagnostics . CodeAnalysis ;
8
9
using System . Linq ;
9
10
using System . Threading . Tasks ;
10
11
using Microsoft . CodeAnalysis . Completion ;
@@ -29,7 +30,8 @@ public abstract class AbstractCSharpCompletionProviderTests<TWorkspaceFixture> :
29
30
{
30
31
protected const string NonBreakingSpaceString = "\x00A0 " ;
31
32
32
- protected static string GetMarkup ( string source , LanguageVersion languageVersion )
33
+ protected static string GetMarkup (
34
+ [ StringSyntax ( PredefinedEmbeddedLanguageNames . CSharpTest ) ] string source , LanguageVersion languageVersion )
33
35
=> $@ "<Workspace>
34
36
<Project Language=""C#"" AssemblyName=""Assembly1"" CommonReferences=""true"" LanguageVersion=""{ languageVersion . ToDisplayString ( ) } "">
35
37
<Document FilePath=""Test2.cs"">
@@ -40,17 +42,17 @@ protected static string GetMarkup(string source, LanguageVersion languageVersion
40
42
</Project>
41
43
</Workspace>" ;
42
44
43
- protected override EditorTestWorkspace CreateWorkspace ( string fileContents )
45
+ protected override EditorTestWorkspace CreateWorkspace ( [ StringSyntax ( PredefinedEmbeddedLanguageNames . CSharpTest ) ] string fileContents )
44
46
=> EditorTestWorkspace . CreateCSharp ( fileContents , composition : GetComposition ( ) ) ;
45
47
46
48
internal override CompletionService GetCompletionService ( Project project )
47
49
=> Assert . IsType < CSharpCompletionService > ( base . GetCompletionService ( project ) ) ;
48
50
49
51
private protected override Task BaseVerifyWorkerAsync (
50
- string code , int position ,
52
+ [ StringSyntax ( PredefinedEmbeddedLanguageNames . CSharpTest ) ] string code , int position ,
51
53
string expectedItemOrNull , string expectedDescriptionOrNull ,
52
54
SourceCodeKind sourceCodeKind , bool usePreviousCharAsTrigger , char ? deletedCharTrigger , bool checkForAbsence ,
53
- int ? glyph , int ? matchPriority , bool ? hasSuggestionItem , string displayTextSuffix ,
55
+ Glyph ? glyph , int ? matchPriority , bool ? hasSuggestionItem , string displayTextSuffix ,
54
56
string displayTextPrefix , string inlineDescription = null , bool ? isComplexTextEdit = null ,
55
57
List < CompletionFilter > matchingFilters = null , CompletionItemFlags ? flags = null ,
56
58
CompletionOptions options = null , bool skipSpeculation = false )
@@ -63,7 +65,7 @@ private protected override Task BaseVerifyWorkerAsync(
63
65
}
64
66
65
67
private protected override Task BaseVerifyWorkerAsync (
66
- string code , int position , bool usePreviousCharAsTrigger , char ? deletedCharTrigger , bool ? hasSuggestionItem ,
68
+ [ StringSyntax ( PredefinedEmbeddedLanguageNames . CSharpTest ) ] string code , int position , bool usePreviousCharAsTrigger , char ? deletedCharTrigger , bool ? hasSuggestionItem ,
67
69
SourceCodeKind sourceCodeKind , ItemExpectation [ ] expectedResults ,
68
70
List < CompletionFilter > matchingFilters , CompletionItemFlags ? flags , CompletionOptions options , bool skipSpeculation = false )
69
71
{
@@ -73,10 +75,10 @@ private protected override Task BaseVerifyWorkerAsync(
73
75
}
74
76
75
77
private protected override async Task VerifyWorkerAsync (
76
- string code , int position ,
78
+ [ StringSyntax ( PredefinedEmbeddedLanguageNames . CSharpTest ) ] string code , int position ,
77
79
string expectedItemOrNull , string expectedDescriptionOrNull ,
78
80
SourceCodeKind sourceCodeKind , bool usePreviousCharAsTrigger , char ? deletedCharTrigger ,
79
- bool checkForAbsence , int ? glyph , int ? matchPriority ,
81
+ bool checkForAbsence , Glyph ? glyph , int ? matchPriority ,
80
82
bool ? hasSuggestionItem , string displayTextSuffix , string displayTextPrefix , string inlineDescription = null ,
81
83
bool ? isComplexTextEdit = null , List < CompletionFilter > matchingFilters = null , CompletionItemFlags ? flags = null ,
82
84
CompletionOptions options = null , bool skipSpeculation = false )
@@ -99,9 +101,9 @@ protected override string ItemPartiallyWritten(string expectedItemOrNull)
99
101
=> expectedItemOrNull [ 0 ] == '@' ? expectedItemOrNull . Substring ( 1 , 1 ) : expectedItemOrNull [ ..1 ] ;
100
102
101
103
private async Task VerifyInFrontOfCommentAsync (
102
- string code , int position , string insertText , bool usePreviousCharAsTrigger , char ? deletedCharTrigger ,
104
+ [ StringSyntax ( PredefinedEmbeddedLanguageNames . CSharpTest ) ] string code , int position , string insertText , bool usePreviousCharAsTrigger , char ? deletedCharTrigger ,
103
105
string expectedItemOrNull , string expectedDescriptionOrNull ,
104
- SourceCodeKind sourceCodeKind , bool checkForAbsence , int ? glyph ,
106
+ SourceCodeKind sourceCodeKind , bool checkForAbsence , Glyph ? glyph ,
105
107
int ? matchPriority , bool ? hasSuggestionItem , string displayTextSuffix ,
106
108
string displayTextPrefix , string inlineDescription , bool ? isComplexTextEdit , List < CompletionFilter > matchingFilters ,
107
109
CompletionOptions options , bool skipSpeculation = false )
@@ -118,9 +120,9 @@ await base.VerifyWorkerAsync(
118
120
}
119
121
120
122
private async Task VerifyInFrontOfCommentAsync (
121
- string code , int position , bool usePreviousCharAsTrigger , char ? deletedCharTrigger ,
123
+ [ StringSyntax ( PredefinedEmbeddedLanguageNames . CSharpTest ) ] string code , int position , bool usePreviousCharAsTrigger , char ? deletedCharTrigger ,
122
124
string expectedItemOrNull , string expectedDescriptionOrNull ,
123
- SourceCodeKind sourceCodeKind , bool checkForAbsence , int ? glyph ,
125
+ SourceCodeKind sourceCodeKind , bool checkForAbsence , Glyph ? glyph ,
124
126
int ? matchPriority , bool ? hasSuggestionItem , string displayTextSuffix ,
125
127
string displayTextPrefix , string inlineDescription , bool ? isComplexTextEdit ,
126
128
List < CompletionFilter > matchingFilters , CompletionOptions options , bool skipSpeculation = false )
@@ -133,9 +135,9 @@ await VerifyInFrontOfCommentAsync(
133
135
}
134
136
135
137
private protected async Task VerifyInFrontOfComment_ItemPartiallyWrittenAsync (
136
- string code , int position , bool usePreviousCharAsTrigger , char ? deletedCharTrigger ,
138
+ [ StringSyntax ( PredefinedEmbeddedLanguageNames . CSharpTest ) ] string code , int position , bool usePreviousCharAsTrigger , char ? deletedCharTrigger ,
137
139
string expectedItemOrNull , string expectedDescriptionOrNull ,
138
- SourceCodeKind sourceCodeKind , bool checkForAbsence , int ? glyph ,
140
+ SourceCodeKind sourceCodeKind , bool checkForAbsence , Glyph ? glyph ,
139
141
int ? matchPriority , bool ? hasSuggestionItem , string displayTextSuffix ,
140
142
string displayTextPrefix , string inlineDescription , bool ? isComplexTextEdit ,
141
143
List < CompletionFilter > matchingFilters , CompletionOptions options , bool skipSpeculation = false )
@@ -147,7 +149,7 @@ await VerifyInFrontOfCommentAsync(
147
149
displayTextPrefix , inlineDescription , isComplexTextEdit , matchingFilters , options , skipSpeculation : skipSpeculation ) ;
148
150
}
149
151
150
- protected static string AddInsideMethod ( string text )
152
+ protected static string AddInsideMethod ( [ StringSyntax ( PredefinedEmbeddedLanguageNames . CSharpTest ) ] string text )
151
153
{
152
154
return
153
155
"""
@@ -162,7 +164,8 @@ void F()
162
164
""" ;
163
165
}
164
166
165
- protected static string AddUsingDirectives ( string usingDirectives , string text )
167
+ protected static string AddUsingDirectives (
168
+ string usingDirectives , [ StringSyntax ( PredefinedEmbeddedLanguageNames . CSharpTest ) ] string text )
166
169
{
167
170
return
168
171
usingDirectives +
@@ -172,7 +175,9 @@ protected static string AddUsingDirectives(string usingDirectives, string text)
172
175
text ;
173
176
}
174
177
175
- protected async Task VerifySendEnterThroughToEnterAsync ( string initialMarkup , string textTypedSoFar , EnterKeyRule sendThroughEnterOption , bool expected )
178
+ protected async Task VerifySendEnterThroughToEnterAsync (
179
+ [ StringSyntax ( PredefinedEmbeddedLanguageNames . CSharpTest ) ] string initialMarkup ,
180
+ string textTypedSoFar , EnterKeyRule sendThroughEnterOption , bool expected )
176
181
{
177
182
using var workspace = CreateWorkspace ( initialMarkup ) ;
178
183
var hostDocument = workspace . DocumentWithCursor ;
0 commit comments