From 9a91df6043b2a5b8074c86b6785fac85e222fc20 Mon Sep 17 00:00:00 2001 From: Heejae Chang Date: Thu, 10 Aug 2017 13:27:21 -0700 Subject: [PATCH] moved every thing to IList --- .../InternalUtilities/EnumerableExtensions.cs | 15 ++++++++++ .../AddUsing/AddUsingTests_NuGet.cs | 6 ++-- .../TodoCommentIncrementalAnalyzer.cs | 6 ++-- .../SymbolSearchUpdateEngineFactory.cs | 14 ++++++---- .../AddImport/AddImportTests_NuGet.vb | 6 ++-- ...pTodoCommentIncrementalAnalyzerProvider.cs | 2 +- .../AbstractAddImportFeatureService.cs | 6 ++-- .../AbstractAddImportFeatureService_Remote.cs | 6 ++-- .../Remote/IRemoteAddImportFeatureService.cs | 4 +-- ...olReferenceFinder_PackageAssemblySearch.cs | 5 ++-- .../IRemoteDesignerAttributeService.cs | 2 +- .../AbstractDocumentHighlightsService.cs | 6 ++-- .../IRemoteDocumentHighlights.cs | 4 +-- .../AbstractNavigateToSearchService.Remote.cs | 10 ++++--- .../IRemoteNavigateToSearchService.cs | 4 +-- .../AbstractTodoCommentService.cs | 20 ++++++------- .../TodoComments/IRemoteTodoCommentService.cs | 2 +- .../TodoComments/ITodoCommentService.cs | 2 +- ...cTodoCommentIncrementalAnalyzerProvider.vb | 2 +- .../DesignerAttributeIncrementalAnalyzer.cs | 2 +- .../VisualStudioSymbolSearchService.cs | 6 ++-- .../DeclarationFinder_AllDeclarations.cs | 9 +++--- .../DeclarationFinder_SourceDeclarations.cs | 13 +++++---- .../FindSymbols/IRemoteSymbolFinder.cs | 8 +++--- .../IRemoteSymbolSearchUpdateEngine.cs | 6 ++-- .../SymbolSearch/ISymbolSearchService.cs | 26 ++++++++--------- .../Utilities/IReadOnlyListExtensions.cs | 28 ++++++++++++++++++- .../Services/CodeAnalysisService_AddImport.cs | 16 +++++------ .../CodeAnalysisService_DesignerAttributes.cs | 4 +-- .../CodeAnalysisService_DocumentHighlights.cs | 2 +- .../CodeAnalysisService_NavigateTo.cs | 4 +-- .../CodeAnalysisService_SymbolFinder.cs | 8 +++--- .../CodeAnalysisService_TodoComments.cs | 4 +-- .../RemoteSymbolSearchUpdateEngine.cs | 6 ++-- 34 files changed, 156 insertions(+), 108 deletions(-) diff --git a/src/Compilers/Core/Portable/InternalUtilities/EnumerableExtensions.cs b/src/Compilers/Core/Portable/InternalUtilities/EnumerableExtensions.cs index 08ac4dcd6c0..929f6ce36ef 100644 --- a/src/Compilers/Core/Portable/InternalUtilities/EnumerableExtensions.cs +++ b/src/Compilers/Core/Portable/InternalUtilities/EnumerableExtensions.cs @@ -3,9 +3,11 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Collections.Immutable; using System.Collections.ObjectModel; using System.Diagnostics; using System.Linq; +using Microsoft.CodeAnalysis.PooledObjects; namespace Roslyn.Utilities { @@ -242,6 +244,19 @@ public static IEnumerable WhereNotNull(this IEnumerable source) return source.Where((Func)s_notNullTest); } + public static ImmutableArray SelectAsArray(this IEnumerable source, Func selector) + { + if (source == null) + { + return ImmutableArray.Empty; + } + + var builder = ArrayBuilder.GetInstance(); + builder.AddRange(source.Select(selector)); + + return builder.ToImmutableAndFree(); + } + public static bool All(this IEnumerable source) { if (source == null) diff --git a/src/EditorFeatures/CSharpTest/AddUsing/AddUsingTests_NuGet.cs b/src/EditorFeatures/CSharpTest/AddUsing/AddUsingTests_NuGet.cs index 1bd614d61df..9d12f9d4f9c 100644 --- a/src/EditorFeatures/CSharpTest/AddUsing/AddUsingTests_NuGet.cs +++ b/src/EditorFeatures/CSharpTest/AddUsing/AddUsingTests_NuGet.cs @@ -257,7 +257,7 @@ public async Task TestFailedInstallRollsBackFile() installerServiceMock.Verify(); } - private Task> CreateSearchResult( + private Task> CreateSearchResult( string packageName, string typeName, ImmutableArray containingNamespaceNames) { return CreateSearchResult(new PackageWithTypeResult( @@ -265,8 +265,8 @@ public async Task TestFailedInstallRollsBackFile() rank: 0, containingNamespaceNames: containingNamespaceNames)); } - private Task> CreateSearchResult(params PackageWithTypeResult[] results) - => Task.FromResult>(ImmutableArray.Create(results)); + private Task> CreateSearchResult(params PackageWithTypeResult[] results) + => Task.FromResult>(ImmutableArray.Create(results)); private ImmutableArray CreateNameParts(params string[] parts) => parts.ToImmutableArray(); } diff --git a/src/EditorFeatures/Core/Implementation/TodoComment/TodoCommentIncrementalAnalyzer.cs b/src/EditorFeatures/Core/Implementation/TodoComment/TodoCommentIncrementalAnalyzer.cs index 86611f7f280..466004e7707 100644 --- a/src/EditorFeatures/Core/Implementation/TodoComment/TodoCommentIncrementalAnalyzer.cs +++ b/src/EditorFeatures/Core/Implementation/TodoComment/TodoCommentIncrementalAnalyzer.cs @@ -87,19 +87,19 @@ public async Task AnalyzeSyntaxAsync(Document document, InvocationReasons reason } } - private async Task> GetTodoCommentsAsync(Document document, IReadOnlyList tokens, CancellationToken cancellationToken) + private async Task> GetTodoCommentsAsync(Document document, IList tokens, CancellationToken cancellationToken) { var service = document.GetLanguageService(); if (service == null) { // no inproc support - return SpecializedCollections.EmptyReadOnlyList(); + return SpecializedCollections.EmptyList(); } return await service.GetTodoCommentsAsync(document, tokens, cancellationToken).ConfigureAwait(false); } - private async Task> CreateItemsAsync(Document document, IReadOnlyList comments, CancellationToken cancellationToken) + private async Task> CreateItemsAsync(Document document, IList comments, CancellationToken cancellationToken) { var items = ImmutableArray.CreateBuilder(); if (comments != null) diff --git a/src/EditorFeatures/Core/SymbolSearch/SymbolSearchUpdateEngineFactory.cs b/src/EditorFeatures/Core/SymbolSearch/SymbolSearchUpdateEngineFactory.cs index b7d0888c028..c76757b729e 100644 --- a/src/EditorFeatures/Core/SymbolSearch/SymbolSearchUpdateEngineFactory.cs +++ b/src/EditorFeatures/Core/SymbolSearch/SymbolSearchUpdateEngineFactory.cs @@ -1,9 +1,11 @@ // Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System.Collections.Generic; using System.Collections.Immutable; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Remote; +using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.SymbolSearch { @@ -61,31 +63,31 @@ private partial class RemoteUpdateEngine : ISymbolSearchUpdateEngine, ISymbolSea public async Task> FindPackagesWithTypeAsync( string source, string name, int arity, CancellationToken cancellationToken) { - var results = await _session.TryInvokeAsync>( + var results = await _session.TryInvokeAsync>( nameof(IRemoteSymbolSearchUpdateEngine.FindPackagesWithTypeAsync), new object[] { source, name, arity }, cancellationToken).ConfigureAwait(false); - return results.NullToEmpty(); + return results.ToImmutableArrayOrEmpty(); } public async Task> FindPackagesWithAssemblyAsync( string source, string assemblyName, CancellationToken cancellationToken) { - var results = await _session.TryInvokeAsync>( + var results = await _session.TryInvokeAsync>( nameof(IRemoteSymbolSearchUpdateEngine.FindPackagesWithAssemblyAsync), new object[] { source, assemblyName }, cancellationToken).ConfigureAwait(false); - return results.NullToEmpty(); + return results.ToImmutableArrayOrEmpty(); } public async Task> FindReferenceAssembliesWithTypeAsync( string name, int arity, CancellationToken cancellationToken) { - var results = await _session.TryInvokeAsync>( + var results = await _session.TryInvokeAsync>( nameof(IRemoteSymbolSearchUpdateEngine.FindReferenceAssembliesWithTypeAsync), new object[] { name, arity }, cancellationToken).ConfigureAwait(false); - return results.NullToEmpty(); + return results.ToImmutableArrayOrEmpty(); } public async Task UpdateContinuouslyAsync( diff --git a/src/EditorFeatures/VisualBasicTest/Diagnostics/AddImport/AddImportTests_NuGet.vb b/src/EditorFeatures/VisualBasicTest/Diagnostics/AddImport/AddImportTests_NuGet.vb index b2fb56157de..b0d626ebda0 100644 --- a/src/EditorFeatures/VisualBasicTest/Diagnostics/AddImport/AddImportTests_NuGet.vb +++ b/src/EditorFeatures/VisualBasicTest/Diagnostics/AddImport/AddImportTests_NuGet.vb @@ -239,7 +239,7 @@ End Class", fixProviderData:=New ProviderData(installerServiceMock.Object, packa installerServiceMock.Verify() End Function - Private Function CreateSearchResult(packageName As String, typeName As String, nameParts As ImmutableArray(Of String)) As Task(Of IReadOnlyList(Of PackageWithTypeResult)) + Private Function CreateSearchResult(packageName As String, typeName As String, nameParts As ImmutableArray(Of String)) As Task(Of IList(Of PackageWithTypeResult)) Return CreateSearchResult(New PackageWithTypeResult( packageName:=packageName, typeName:=typeName, @@ -248,8 +248,8 @@ End Class", fixProviderData:=New ProviderData(installerServiceMock.Object, packa containingNamespaceNames:=nameParts)) End Function - Private Function CreateSearchResult(ParamArray results As PackageWithTypeResult()) As Task(Of IReadOnlyList(Of PackageWithTypeResult)) - Return Task.FromResult(Of IReadOnlyList(Of PackageWithTypeResult))(ImmutableArray.Create(results)) + Private Function CreateSearchResult(ParamArray results As PackageWithTypeResult()) As Task(Of IList(Of PackageWithTypeResult)) + Return Task.FromResult(Of IList(Of PackageWithTypeResult))(ImmutableArray.Create(results)) End Function Private Function CreateNameParts(ParamArray parts As String()) As ImmutableArray(Of String) diff --git a/src/Features/CSharp/Portable/TodoComments/CSharpTodoCommentIncrementalAnalyzerProvider.cs b/src/Features/CSharp/Portable/TodoComments/CSharpTodoCommentIncrementalAnalyzerProvider.cs index 6ec91af8f23..a2fca9fda9b 100644 --- a/src/Features/CSharp/Portable/TodoComments/CSharpTodoCommentIncrementalAnalyzerProvider.cs +++ b/src/Features/CSharp/Portable/TodoComments/CSharpTodoCommentIncrementalAnalyzerProvider.cs @@ -28,7 +28,7 @@ public CSharpTodoCommentService(Workspace workspace) : base(workspace) { } - protected override void AppendTodoComments(IReadOnlyList commentDescriptors, SyntacticDocument document, SyntaxTrivia trivia, List todoList) + protected override void AppendTodoComments(IList commentDescriptors, SyntacticDocument document, SyntaxTrivia trivia, List todoList) { if (PreprocessorHasComment(trivia)) { diff --git a/src/Features/Core/Portable/AddImport/AbstractAddImportFeatureService.cs b/src/Features/Core/Portable/AddImport/AbstractAddImportFeatureService.cs index f591a7a63ef..7b8b5ce3687 100644 --- a/src/Features/Core/Portable/AddImport/AbstractAddImportFeatureService.cs +++ b/src/Features/Core/Portable/AddImport/AbstractAddImportFeatureService.cs @@ -61,7 +61,7 @@ protected AbstractAddImportFeatureService() if (RemoteSupportedLanguages.IsSupported(document.Project.Language)) { var callbackTarget = new RemoteSymbolSearchService(symbolSearchService, cancellationToken); - var result = await document.Project.Solution.TryRunCodeAnalysisRemoteAsync>( + var result = await document.Project.Solution.TryRunCodeAnalysisRemoteAsync>( RemoteFeatureOptions.AddImportEnabled, callbackTarget, nameof(IRemoteAddImportFeatureService.GetFixesAsync), @@ -78,9 +78,9 @@ protected AbstractAddImportFeatureService() var documentOptions = await document.GetOptionsAsync(cancellationToken).ConfigureAwait(false); - if (!result.IsDefault) + if (result != null) { - return result; + return result.ToImmutableArray(); } } diff --git a/src/Features/Core/Portable/AddImport/Remote/AbstractAddImportFeatureService_Remote.cs b/src/Features/Core/Portable/AddImport/Remote/AbstractAddImportFeatureService_Remote.cs index 3a236ddf729..8fa8bf95094 100644 --- a/src/Features/Core/Portable/AddImport/Remote/AbstractAddImportFeatureService_Remote.cs +++ b/src/Features/Core/Portable/AddImport/Remote/AbstractAddImportFeatureService_Remote.cs @@ -40,21 +40,21 @@ public Task UpdateContinuouslyAsync(string sourceName, string localSettingsDirec throw new NotImplementedException(); } - public Task> FindPackagesWithTypeAsync( + public Task> FindPackagesWithTypeAsync( string source, string name, int arity, CancellationToken cancellationToken) { return _symbolSearchService.FindPackagesWithTypeAsync( source, name, arity, cancellationToken); } - public Task> FindPackagesWithAssemblyAsync( + public Task> FindPackagesWithAssemblyAsync( string source, string name, CancellationToken cancellationToken) { return _symbolSearchService.FindPackagesWithAssemblyAsync( source, name, cancellationToken); } - public Task> FindReferenceAssembliesWithTypeAsync( + public Task> FindReferenceAssembliesWithTypeAsync( string name, int arity, CancellationToken cancellationToken) { return _symbolSearchService.FindReferenceAssembliesWithTypeAsync( diff --git a/src/Features/Core/Portable/AddImport/Remote/IRemoteAddImportFeatureService.cs b/src/Features/Core/Portable/AddImport/Remote/IRemoteAddImportFeatureService.cs index f1d93472c9f..5fff125b7ef 100644 --- a/src/Features/Core/Portable/AddImport/Remote/IRemoteAddImportFeatureService.cs +++ b/src/Features/Core/Portable/AddImport/Remote/IRemoteAddImportFeatureService.cs @@ -11,8 +11,8 @@ namespace Microsoft.CodeAnalysis.AddImport { internal interface IRemoteAddImportFeatureService { - Task> GetFixesAsync( + Task> GetFixesAsync( DocumentId documentId, TextSpan span, string diagnosticId, bool placeSystemNamespaceFirst, - bool searchReferenceAssemblies, IReadOnlyList packageSources, CancellationToken cancellationToken); + bool searchReferenceAssemblies, IList packageSources, CancellationToken cancellationToken); } } diff --git a/src/Features/Core/Portable/AddImport/SymbolReferenceFinder_PackageAssemblySearch.cs b/src/Features/Core/Portable/AddImport/SymbolReferenceFinder_PackageAssemblySearch.cs index a2bc71f0cd8..7ab3d06324a 100644 --- a/src/Features/Core/Portable/AddImport/SymbolReferenceFinder_PackageAssemblySearch.cs +++ b/src/Features/Core/Portable/AddImport/SymbolReferenceFinder_PackageAssemblySearch.cs @@ -5,6 +5,7 @@ using Microsoft.CodeAnalysis.Packaging; using Microsoft.CodeAnalysis.PooledObjects; using Microsoft.CodeAnalysis.SymbolSearch; +using Microsoft.CodeAnalysis.Utilities; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.AddImport @@ -163,7 +164,7 @@ private partial class SymbolReferenceFinder var desiredName = GetDesiredName(isAttributeSearch, result.TypeName); allReferences.Add(new AssemblyReference( - _owner, new SearchResult(desiredName, nameNode, result.ContainingNamespaceNames, weight), result)); + _owner, new SearchResult(desiredName, nameNode, result.ContainingNamespaceNames.ToReadOnlyList(), weight), result)); } private void HandleNugetReference( @@ -177,7 +178,7 @@ private partial class SymbolReferenceFinder { var desiredName = GetDesiredName(isAttributeSearch, result.TypeName); allReferences.Add(new PackageReference(_owner, - new SearchResult(desiredName, nameNode, result.ContainingNamespaceNames, weight), + new SearchResult(desiredName, nameNode, result.ContainingNamespaceNames.ToReadOnlyList(), weight), source, result.PackageName, result.Version)); } diff --git a/src/Features/Core/Portable/DesignerAttributes/IRemoteDesignerAttributeService.cs b/src/Features/Core/Portable/DesignerAttributes/IRemoteDesignerAttributeService.cs index bd4076c010c..3f09f0a062b 100644 --- a/src/Features/Core/Portable/DesignerAttributes/IRemoteDesignerAttributeService.cs +++ b/src/Features/Core/Portable/DesignerAttributes/IRemoteDesignerAttributeService.cs @@ -8,6 +8,6 @@ namespace Microsoft.CodeAnalysis.DesignerAttributes { internal interface IRemoteDesignerAttributeService { - Task> ScanDesignerAttributesAsync(ProjectId projectId, CancellationToken cancellationToken); + Task> ScanDesignerAttributesAsync(ProjectId projectId, CancellationToken cancellationToken); } } diff --git a/src/Features/Core/Portable/DocumentHighlighting/AbstractDocumentHighlightsService.cs b/src/Features/Core/Portable/DocumentHighlighting/AbstractDocumentHighlightsService.cs index 5d78c9d79f7..d8a5ad324e1 100644 --- a/src/Features/Core/Portable/DocumentHighlighting/AbstractDocumentHighlightsService.cs +++ b/src/Features/Core/Portable/DocumentHighlighting/AbstractDocumentHighlightsService.cs @@ -39,7 +39,7 @@ internal abstract partial class AbstractDocumentHighlightsService : IDocumentHig private async Task<(bool succeeded, ImmutableArray highlights)> GetDocumentHighlightsInRemoteProcessAsync( Document document, int position, IImmutableSet documentsToSearch, CancellationToken cancellationToken) { - var result = await document.Project.Solution.TryRunCodeAnalysisRemoteAsync>( + var result = await document.Project.Solution.TryRunCodeAnalysisRemoteAsync>( RemoteFeatureOptions.DocumentHighlightingEnabled, nameof(IRemoteDocumentHighlights.GetDocumentHighlightsAsync), new object[] @@ -50,12 +50,12 @@ internal abstract partial class AbstractDocumentHighlightsService : IDocumentHig }, cancellationToken).ConfigureAwait(false); - if (result.IsDefault) + if (result == null) { return (succeeded: false, ImmutableArray.Empty); } - return (true, result.SelectAsArray(h => h.Rehydrate(document.Project.Solution))); + return (true, result.Select(h => h.Rehydrate(document.Project.Solution)).ToImmutableArray()); } private async Task> GetDocumentHighlightsInCurrentProcessAsync( diff --git a/src/Features/Core/Portable/DocumentHighlighting/IRemoteDocumentHighlights.cs b/src/Features/Core/Portable/DocumentHighlighting/IRemoteDocumentHighlights.cs index 4078b408241..df95e87c8fe 100644 --- a/src/Features/Core/Portable/DocumentHighlighting/IRemoteDocumentHighlights.cs +++ b/src/Features/Core/Portable/DocumentHighlighting/IRemoteDocumentHighlights.cs @@ -10,14 +10,14 @@ namespace Microsoft.CodeAnalysis.DocumentHighlighting { internal interface IRemoteDocumentHighlights { - Task> GetDocumentHighlightsAsync( + Task> GetDocumentHighlightsAsync( DocumentId documentId, int position, DocumentId[] documentIdsToSearch, CancellationToken cancellationToken); } internal struct SerializableDocumentHighlights { public DocumentId DocumentId; - public IReadOnlyList HighlightSpans; + public IList HighlightSpans; public DocumentHighlights Rehydrate(Solution solution) => new DocumentHighlights(solution.GetDocument(DocumentId), HighlightSpans.ToImmutableArray()); diff --git a/src/Features/Core/Portable/NavigateTo/AbstractNavigateToSearchService.Remote.cs b/src/Features/Core/Portable/NavigateTo/AbstractNavigateToSearchService.Remote.cs index 55e53c71ee7..f7bf8a75e76 100644 --- a/src/Features/Core/Portable/NavigateTo/AbstractNavigateToSearchService.Remote.cs +++ b/src/Features/Core/Portable/NavigateTo/AbstractNavigateToSearchService.Remote.cs @@ -1,12 +1,14 @@ // Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Experiments; using Microsoft.CodeAnalysis.Remote; +using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.NavigateTo { @@ -17,11 +19,11 @@ internal abstract partial class AbstractNavigateToSearchService { var solution = document.Project.Solution; - var serializableResults = await client.TryRunCodeAnalysisRemoteAsync>( + var serializableResults = await client.TryRunCodeAnalysisRemoteAsync>( solution, nameof(IRemoteNavigateToSearchService.SearchDocumentAsync), new object[] { document.Id, searchPattern }, cancellationToken).ConfigureAwait(false); - return serializableResults.NullToEmpty().SelectAsArray(r => r.Rehydrate(solution)); + return serializableResults.SelectAsArray(r => r.Rehydrate(solution)); } private async Task> SearchProjectInRemoteProcessAsync( @@ -29,11 +31,11 @@ internal abstract partial class AbstractNavigateToSearchService { var solution = project.Solution; - var serializableResults = await client.TryRunCodeAnalysisRemoteAsync>( + var serializableResults = await client.TryRunCodeAnalysisRemoteAsync>( solution, nameof(IRemoteNavigateToSearchService.SearchProjectAsync), new object[] { project.Id, searchPattern }, cancellationToken).ConfigureAwait(false); - return serializableResults.NullToEmpty().SelectAsArray(r => r.Rehydrate(solution)); + return serializableResults.SelectAsArray(r => r.Rehydrate(solution)); } private static async Task TryGetRemoteHostClientAsync(Project project, CancellationToken cancellationToken) diff --git a/src/Features/Core/Portable/NavigateTo/IRemoteNavigateToSearchService.cs b/src/Features/Core/Portable/NavigateTo/IRemoteNavigateToSearchService.cs index cf1089e29eb..16f5a09bd07 100644 --- a/src/Features/Core/Portable/NavigateTo/IRemoteNavigateToSearchService.cs +++ b/src/Features/Core/Portable/NavigateTo/IRemoteNavigateToSearchService.cs @@ -10,7 +10,7 @@ namespace Microsoft.CodeAnalysis.NavigateTo { internal interface IRemoteNavigateToSearchService { - Task> SearchDocumentAsync(DocumentId documentId, string searchPattern, CancellationToken cancellationToken); - Task> SearchProjectAsync(ProjectId projectId, string searchPattern, CancellationToken cancellationToken); + Task> SearchDocumentAsync(DocumentId documentId, string searchPattern, CancellationToken cancellationToken); + Task> SearchProjectAsync(ProjectId projectId, string searchPattern, CancellationToken cancellationToken); } } diff --git a/src/Features/Core/Portable/TodoComments/AbstractTodoCommentService.cs b/src/Features/Core/Portable/TodoComments/AbstractTodoCommentService.cs index a45cef7e5f1..d4eeb07e625 100644 --- a/src/Features/Core/Portable/TodoComments/AbstractTodoCommentService.cs +++ b/src/Features/Core/Portable/TodoComments/AbstractTodoCommentService.cs @@ -36,9 +36,9 @@ protected AbstractTodoCommentService(Workspace workspace) protected abstract string GetNormalizedText(string message); protected abstract int GetCommentStartingIndex(string message); - protected abstract void AppendTodoComments(IReadOnlyList commentDescriptors, SyntacticDocument document, SyntaxTrivia trivia, List todoList); + protected abstract void AppendTodoComments(IList commentDescriptors, SyntacticDocument document, SyntaxTrivia trivia, List todoList); - public async Task> GetTodoCommentsAsync(Document document, IReadOnlyList commentDescriptors, CancellationToken cancellationToken) + public async Task> GetTodoCommentsAsync(Document document, IList commentDescriptors, CancellationToken cancellationToken) { // make sure given input is right one Contract.ThrowIfFalse(_workspace == document.Project.Solution.Workspace); @@ -58,17 +58,17 @@ public async Task> GetTodoCommentsAsync(Document docu return await GetTodoCommentsInCurrentProcessAsync(document, commentDescriptors, cancellationToken).ConfigureAwait(false); } - private async Task> GetTodoCommentsInRemoteHostAsync( - RemoteHostClient client, Document document, IReadOnlyList commentDescriptors, CancellationToken cancellationToken) + private async Task> GetTodoCommentsInRemoteHostAsync( + RemoteHostClient client, Document document, IList commentDescriptors, CancellationToken cancellationToken) { var keepAliveSession = await TryGetKeepAliveSessionAsync(client, cancellationToken).ConfigureAwait(false); - var result = await keepAliveSession.TryInvokeAsync>( + var result = await keepAliveSession.TryInvokeAsync>( nameof(IRemoteTodoCommentService.GetTodoCommentsAsync), document.Project.Solution, new object[] { document.Id, commentDescriptors }, cancellationToken).ConfigureAwait(false); - return result ?? SpecializedCollections.EmptyReadOnlyList(); + return result ?? SpecializedCollections.EmptyList(); } private async Task TryGetKeepAliveSessionAsync(RemoteHostClient client, CancellationToken cancellationToken) @@ -84,8 +84,8 @@ private async Task TryGetKeepAliveSessionAsync(RemoteHostClien } } - private async Task> GetTodoCommentsInCurrentProcessAsync( - Document document, IReadOnlyList commentDescriptors, CancellationToken cancellationToken) + private async Task> GetTodoCommentsInCurrentProcessAsync( + Document document, IList commentDescriptors, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); @@ -115,7 +115,7 @@ private bool ContainsComments(SyntaxTrivia trivia) return PreprocessorHasComment(trivia) || IsSingleLineComment(trivia) || IsMultilineComment(trivia); } - protected void AppendTodoCommentInfoFromSingleLine(IReadOnlyList commentDescriptors, SyntacticDocument document, string message, int start, List todoList) + protected void AppendTodoCommentInfoFromSingleLine(IList commentDescriptors, SyntacticDocument document, string message, int start, List todoList) { var index = GetCommentStartingIndex(message); if (index >= message.Length) @@ -147,7 +147,7 @@ protected void AppendTodoCommentInfoFromSingleLine(IReadOnlyList commentDescriptors, SyntacticDocument document, SyntaxTrivia trivia, int postfixLength, List todoList) + protected void ProcessMultilineComment(IList commentDescriptors, SyntacticDocument document, SyntaxTrivia trivia, int postfixLength, List todoList) { // this is okay since we know it is already alive var text = document.Text; diff --git a/src/Features/Core/Portable/TodoComments/IRemoteTodoCommentService.cs b/src/Features/Core/Portable/TodoComments/IRemoteTodoCommentService.cs index c65172d3f10..c518327f06a 100644 --- a/src/Features/Core/Portable/TodoComments/IRemoteTodoCommentService.cs +++ b/src/Features/Core/Portable/TodoComments/IRemoteTodoCommentService.cs @@ -13,6 +13,6 @@ namespace Microsoft.CodeAnalysis.TodoComments /// internal interface IRemoteTodoCommentService { - Task> GetTodoCommentsAsync(PinnedSolutionInfo solutionInfo, DocumentId documentId, IReadOnlyList commentDescriptors, CancellationToken cancellationToken); + Task> GetTodoCommentsAsync(PinnedSolutionInfo solutionInfo, DocumentId documentId, IList commentDescriptors, CancellationToken cancellationToken); } } diff --git a/src/Features/Core/Portable/TodoComments/ITodoCommentService.cs b/src/Features/Core/Portable/TodoComments/ITodoCommentService.cs index 3a378b5b409..e6a36894453 100644 --- a/src/Features/Core/Portable/TodoComments/ITodoCommentService.cs +++ b/src/Features/Core/Portable/TodoComments/ITodoCommentService.cs @@ -42,6 +42,6 @@ public TodoComment(TodoCommentDescriptor descriptor, string message, int positio internal interface ITodoCommentService : ILanguageService { - Task> GetTodoCommentsAsync(Document document, IReadOnlyList commentDescriptors, CancellationToken cancellationToken); + Task> GetTodoCommentsAsync(Document document, IList commentDescriptors, CancellationToken cancellationToken); } } diff --git a/src/Features/VisualBasic/Portable/TodoComments/BasicTodoCommentIncrementalAnalyzerProvider.vb b/src/Features/VisualBasic/Portable/TodoComments/BasicTodoCommentIncrementalAnalyzerProvider.vb index dbcdfe3003f..cca5bb7ea25 100644 --- a/src/Features/VisualBasic/Portable/TodoComments/BasicTodoCommentIncrementalAnalyzerProvider.vb +++ b/src/Features/VisualBasic/Portable/TodoComments/BasicTodoCommentIncrementalAnalyzerProvider.vb @@ -25,7 +25,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.TodoComments MyBase.New(workspace) End Sub - Protected Overrides Sub AppendTodoComments(commentDescriptors As IReadOnlyList(Of TodoCommentDescriptor), document As SyntacticDocument, trivia As SyntaxTrivia, todoList As List(Of TodoComment)) + Protected Overrides Sub AppendTodoComments(commentDescriptors As IList(Of TodoCommentDescriptor), document As SyntacticDocument, trivia As SyntaxTrivia, todoList As List(Of TodoComment)) If PreprocessorHasComment(trivia) Then Dim commentTrivia = trivia.GetStructure().DescendantTrivia().First(Function(t) t.RawKind = SyntaxKind.CommentTrivia) diff --git a/src/VisualStudio/Core/Def/Implementation/DesignerAttribute/DesignerAttributeIncrementalAnalyzer.cs b/src/VisualStudio/Core/Def/Implementation/DesignerAttribute/DesignerAttributeIncrementalAnalyzer.cs index 7dd8ee8705d..6ceaa77b5d7 100644 --- a/src/VisualStudio/Core/Def/Implementation/DesignerAttribute/DesignerAttributeIncrementalAnalyzer.cs +++ b/src/VisualStudio/Core/Def/Implementation/DesignerAttribute/DesignerAttributeIncrementalAnalyzer.cs @@ -130,7 +130,7 @@ public async Task AnalyzeProjectAsync(Project project, bool semanticsChanged, In return null; } - var serializedResults = await session.InvokeAsync>( + var serializedResults = await session.InvokeAsync>( nameof(IRemoteDesignerAttributeService.ScanDesignerAttributesAsync), new object[] { project.Id }, cancellationToken).ConfigureAwait(false); var data = serializedResults.ToImmutableDictionary(kvp => kvp.FilePath); diff --git a/src/VisualStudio/Core/Def/SymbolSearch/VisualStudioSymbolSearchService.cs b/src/VisualStudio/Core/Def/SymbolSearch/VisualStudioSymbolSearchService.cs index 6b7f9d79bef..ccd06a3f2ee 100644 --- a/src/VisualStudio/Core/Def/SymbolSearch/VisualStudioSymbolSearchService.cs +++ b/src/VisualStudio/Core/Def/SymbolSearch/VisualStudioSymbolSearchService.cs @@ -108,7 +108,7 @@ private async Task UpdateSourceInBackgroundAsync(string sourceName) await engine.UpdateContinuouslyAsync(sourceName, _localSettingsDirectory).ConfigureAwait(false); } - public async Task> FindPackagesWithTypeAsync( + public async Task> FindPackagesWithTypeAsync( string source, string name, int arity, CancellationToken cancellationToken) { var engine = await GetEngine(cancellationToken).ConfigureAwait(false); @@ -118,7 +118,7 @@ private async Task UpdateSourceInBackgroundAsync(string sourceName) return FilterAndOrderPackages(allPackagesWithType); } - public async Task> FindPackagesWithAssemblyAsync( + public async Task> FindPackagesWithAssemblyAsync( string source, string assemblyName, CancellationToken cancellationToken) { var engine = await GetEngine(cancellationToken).ConfigureAwait(false); @@ -170,7 +170,7 @@ private async Task UpdateSourceInBackgroundAsync(string sourceName) return result.ToImmutableAndFree(); } - public async Task> FindReferenceAssembliesWithTypeAsync( + public async Task> FindReferenceAssembliesWithTypeAsync( string name, int arity, CancellationToken cancellationToken) { var engine = await GetEngine(cancellationToken).ConfigureAwait(false); diff --git a/src/Workspaces/Core/Portable/FindSymbols/Declarations/DeclarationFinder_AllDeclarations.cs b/src/Workspaces/Core/Portable/FindSymbols/Declarations/DeclarationFinder_AllDeclarations.cs index 5804518b3d3..2619fdcc5ce 100644 --- a/src/Workspaces/Core/Portable/FindSymbols/Declarations/DeclarationFinder_AllDeclarations.cs +++ b/src/Workspaces/Core/Portable/FindSymbols/Declarations/DeclarationFinder_AllDeclarations.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.Collections.Generic; using System.Collections.Immutable; using System.Diagnostics; using System.Threading; @@ -99,12 +100,12 @@ internal static partial class DeclarationFinder return (false, ImmutableArray.Empty); } - var result = await project.Solution.TryRunCodeAnalysisRemoteAsync>( + var result = await project.Solution.TryRunCodeAnalysisRemoteAsync>( RemoteFeatureOptions.SymbolFinderEnabled, nameof(IRemoteSymbolFinder.FindAllDeclarationsWithNormalQueryAsync), new object[] { project.Id, query.Name, query.Kind, criteria }, cancellationToken).ConfigureAwait(false); - if (result.IsDefault) + if (result == null) { return (false, ImmutableArray.Empty); } @@ -116,9 +117,9 @@ internal static partial class DeclarationFinder } private static async Task> RehydrateAsync( - Solution solution, ImmutableArray array, CancellationToken cancellationToken) + Solution solution, IList array, CancellationToken cancellationToken) { - var result = ArrayBuilder.GetInstance(array.Length); + var result = ArrayBuilder.GetInstance(array.Count); foreach (var dehydrated in array) { diff --git a/src/Workspaces/Core/Portable/FindSymbols/Declarations/DeclarationFinder_SourceDeclarations.cs b/src/Workspaces/Core/Portable/FindSymbols/Declarations/DeclarationFinder_SourceDeclarations.cs index 60b80e14e53..1f915167d00 100644 --- a/src/Workspaces/Core/Portable/FindSymbols/Declarations/DeclarationFinder_SourceDeclarations.cs +++ b/src/Workspaces/Core/Portable/FindSymbols/Declarations/DeclarationFinder_SourceDeclarations.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.Collections.Generic; using System.Collections.Immutable; using System.Threading; using System.Threading.Tasks; @@ -115,12 +116,12 @@ internal static partial class DeclarationFinder private static async Task<(bool, ImmutableArray)> TryFindSourceDeclarationsWithNormalQueryInRemoteProcessAsync( Solution solution, string name, bool ignoreCase, SymbolFilter criteria, CancellationToken cancellationToken) { - var result = await solution.TryRunCodeAnalysisRemoteAsync>( + var result = await solution.TryRunCodeAnalysisRemoteAsync>( RemoteFeatureOptions.SymbolFinderEnabled, nameof(IRemoteSymbolFinder.FindSolutionSourceDeclarationsWithNormalQueryAsync), new object[] { name, ignoreCase, criteria }, cancellationToken).ConfigureAwait(false); - if (result.IsDefault) + if (result == null) { return (false, ImmutableArray.Empty); } @@ -139,12 +140,12 @@ internal static partial class DeclarationFinder return (false, ImmutableArray.Empty); } - var result = await project.Solution.TryRunCodeAnalysisRemoteAsync>( + var result = await project.Solution.TryRunCodeAnalysisRemoteAsync>( RemoteFeatureOptions.SymbolFinderEnabled, nameof(IRemoteSymbolFinder.FindProjectSourceDeclarationsWithNormalQueryAsync), new object[] { project.Id, name, ignoreCase, criteria }, cancellationToken).ConfigureAwait(false); - if (result.IsDefault) + if (result == null) { return (false, ImmutableArray.Empty); } @@ -163,12 +164,12 @@ internal static partial class DeclarationFinder return (false, ImmutableArray.Empty); } - var result = await project.Solution.TryRunCodeAnalysisRemoteAsync>( + var result = await project.Solution.TryRunCodeAnalysisRemoteAsync>( RemoteFeatureOptions.SymbolFinderEnabled, nameof(IRemoteSymbolFinder.FindProjectSourceDeclarationsWithPatternAsync), new object[] { project.Id, pattern, criteria }, cancellationToken).ConfigureAwait(false); - if (result.IsDefault) + if (result == null) { return (false, ImmutableArray.Empty); } diff --git a/src/Workspaces/Core/Portable/FindSymbols/IRemoteSymbolFinder.cs b/src/Workspaces/Core/Portable/FindSymbols/IRemoteSymbolFinder.cs index c676d62ab24..464535c989a 100644 --- a/src/Workspaces/Core/Portable/FindSymbols/IRemoteSymbolFinder.cs +++ b/src/Workspaces/Core/Portable/FindSymbols/IRemoteSymbolFinder.cs @@ -14,16 +14,16 @@ internal interface IRemoteSymbolFinder Task FindReferencesAsync(SerializableSymbolAndProjectId symbolAndProjectIdArg, DocumentId[] documentArgs, CancellationToken cancellationToken); Task FindLiteralReferencesAsync(object value, TypeCode typeCode, CancellationToken cancellationToken); - Task> FindAllDeclarationsWithNormalQueryAsync( + Task> FindAllDeclarationsWithNormalQueryAsync( ProjectId projectId, string name, SearchKind searchKind, SymbolFilter criteria, CancellationToken cancellationToken); - Task> FindSolutionSourceDeclarationsWithNormalQueryAsync( + Task> FindSolutionSourceDeclarationsWithNormalQueryAsync( string name, bool ignoreCase, SymbolFilter criteria, CancellationToken cancellationToken); - Task> FindProjectSourceDeclarationsWithNormalQueryAsync( + Task> FindProjectSourceDeclarationsWithNormalQueryAsync( ProjectId projectId, string name, bool ignoreCase, SymbolFilter criteria, CancellationToken cancellationToken); - Task> FindProjectSourceDeclarationsWithPatternAsync( + Task> FindProjectSourceDeclarationsWithPatternAsync( ProjectId projectId, string pattern, SymbolFilter criteria, CancellationToken cancellationToken); } } diff --git a/src/Workspaces/Core/Portable/SymbolSearch/IRemoteSymbolSearchUpdateEngine.cs b/src/Workspaces/Core/Portable/SymbolSearch/IRemoteSymbolSearchUpdateEngine.cs index f784a9b3436..6f7a0a047d9 100644 --- a/src/Workspaces/Core/Portable/SymbolSearch/IRemoteSymbolSearchUpdateEngine.cs +++ b/src/Workspaces/Core/Portable/SymbolSearch/IRemoteSymbolSearchUpdateEngine.cs @@ -11,8 +11,8 @@ internal interface IRemoteSymbolSearchUpdateEngine { Task UpdateContinuouslyAsync(string sourceName, string localSettingsDirectory); - Task> FindPackagesWithTypeAsync(string source, string name, int arity, CancellationToken cancellationToken); - Task> FindPackagesWithAssemblyAsync(string source, string name, CancellationToken cancellationToken); - Task> FindReferenceAssembliesWithTypeAsync(string name, int arity, CancellationToken cancellationToken); + Task> FindPackagesWithTypeAsync(string source, string name, int arity, CancellationToken cancellationToken); + Task> FindPackagesWithAssemblyAsync(string source, string name, CancellationToken cancellationToken); + Task> FindReferenceAssembliesWithTypeAsync(string name, int arity, CancellationToken cancellationToken); } } diff --git a/src/Workspaces/Core/Portable/SymbolSearch/ISymbolSearchService.cs b/src/Workspaces/Core/Portable/SymbolSearch/ISymbolSearchService.cs index 9a7725e331f..c38f1e982ee 100644 --- a/src/Workspaces/Core/Portable/SymbolSearch/ISymbolSearchService.cs +++ b/src/Workspaces/Core/Portable/SymbolSearch/ISymbolSearchService.cs @@ -23,7 +23,7 @@ internal interface ISymbolSearchService : IWorkspaceService /// Implementations should return results in order from best to worst (from their /// perspective). /// - Task> FindPackagesWithTypeAsync( + Task> FindPackagesWithTypeAsync( string source, string name, int arity, CancellationToken cancellationToken); /// @@ -34,7 +34,7 @@ internal interface ISymbolSearchService : IWorkspaceService /// Implementations should return results in order from best to worst (from their /// perspective). /// - Task> FindPackagesWithAssemblyAsync( + Task> FindPackagesWithAssemblyAsync( string source, string assemblyName, CancellationToken cancellationToken); /// @@ -46,7 +46,7 @@ internal interface ISymbolSearchService : IWorkspaceService /// Implementations should return results in order from best to worst (from their /// perspective). /// - Task> FindReferenceAssembliesWithTypeAsync( + Task> FindReferenceAssembliesWithTypeAsync( string name, int arity, CancellationToken cancellationToken); } @@ -64,7 +64,7 @@ protected PackageResult(string packageName, int rank) internal class PackageWithTypeResult : PackageResult { - public readonly IReadOnlyList ContainingNamespaceNames; + public readonly IList ContainingNamespaceNames; public readonly string TypeName; public readonly string Version; @@ -73,7 +73,7 @@ internal class PackageWithTypeResult : PackageResult string typeName, string version, int rank, - IReadOnlyList containingNamespaceNames) + IList containingNamespaceNames) : base(packageName, rank) { TypeName = typeName; @@ -118,14 +118,14 @@ public int CompareTo(PackageWithAssemblyResult other) internal class ReferenceAssemblyWithTypeResult { - public readonly IReadOnlyList ContainingNamespaceNames; + public readonly IList ContainingNamespaceNames; public readonly string AssemblyName; public readonly string TypeName; public ReferenceAssemblyWithTypeResult( string assemblyName, string typeName, - IReadOnlyList containingNamespaceNames) + IList containingNamespaceNames) { AssemblyName = assemblyName; TypeName = typeName; @@ -136,22 +136,22 @@ internal class ReferenceAssemblyWithTypeResult [ExportWorkspaceService(typeof(ISymbolSearchService)), Shared] internal class DefaultSymbolSearchService : ISymbolSearchService { - public Task> FindPackagesWithTypeAsync( + public Task> FindPackagesWithTypeAsync( string source, string name, int arity, CancellationToken cancellationToken) { - return SpecializedTasks.EmptyReadOnlyList(); + return SpecializedTasks.EmptyList(); } - public Task> FindPackagesWithAssemblyAsync( + public Task> FindPackagesWithAssemblyAsync( string source, string assemblyName, CancellationToken cancellationToken) { - return SpecializedTasks.EmptyReadOnlyList(); + return SpecializedTasks.EmptyList(); } - public Task> FindReferenceAssembliesWithTypeAsync( + public Task> FindReferenceAssembliesWithTypeAsync( string name, int arity, CancellationToken cancellationToken) { - return SpecializedTasks.EmptyReadOnlyList(); + return SpecializedTasks.EmptyList(); } } } diff --git a/src/Workspaces/Core/Portable/Utilities/IReadOnlyListExtensions.cs b/src/Workspaces/Core/Portable/Utilities/IReadOnlyListExtensions.cs index 1a4698cc9b5..b15e7de4427 100644 --- a/src/Workspaces/Core/Portable/Utilities/IReadOnlyListExtensions.cs +++ b/src/Workspaces/Core/Portable/Utilities/IReadOnlyListExtensions.cs @@ -1,12 +1,38 @@ -using System.Collections.Generic; +using System.Collections; +using System.Collections.Generic; namespace Microsoft.CodeAnalysis.Utilities { internal static class IReadOnlyListExtensions { + public static IReadOnlyList ToReadOnlyList(this IList list) + { + if (list is IReadOnlyList readOnlyList) + { + return readOnlyList; + } + + return new ReadOnlyList(list); + } + public static T Last(this IReadOnlyList list) { return list[list.Count - 1]; } + + private class ReadOnlyList : IReadOnlyList + { + private readonly IList _list; + + public ReadOnlyList(IList list) + { + _list = list; + } + + public T this[int index] => _list[index]; + public int Count => _list.Count; + public IEnumerator GetEnumerator() => _list.GetEnumerator(); + IEnumerator IEnumerable.GetEnumerator() => _list.GetEnumerator(); + } } } diff --git a/src/Workspaces/Remote/ServiceHub/Services/CodeAnalysisService_AddImport.cs b/src/Workspaces/Remote/ServiceHub/Services/CodeAnalysisService_AddImport.cs index 004088f8b1e..3c5bad58806 100644 --- a/src/Workspaces/Remote/ServiceHub/Services/CodeAnalysisService_AddImport.cs +++ b/src/Workspaces/Remote/ServiceHub/Services/CodeAnalysisService_AddImport.cs @@ -14,9 +14,9 @@ namespace Microsoft.CodeAnalysis.Remote { internal partial class CodeAnalysisService : IRemoteAddImportFeatureService { - public async Task> GetFixesAsync( + public async Task> GetFixesAsync( DocumentId documentId, TextSpan span, string diagnosticId, bool placeSystemNamespaceFirst, - bool searchReferenceAssemblies, IReadOnlyList packageSources, CancellationToken cancellationToken) + bool searchReferenceAssemblies, IList packageSources, CancellationToken cancellationToken) { using (UserOperationBooster.Boost()) { @@ -55,28 +55,28 @@ public SymbolSearchService(CodeAnalysisService codeAnalysisService) this.codeAnalysisService = codeAnalysisService; } - public async Task> FindPackagesWithTypeAsync( + public async Task> FindPackagesWithTypeAsync( string source, string name, int arity, CancellationToken cancellationToken) { - var result = await codeAnalysisService.Rpc.InvokeAsync>( + var result = await codeAnalysisService.Rpc.InvokeAsync>( nameof(FindPackagesWithTypeAsync), source, name, arity).ConfigureAwait(false); return result; } - public async Task> FindPackagesWithAssemblyAsync( + public async Task> FindPackagesWithAssemblyAsync( string source, string assemblyName, CancellationToken cancellationToken) { - var result = await codeAnalysisService.Rpc.InvokeAsync>( + var result = await codeAnalysisService.Rpc.InvokeAsync>( nameof(FindPackagesWithAssemblyAsync), source, assemblyName).ConfigureAwait(false); return result; } - public async Task> FindReferenceAssembliesWithTypeAsync( + public async Task> FindReferenceAssembliesWithTypeAsync( string name, int arity, CancellationToken cancellationToken) { - var result = await codeAnalysisService.Rpc.InvokeAsync>( + var result = await codeAnalysisService.Rpc.InvokeAsync>( nameof(FindReferenceAssembliesWithTypeAsync), name, arity).ConfigureAwait(false); return result; diff --git a/src/Workspaces/Remote/ServiceHub/Services/CodeAnalysisService_DesignerAttributes.cs b/src/Workspaces/Remote/ServiceHub/Services/CodeAnalysisService_DesignerAttributes.cs index 8a49d29bd7f..3aefc8e2ea1 100644 --- a/src/Workspaces/Remote/ServiceHub/Services/CodeAnalysisService_DesignerAttributes.cs +++ b/src/Workspaces/Remote/ServiceHub/Services/CodeAnalysisService_DesignerAttributes.cs @@ -19,7 +19,7 @@ internal partial class CodeAnalysisService : IRemoteDesignerAttributeService /// /// This will be called by ServiceHub/JsonRpc framework /// - public async Task> ScanDesignerAttributesAsync(ProjectId projectId, CancellationToken cancellationToken) + public async Task> ScanDesignerAttributesAsync(ProjectId projectId, CancellationToken cancellationToken) { using (RoslynLogger.LogBlock(FunctionId.CodeAnalysisService_GetDesignerAttributesAsync, projectId.DebugName, cancellationToken)) { @@ -31,7 +31,7 @@ public async Task> ScanDesignerAttr if (data.Count == 0) { - return SpecializedCollections.EmptyReadOnlyList(); + return SpecializedCollections.EmptyList(); } return data.Values.ToList(); diff --git a/src/Workspaces/Remote/ServiceHub/Services/CodeAnalysisService_DocumentHighlights.cs b/src/Workspaces/Remote/ServiceHub/Services/CodeAnalysisService_DocumentHighlights.cs index e8af78b4456..db3147ec915 100644 --- a/src/Workspaces/Remote/ServiceHub/Services/CodeAnalysisService_DocumentHighlights.cs +++ b/src/Workspaces/Remote/ServiceHub/Services/CodeAnalysisService_DocumentHighlights.cs @@ -14,7 +14,7 @@ namespace Microsoft.CodeAnalysis.Remote // root level service for all Roslyn services internal partial class CodeAnalysisService : IRemoteDocumentHighlights { - public async Task> GetDocumentHighlightsAsync( + public async Task> GetDocumentHighlightsAsync( DocumentId documentId, int position, DocumentId[] documentIdsToSearch, CancellationToken cancellationToken) { // NOTE: In projection scenarios, we might get a set of documents to search diff --git a/src/Workspaces/Remote/ServiceHub/Services/CodeAnalysisService_NavigateTo.cs b/src/Workspaces/Remote/ServiceHub/Services/CodeAnalysisService_NavigateTo.cs index 346f1714b25..7ceff52363c 100644 --- a/src/Workspaces/Remote/ServiceHub/Services/CodeAnalysisService_NavigateTo.cs +++ b/src/Workspaces/Remote/ServiceHub/Services/CodeAnalysisService_NavigateTo.cs @@ -10,7 +10,7 @@ namespace Microsoft.CodeAnalysis.Remote { internal partial class CodeAnalysisService : IRemoteNavigateToSearchService { - public async Task> SearchDocumentAsync( + public async Task> SearchDocumentAsync( DocumentId documentId, string searchPattern, CancellationToken cancellationToken) { using (UserOperationBooster.Boost()) @@ -25,7 +25,7 @@ internal partial class CodeAnalysisService : IRemoteNavigateToSearchService } } - public async Task> SearchProjectAsync( + public async Task> SearchProjectAsync( ProjectId projectId, string searchPattern, CancellationToken cancellationToken) { using (UserOperationBooster.Boost()) diff --git a/src/Workspaces/Remote/ServiceHub/Services/CodeAnalysisService_SymbolFinder.cs b/src/Workspaces/Remote/ServiceHub/Services/CodeAnalysisService_SymbolFinder.cs index 588a3498312..740060c72ea 100644 --- a/src/Workspaces/Remote/ServiceHub/Services/CodeAnalysisService_SymbolFinder.cs +++ b/src/Workspaces/Remote/ServiceHub/Services/CodeAnalysisService_SymbolFinder.cs @@ -60,7 +60,7 @@ public async Task FindLiteralReferencesAsync(object value, TypeCode typeCode, Ca } } - public async Task> FindAllDeclarationsWithNormalQueryAsync( + public async Task> FindAllDeclarationsWithNormalQueryAsync( ProjectId projectId, string name, SearchKind searchKind, SymbolFilter criteria, CancellationToken cancellationToken) { using (UserOperationBooster.Boost()) @@ -78,7 +78,7 @@ public async Task FindLiteralReferencesAsync(object value, TypeCode typeCode, Ca } } - public async Task> FindSolutionSourceDeclarationsWithNormalQueryAsync( + public async Task> FindSolutionSourceDeclarationsWithNormalQueryAsync( string name, bool ignoreCase, SymbolFilter criteria, CancellationToken cancellationToken) { using (UserOperationBooster.Boost()) @@ -91,7 +91,7 @@ public async Task FindLiteralReferencesAsync(object value, TypeCode typeCode, Ca } } - public async Task> FindProjectSourceDeclarationsWithNormalQueryAsync( + public async Task> FindProjectSourceDeclarationsWithNormalQueryAsync( ProjectId projectId, string name, bool ignoreCase, SymbolFilter criteria, CancellationToken cancellationToken) { using (UserOperationBooster.Boost()) @@ -106,7 +106,7 @@ public async Task FindLiteralReferencesAsync(object value, TypeCode typeCode, Ca } } - public async Task> FindProjectSourceDeclarationsWithPatternAsync( + public async Task> FindProjectSourceDeclarationsWithPatternAsync( ProjectId projectId, string pattern, SymbolFilter criteria, CancellationToken cancellationToken) { using (UserOperationBooster.Boost()) diff --git a/src/Workspaces/Remote/ServiceHub/Services/CodeAnalysisService_TodoComments.cs b/src/Workspaces/Remote/ServiceHub/Services/CodeAnalysisService_TodoComments.cs index ad4323e5a92..4dec373eb20 100644 --- a/src/Workspaces/Remote/ServiceHub/Services/CodeAnalysisService_TodoComments.cs +++ b/src/Workspaces/Remote/ServiceHub/Services/CodeAnalysisService_TodoComments.cs @@ -23,7 +23,7 @@ internal partial class CodeAnalysisService : IRemoteTodoCommentService /// /// This will be called by ServiceHub/JsonRpc framework /// - public async Task> GetTodoCommentsAsync(PinnedSolutionInfo solutionInfo, DocumentId documentId, IReadOnlyList tokens, CancellationToken cancellationToken) + public async Task> GetTodoCommentsAsync(PinnedSolutionInfo solutionInfo, DocumentId documentId, IList tokens, CancellationToken cancellationToken) { using (RoslynLogger.LogBlock(FunctionId.CodeAnalysisService_GetTodoCommentsAsync, documentId.ProjectId.DebugName, cancellationToken)) { @@ -37,7 +37,7 @@ public async Task> GetTodoCommentsAsync(PinnedSolutio return await service.GetTodoCommentsAsync(document, tokens, cancellationToken).ConfigureAwait(false); } - return SpecializedCollections.EmptyReadOnlyList(); + return SpecializedCollections.EmptyList(); } } } diff --git a/src/Workspaces/Remote/ServiceHub/Services/RemoteSymbolSearchUpdateEngine.cs b/src/Workspaces/Remote/ServiceHub/Services/RemoteSymbolSearchUpdateEngine.cs index 9d94411133f..d46a9e47c43 100644 --- a/src/Workspaces/Remote/ServiceHub/Services/RemoteSymbolSearchUpdateEngine.cs +++ b/src/Workspaces/Remote/ServiceHub/Services/RemoteSymbolSearchUpdateEngine.cs @@ -29,7 +29,7 @@ public Task UpdateContinuouslyAsync(string sourceName, string localSettingsDirec return _updateEngine.UpdateContinuouslyAsync(sourceName, localSettingsDirectory); } - public async Task> FindPackagesWithTypeAsync(string source, string name, int arity, CancellationToken cancellationToken) + public async Task> FindPackagesWithTypeAsync(string source, string name, int arity, CancellationToken cancellationToken) { var results = await _updateEngine.FindPackagesWithTypeAsync( source, name, arity, cancellationToken).ConfigureAwait(false); @@ -37,7 +37,7 @@ public async Task> FindPackagesWithTypeAsyn return results; } - public async Task> FindPackagesWithAssemblyAsync(string source, string assemblyName, CancellationToken cancellationToken) + public async Task> FindPackagesWithAssemblyAsync(string source, string assemblyName, CancellationToken cancellationToken) { var results = await _updateEngine.FindPackagesWithAssemblyAsync( source, assemblyName, cancellationToken).ConfigureAwait(false); @@ -45,7 +45,7 @@ public async Task> FindPackagesWithAsse return results; } - public async Task> FindReferenceAssembliesWithTypeAsync(string name, int arity, CancellationToken cancellationToken) + public async Task> FindReferenceAssembliesWithTypeAsync(string name, int arity, CancellationToken cancellationToken) { var results = await _updateEngine.FindReferenceAssembliesWithTypeAsync( name, arity, cancellationToken).ConfigureAwait(false); -- GitLab