55#nullable disable
66
77using System . Collections . Generic ;
8+ using System . Diagnostics . CodeAnalysis ;
89using System . Linq ;
910using System . Threading . Tasks ;
1011using Microsoft . CodeAnalysis . Completion ;
@@ -29,7 +30,8 @@ public abstract class AbstractCSharpCompletionProviderTests<TWorkspaceFixture> :
2930{
3031 protected const string NonBreakingSpaceString = "\x00A0 " ;
3132
32- protected static string GetMarkup ( string source , LanguageVersion languageVersion )
33+ protected static string GetMarkup (
34+ [ StringSyntax ( PredefinedEmbeddedLanguageNames . CSharpTest ) ] string source , LanguageVersion languageVersion )
3335 => $@ "<Workspace>
3436 <Project Language=""C#"" AssemblyName=""Assembly1"" CommonReferences=""true"" LanguageVersion=""{ languageVersion . ToDisplayString ( ) } "">
3537 <Document FilePath=""Test2.cs"">
@@ -40,17 +42,17 @@ protected static string GetMarkup(string source, LanguageVersion languageVersion
4042 </Project>
4143</Workspace>" ;
4244
43- protected override EditorTestWorkspace CreateWorkspace ( string fileContents )
45+ protected override EditorTestWorkspace CreateWorkspace ( [ StringSyntax ( PredefinedEmbeddedLanguageNames . CSharpTest ) ] string fileContents )
4446 => EditorTestWorkspace . CreateCSharp ( fileContents , composition : GetComposition ( ) ) ;
4547
4648 internal override CompletionService GetCompletionService ( Project project )
4749 => Assert . IsType < CSharpCompletionService > ( base . GetCompletionService ( project ) ) ;
4850
4951 private protected override Task BaseVerifyWorkerAsync (
50- string code , int position ,
52+ [ StringSyntax ( PredefinedEmbeddedLanguageNames . CSharpTest ) ] string code , int position ,
5153 string expectedItemOrNull , string expectedDescriptionOrNull ,
5254 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 ,
5456 string displayTextPrefix , string inlineDescription = null , bool ? isComplexTextEdit = null ,
5557 List < CompletionFilter > matchingFilters = null , CompletionItemFlags ? flags = null ,
5658 CompletionOptions options = null , bool skipSpeculation = false )
@@ -63,7 +65,7 @@ private protected override Task BaseVerifyWorkerAsync(
6365 }
6466
6567 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 ,
6769 SourceCodeKind sourceCodeKind , ItemExpectation [ ] expectedResults ,
6870 List < CompletionFilter > matchingFilters , CompletionItemFlags ? flags , CompletionOptions options , bool skipSpeculation = false )
6971 {
@@ -73,10 +75,10 @@ private protected override Task BaseVerifyWorkerAsync(
7375 }
7476
7577 private protected override async Task VerifyWorkerAsync (
76- string code , int position ,
78+ [ StringSyntax ( PredefinedEmbeddedLanguageNames . CSharpTest ) ] string code , int position ,
7779 string expectedItemOrNull , string expectedDescriptionOrNull ,
7880 SourceCodeKind sourceCodeKind , bool usePreviousCharAsTrigger , char ? deletedCharTrigger ,
79- bool checkForAbsence , int ? glyph , int ? matchPriority ,
81+ bool checkForAbsence , Glyph ? glyph , int ? matchPriority ,
8082 bool ? hasSuggestionItem , string displayTextSuffix , string displayTextPrefix , string inlineDescription = null ,
8183 bool ? isComplexTextEdit = null , List < CompletionFilter > matchingFilters = null , CompletionItemFlags ? flags = null ,
8284 CompletionOptions options = null , bool skipSpeculation = false )
@@ -99,9 +101,9 @@ protected override string ItemPartiallyWritten(string expectedItemOrNull)
99101 => expectedItemOrNull [ 0 ] == '@' ? expectedItemOrNull . Substring ( 1 , 1 ) : expectedItemOrNull [ ..1 ] ;
100102
101103 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 ,
103105 string expectedItemOrNull , string expectedDescriptionOrNull ,
104- SourceCodeKind sourceCodeKind , bool checkForAbsence , int ? glyph ,
106+ SourceCodeKind sourceCodeKind , bool checkForAbsence , Glyph ? glyph ,
105107 int ? matchPriority , bool ? hasSuggestionItem , string displayTextSuffix ,
106108 string displayTextPrefix , string inlineDescription , bool ? isComplexTextEdit , List < CompletionFilter > matchingFilters ,
107109 CompletionOptions options , bool skipSpeculation = false )
@@ -118,9 +120,9 @@ await base.VerifyWorkerAsync(
118120 }
119121
120122 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 ,
122124 string expectedItemOrNull , string expectedDescriptionOrNull ,
123- SourceCodeKind sourceCodeKind , bool checkForAbsence , int ? glyph ,
125+ SourceCodeKind sourceCodeKind , bool checkForAbsence , Glyph ? glyph ,
124126 int ? matchPriority , bool ? hasSuggestionItem , string displayTextSuffix ,
125127 string displayTextPrefix , string inlineDescription , bool ? isComplexTextEdit ,
126128 List < CompletionFilter > matchingFilters , CompletionOptions options , bool skipSpeculation = false )
@@ -133,9 +135,9 @@ await VerifyInFrontOfCommentAsync(
133135 }
134136
135137 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 ,
137139 string expectedItemOrNull , string expectedDescriptionOrNull ,
138- SourceCodeKind sourceCodeKind , bool checkForAbsence , int ? glyph ,
140+ SourceCodeKind sourceCodeKind , bool checkForAbsence , Glyph ? glyph ,
139141 int ? matchPriority , bool ? hasSuggestionItem , string displayTextSuffix ,
140142 string displayTextPrefix , string inlineDescription , bool ? isComplexTextEdit ,
141143 List < CompletionFilter > matchingFilters , CompletionOptions options , bool skipSpeculation = false )
@@ -147,7 +149,7 @@ await VerifyInFrontOfCommentAsync(
147149 displayTextPrefix , inlineDescription , isComplexTextEdit , matchingFilters , options , skipSpeculation : skipSpeculation ) ;
148150 }
149151
150- protected static string AddInsideMethod ( string text )
152+ protected static string AddInsideMethod ( [ StringSyntax ( PredefinedEmbeddedLanguageNames . CSharpTest ) ] string text )
151153 {
152154 return
153155 """
@@ -162,7 +164,8 @@ void F()
162164 """ ;
163165 }
164166
165- protected static string AddUsingDirectives ( string usingDirectives , string text )
167+ protected static string AddUsingDirectives (
168+ string usingDirectives , [ StringSyntax ( PredefinedEmbeddedLanguageNames . CSharpTest ) ] string text )
166169 {
167170 return
168171usingDirectives +
@@ -172,7 +175,9 @@ protected static string AddUsingDirectives(string usingDirectives, string text)
172175text ;
173176 }
174177
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 )
176181 {
177182 using var workspace = CreateWorkspace ( initialMarkup ) ;
178183 var hostDocument = workspace . DocumentWithCursor ;
0 commit comments