Skip to content

Commit 4768d19

Browse files
Use collection expressions (#78237)
2 parents 9eb88c2 + 386241a commit 4768d19

File tree

86 files changed

+154
-162
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+154
-162
lines changed

src/EditorFeatures/CSharpTest/Completion/CompletionProviders/SnippetCompletionProviderTests.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,10 @@ public MockSnippetInfoService()
149149
}
150150

151151
public IEnumerable<SnippetInfo> GetSnippetsIfAvailable()
152-
=> new List<SnippetInfo>
153-
{
154-
new SnippetInfo(SnippetShortcut, SnippetTitle, SnippetDescription, SnippetPath),
155-
new SnippetInfo(PreProcessorSnippetShortcut, PreProcessorSnippetTitle, PreProcessorSnippetDescription, PreProcessorSnippetPath)
156-
};
152+
=> [
153+
new SnippetInfo(SnippetShortcut, SnippetTitle, SnippetDescription, SnippetPath),
154+
new SnippetInfo(PreProcessorSnippetShortcut, PreProcessorSnippetTitle, PreProcessorSnippetDescription, PreProcessorSnippetPath)
155+
];
157156

158157
public bool SnippetShortcutExists_NonBlocking(string shortcut)
159158
=> string.Equals(shortcut, SnippetShortcut, StringComparison.OrdinalIgnoreCase) ||

src/EditorFeatures/CSharpTest/SignatureHelp/AbstractCSharpSignatureHelpProviderTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ public abstract class AbstractCSharpSignatureHelpProviderTests : AbstractSignatu
1313
{
1414
protected override ParseOptions CreateExperimentalParseOptions()
1515
{
16-
return new CSharpParseOptions().WithFeatures(new Dictionary<string, string>()); // no experimental features to enable
16+
return new CSharpParseOptions().WithFeatures([]); // no experimental features to enable
1717
}
1818
}

src/EditorFeatures/CSharpTest/SignatureHelp/AttributeSignatureHelpProviderTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -877,7 +877,7 @@ public MyAttribute(int x)
877877

878878
await TestSignatureHelpInEditorBrowsableContextsAsync(markup: markup,
879879
referencedCode: referencedCode,
880-
expectedOrderedItemsMetadataReference: new List<SignatureHelpTestItem>(),
880+
expectedOrderedItemsMetadataReference: [],
881881
expectedOrderedItemsSameSolution: expectedOrderedItems,
882882
sourceLanguage: LanguageNames.CSharp,
883883
referencedLanguage: LanguageNames.CSharp);
@@ -910,7 +910,7 @@ public MyAttribute(int x)
910910

911911
await TestSignatureHelpInEditorBrowsableContextsAsync(markup: markup,
912912
referencedCode: referencedCode,
913-
expectedOrderedItemsMetadataReference: new List<SignatureHelpTestItem>(),
913+
expectedOrderedItemsMetadataReference: [],
914914
expectedOrderedItemsSameSolution: expectedOrderedItems,
915915
sourceLanguage: LanguageNames.CSharp,
916916
referencedLanguage: LanguageNames.CSharp,

src/EditorFeatures/CSharpTest/SignatureHelp/ConstructorInitializerSignatureHelpProviderTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ public BaseClass(int x)
478478

479479
await TestSignatureHelpInEditorBrowsableContextsAsync(markup: markup,
480480
referencedCode: referencedCode,
481-
expectedOrderedItemsMetadataReference: new List<SignatureHelpTestItem>(),
481+
expectedOrderedItemsMetadataReference: [],
482482
expectedOrderedItemsSameSolution: expectedOrderedItems,
483483
sourceLanguage: LanguageNames.CSharp,
484484
referencedLanguage: LanguageNames.CSharp);
@@ -509,7 +509,7 @@ public BaseClass(int x)
509509

510510
await TestSignatureHelpInEditorBrowsableContextsAsync(markup: markup,
511511
referencedCode: referencedCode,
512-
expectedOrderedItemsMetadataReference: new List<SignatureHelpTestItem>(),
512+
expectedOrderedItemsMetadataReference: [],
513513
expectedOrderedItemsSameSolution: expectedOrderedItems,
514514
sourceLanguage: LanguageNames.CSharp,
515515
referencedLanguage: LanguageNames.CSharp,

src/EditorFeatures/CSharpTest/SignatureHelp/ElementAccessExpressionSignatureHelpProviderTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ public int this[int x]
503503

504504
await TestSignatureHelpInEditorBrowsableContextsAsync(markup: markup,
505505
referencedCode: referencedCode,
506-
expectedOrderedItemsMetadataReference: new List<SignatureHelpTestItem>(),
506+
expectedOrderedItemsMetadataReference: [],
507507
expectedOrderedItemsSameSolution: expectedOrderedItemsMetadataReference,
508508
sourceLanguage: LanguageNames.CSharp,
509509
referencedLanguage: LanguageNames.CSharp);
@@ -540,7 +540,7 @@ public int this[int x]
540540

541541
await TestSignatureHelpInEditorBrowsableContextsAsync(markup: markup,
542542
referencedCode: referencedCode,
543-
expectedOrderedItemsMetadataReference: new List<SignatureHelpTestItem>(),
543+
expectedOrderedItemsMetadataReference: [],
544544
expectedOrderedItemsSameSolution: expectedOrderedItems,
545545
sourceLanguage: LanguageNames.CSharp,
546546
referencedLanguage: LanguageNames.CSharp,

src/EditorFeatures/CSharpTest/SignatureHelp/GenericNamePartiallyWrittenSignatureHelpProviderTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ public void Goo<T>(T x)
209209

210210
await TestSignatureHelpInEditorBrowsableContextsAsync(markup: markup,
211211
referencedCode: referencedCode,
212-
expectedOrderedItemsMetadataReference: new List<SignatureHelpTestItem>(),
212+
expectedOrderedItemsMetadataReference: [],
213213
expectedOrderedItemsSameSolution: expectedOrderedItems,
214214
sourceLanguage: LanguageNames.CSharp,
215215
referencedLanguage: LanguageNames.CSharp);
@@ -252,7 +252,7 @@ await TestSignatureHelpInEditorBrowsableContextsAsync(markup: markup,
252252

253253
await TestSignatureHelpInEditorBrowsableContextsAsync(markup: markup,
254254
referencedCode: referencedCode,
255-
expectedOrderedItemsMetadataReference: new List<SignatureHelpTestItem>(),
255+
expectedOrderedItemsMetadataReference: [],
256256
expectedOrderedItemsSameSolution: expectedOrderedItems,
257257
sourceLanguage: LanguageNames.CSharp,
258258
referencedLanguage: LanguageNames.CSharp,

src/EditorFeatures/CSharpTest/SignatureHelp/GenericNameSignatureHelpProviderTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -736,10 +736,10 @@ void Bar()
736736
}
737737
""";
738738

739-
await TestAsync(markup, new List<SignatureHelpTestItem>
740-
{
739+
await TestAsync(markup,
740+
[
741741
new SignatureHelpTestItem("void C.M<T>(T arg) where T : unmanaged", "summary headline", "T documentation", currentParameterIndex: 0)
742-
});
742+
]);
743743
}
744744

745745
#endregion
@@ -888,7 +888,7 @@ public class C<T>
888888

889889
await TestSignatureHelpInEditorBrowsableContextsAsync(markup: markup,
890890
referencedCode: referencedCode,
891-
expectedOrderedItemsMetadataReference: new List<SignatureHelpTestItem>(),
891+
expectedOrderedItemsMetadataReference: [],
892892
expectedOrderedItemsSameSolution: expectedOrderedItems,
893893
sourceLanguage: LanguageNames.CSharp,
894894
referencedLanguage: LanguageNames.CSharp);
@@ -921,7 +921,7 @@ public class C<T>
921921

922922
await TestSignatureHelpInEditorBrowsableContextsAsync(markup: markup,
923923
referencedCode: referencedCode,
924-
expectedOrderedItemsMetadataReference: new List<SignatureHelpTestItem>(),
924+
expectedOrderedItemsMetadataReference: [],
925925
expectedOrderedItemsSameSolution: expectedOrderedItems,
926926
sourceLanguage: LanguageNames.CSharp,
927927
referencedLanguage: LanguageNames.CSharp,

src/EditorFeatures/CSharpTest/SignatureHelp/ObjectCreationExpressionSignatureHelpProviderTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ public Goo()
531531
await TestSignatureHelpInEditorBrowsableContextsAsync(
532532
markup: markup,
533533
referencedCode: referencedCode,
534-
expectedOrderedItemsMetadataReference: new List<SignatureHelpTestItem>(),
534+
expectedOrderedItemsMetadataReference: [],
535535
expectedOrderedItemsSameSolution: expectedOrderedItems,
536536
sourceLanguage: LanguageNames.CSharp,
537537
referencedLanguage: LanguageNames.CSharp,

src/EditorFeatures/Core.Wpf/Suggestions/SuggestedActionPriorityProvider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ internal sealed class SuggestedActionPriorityProvider(
2323

2424
public struct LowPriorityAnalyzersAndDiagnosticIds()
2525
{
26-
public ConcurrentSet<DiagnosticAnalyzer> Analyzers { get; } = new();
27-
public ConcurrentSet<string> SupportedDiagnosticIds { get; } = new();
26+
public ConcurrentSet<DiagnosticAnalyzer> Analyzers { get; } = [];
27+
public ConcurrentSet<string> SupportedDiagnosticIds { get; } = [];
2828
}
2929

3030
public void AddDeprioritizedAnalyzerWithLowPriority(DiagnosticAnalyzer analyzer)

src/EditorFeatures/Core/Classification/Syntactic/SyntacticClassificationTaggerProvider.ClassifiedLineCache.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ private sealed class ClassifiedLineCache(IThreadingContext threadingContext)
4343
/// </summary>
4444
private const int CacheSize = 256;
4545

46-
private static readonly ObjectPool<SegmentedList<ClassifiedSpan>> s_classifiedSpanListPool = new(() => new(), CacheSize);
46+
private static readonly ObjectPool<SegmentedList<ClassifiedSpan>> s_classifiedSpanListPool = new(() => [], CacheSize);
4747

4848
private readonly IThreadingContext _threadingContext = threadingContext;
4949

0 commit comments

Comments
 (0)