From c78dcf79bd39df4c4812142803cd94edef5de042 Mon Sep 17 00:00:00 2001 From: CyrusNajmabadi Date: Tue, 27 Sep 2016 17:09:12 -0700 Subject: [PATCH 1/8] Reduce the number of intermediary IEnumerables we create while building indices. --- ...actAddImportCodeFixProvider.SearchScope.cs | 14 +-- .../FindSymbols/SymbolFinder_Declarations.cs | 38 +++++--- .../FindSymbols/SymbolTree/SymbolTreeInfo.cs | 92 +++++++++++-------- 3 files changed, 84 insertions(+), 60 deletions(-) diff --git a/src/Features/Core/Portable/CodeFixes/AddImport/AbstractAddImportCodeFixProvider.SearchScope.cs b/src/Features/Core/Portable/CodeFixes/AddImport/AbstractAddImportCodeFixProvider.SearchScope.cs index 928b8c6a0f055..567eb98153fd9 100644 --- a/src/Features/Core/Portable/CodeFixes/AddImport/AbstractAddImportCodeFixProvider.SearchScope.cs +++ b/src/Features/Core/Portable/CodeFixes/AddImport/AbstractAddImportCodeFixProvider.SearchScope.cs @@ -2,6 +2,7 @@ using System.Collections.Concurrent; using System.Collections.Generic; +using System.Collections.Immutable; using System.Diagnostics; using System.Linq; using System.Threading; @@ -34,7 +35,7 @@ protected SearchScope(AbstractAddImportCodeFixProvider provid CancellationToken = cancellationToken; } - protected abstract Task> FindDeclarationsAsync(string name, SymbolFilter filter, SearchQuery query); + protected abstract Task> FindDeclarationsAsync(string name, SymbolFilter filter, SearchQuery query); public abstract SymbolReference CreateReference(SymbolResult symbol) where T : INamespaceOrTypeSymbol; public async Task>> FindDeclarationsAsync( @@ -109,7 +110,7 @@ public AllSymbolsProjectSearchScope( { } - protected override Task> FindDeclarationsAsync( + protected override Task> FindDeclarationsAsync( string name, SymbolFilter filter, SearchQuery searchQuery) { return SymbolFinder.FindDeclarationsAsync(_project, searchQuery, filter, CancellationToken); @@ -133,14 +134,15 @@ public SourceSymbolsProjectSearchScope( _projectToAssembly = projectToAssembly; } - protected override async Task> FindDeclarationsAsync(string name, SymbolFilter filter, SearchQuery searchQuery) + protected override async Task> FindDeclarationsAsync( + string name, SymbolFilter filter, SearchQuery searchQuery) { var service = _project.Solution.Workspace.Services.GetService(); var info = await service.TryGetSourceSymbolTreeInfoAsync(_project, CancellationToken).ConfigureAwait(false); if (info == null) { // Looks like there was nothing in the cache. Return no results for now. - return SpecializedCollections.EmptyEnumerable(); + return ImmutableArray.Empty; } // Don't create the assembly until it is actually needed by the SymbolTreeInfo.FindAsync @@ -190,14 +192,14 @@ public override SymbolReference CreateReference(SymbolResult searchResult) _metadataReference); } - protected override async Task> FindDeclarationsAsync( + protected override async Task> FindDeclarationsAsync( string name, SymbolFilter filter, SearchQuery searchQuery) { var service = _solution.Workspace.Services.GetService(); var info = await service.TryGetMetadataSymbolTreeInfoAsync(_solution, _metadataReference, CancellationToken).ConfigureAwait(false); if (info == null) { - return SpecializedCollections.EmptyEnumerable(); + return ImmutableArray.Empty; } return await info.FindAsync(searchQuery, _assembly, filter, CancellationToken).ConfigureAwait(false); diff --git a/src/Workspaces/Core/Portable/FindSymbols/SymbolFinder_Declarations.cs b/src/Workspaces/Core/Portable/FindSymbols/SymbolFinder_Declarations.cs index e65ae5ed11730..e5a0a6ee85293 100644 --- a/src/Workspaces/Core/Portable/FindSymbols/SymbolFinder_Declarations.cs +++ b/src/Workspaces/Core/Portable/FindSymbols/SymbolFinder_Declarations.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; +using System.Collections.Immutable; using System.Diagnostics; using System.Linq; using System.Threading; @@ -117,7 +118,7 @@ public static partial class SymbolFinder /// /// Find the declared symbols from either source, referenced projects or metadata assemblies with the specified name. /// - public static Task> FindDeclarationsAsync( + public static async Task> FindDeclarationsAsync( Project project, string name, bool ignoreCase, CancellationToken cancellationToken = default(CancellationToken)) { if (name == null) @@ -127,16 +128,17 @@ public static Task> FindDeclarationsAsync( if (string.IsNullOrWhiteSpace(name)) { - return SpecializedTasks.EmptyEnumerable(); + return ImmutableArray.Empty; } - return FindDeclarationsAsync(project, SearchQuery.Create(name, ignoreCase), SymbolFilter.All, cancellationToken: cancellationToken); + return await FindDeclarationsAsync( + project, SearchQuery.Create(name, ignoreCase), SymbolFilter.All, cancellationToken: cancellationToken).ConfigureAwait(false); } /// /// Find the declared symbols from either source, referenced projects or metadata assemblies with the specified name. /// - public static Task> FindDeclarationsAsync( + public static async Task> FindDeclarationsAsync( Project project, string name, bool ignoreCase, SymbolFilter filter, CancellationToken cancellationToken = default(CancellationToken)) { if (name == null) @@ -146,13 +148,14 @@ public static Task> FindDeclarationsAsync( if (string.IsNullOrWhiteSpace(name)) { - return SpecializedTasks.EmptyEnumerable(); + return ImmutableArray.Empty; } - return FindDeclarationsAsync(project, SearchQuery.Create(name, ignoreCase), filter, cancellationToken: cancellationToken); + return await FindDeclarationsAsync( + project, SearchQuery.Create(name, ignoreCase), filter, cancellationToken: cancellationToken).ConfigureAwait(false); } - internal static Task> FindDeclarationsAsync( + internal static Task> FindDeclarationsAsync( Project project, SearchQuery query, SymbolFilter filter, CancellationToken cancellationToken) { // All entrypoints to this function are Find functions that are only searching @@ -166,7 +169,7 @@ internal static Task> FindDeclarationsAsync( if (query.Name != null && string.IsNullOrWhiteSpace(query.Name)) { - return SpecializedTasks.EmptyEnumerable(); + return SpecializedTasks.EmptyImmutableArray(); } using (Logger.LogBlock(FunctionId.SymbolFinder_FindDeclarationsAsync, cancellationToken)) @@ -175,7 +178,7 @@ internal static Task> FindDeclarationsAsync( } } - private static async Task> FindDeclarationsAsyncImpl( + private static async Task> FindDeclarationsAsyncImpl( Project project, SearchQuery query, SymbolFilter criteria, CancellationToken cancellationToken) { // All entrypoints to this function are Find functions that are only searching @@ -216,20 +219,23 @@ private static string GetMetadataReferenceFilePath(MetadataReference metadataRef /// /// Makes certain all namespace symbols returned by API are from the compilation. /// - private static IEnumerable TranslateNamespaces(List symbols, Compilation compilation) + private static ImmutableArray TranslateNamespaces(List symbols, Compilation compilation) { + var result = ArrayBuilder.GetInstance(); foreach (var symbol in symbols) { var ns = symbol as INamespaceSymbol; if (ns != null) { - yield return compilation.GetCompilationNamespace(ns); + result.Add(compilation.GetCompilationNamespace(ns)); } else { - yield return symbol; + result.Add(symbol); } } + + return result.ToImmutableAndFree(); } private static async Task AddDeclarationsAsync( @@ -479,8 +485,10 @@ internal static async Task> FindSourceDeclarationsAsync(Pro } } - internal static IEnumerable FilterByCriteria(IEnumerable symbols, SymbolFilter criteria) + internal static ImmutableArray FilterByCriteria( + IEnumerable symbols, SymbolFilter criteria) { + var result = ArrayBuilder.GetInstance(); foreach (var symbol in symbols) { if (symbol.IsImplicitlyDeclared || symbol.IsAccessor()) @@ -490,9 +498,11 @@ internal static IEnumerable FilterByCriteria(IEnumerable symbo if (MeetCriteria(symbol, criteria)) { - yield return symbol; + result.Add(symbol); } } + + return result.ToImmutableAndFree(); } private static bool MeetCriteria(ISymbol symbol, SymbolFilter filter) diff --git a/src/Workspaces/Core/Portable/FindSymbols/SymbolTree/SymbolTreeInfo.cs b/src/Workspaces/Core/Portable/FindSymbols/SymbolTree/SymbolTreeInfo.cs index 0174ef1adaca7..4d1933b228ea6 100644 --- a/src/Workspaces/Core/Portable/FindSymbols/SymbolTree/SymbolTreeInfo.cs +++ b/src/Workspaces/Core/Portable/FindSymbols/SymbolTree/SymbolTreeInfo.cs @@ -114,7 +114,7 @@ private SymbolTreeInfo( _spellCheckerTask = spellCheckerTask; } - public Task> FindAsync( + public Task> FindAsync( SearchQuery query, IAssemblySymbol assembly, SymbolFilter filter, CancellationToken cancellationToken) { // All entrypoints to this function are Find functions that are only searching @@ -124,7 +124,7 @@ public Task> FindAsync( return this.FindAsync(query, new AsyncLazy(assembly), filter, cancellationToken); } - public async Task> FindAsync( + public async Task> FindAsync( SearchQuery query, AsyncLazy lazyAssembly, SymbolFilter filter, CancellationToken cancellationToken) { // All entrypoints to this function are Find functions that are only searching @@ -136,7 +136,7 @@ await FindAsyncWorker(query, lazyAssembly, cancellationToken).ConfigureAwait(fal filter); } - private Task> FindAsyncWorker( + private Task> FindAsyncWorker( SearchQuery query, AsyncLazy lazyAssembly, CancellationToken cancellationToken) { // All entrypoints to this function are Find functions that are only searching @@ -161,18 +161,18 @@ private Task> FindAsyncWorker( /// /// Finds symbols in this assembly that match the provided name in a fuzzy manner. /// - private async Task> FuzzyFindAsync( + private async Task> FuzzyFindAsync( AsyncLazy lazyAssembly, string name, CancellationToken cancellationToken) { if (_spellCheckerTask.Status != TaskStatus.RanToCompletion) { // Spell checker isn't ready. Just return immediately. - return SpecializedCollections.EmptyEnumerable(); + return ImmutableArray.Empty; } var spellChecker = _spellCheckerTask.Result; var similarNames = spellChecker.FindSimilarWords(name, substringsAreSimilar: false); - var result = new List(); + var result = ArrayBuilder.GetInstance(); foreach (var similarName in similarNames) { @@ -180,20 +180,20 @@ private async Task> FuzzyFindAsync( result.AddRange(symbols); } - return result; + return result.ToImmutableAndFree(); } /// /// Get all symbols that have a name matching the specified name. /// - private async Task> FindAsync( + private async Task> FindAsync( AsyncLazy lazyAssembly, string name, bool ignoreCase, CancellationToken cancellationToken) { var comparer = GetComparer(ignoreCase); - var result = new List(); + var results = ArrayBuilder.GetInstance(); IAssemblySymbol assemblySymbol = null; foreach (var node in FindNodeIndices(name, comparer)) @@ -201,10 +201,10 @@ private async Task> FindAsync( cancellationToken.ThrowIfCancellationRequested(); assemblySymbol = assemblySymbol ?? await lazyAssembly.GetValueAsync(cancellationToken).ConfigureAwait(false); - result.AddRange(Bind(node, assemblySymbol.GlobalNamespace, cancellationToken)); + Bind(node, assemblySymbol.GlobalNamespace, results, cancellationToken); } - return result; + return results.ToImmutableAndFree(); ; } private static StringSliceComparer GetComparer(bool ignoreCase) @@ -409,26 +409,8 @@ private static int CompareNodes( #region Binding // returns all the symbols in the container corresponding to the node - private IEnumerable Bind( - int index, INamespaceOrTypeSymbol rootContainer, CancellationToken cancellationToken) - { - cancellationToken.ThrowIfCancellationRequested(); - - using (var symbols = SharedPools.Default>().GetPooledObject()) - { - BindWorker(index, rootContainer, symbols.Object, cancellationToken); - - foreach (var symbol in symbols.Object) - { - cancellationToken.ThrowIfCancellationRequested(); - yield return symbol; - } - } - } - - // returns all the symbols in the container corresponding to the node - private void BindWorker( - int index, INamespaceOrTypeSymbol rootContainer, List results, CancellationToken cancellationToken) + private void Bind( + int index, INamespaceOrTypeSymbol rootContainer, ArrayBuilder results, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); @@ -444,17 +426,26 @@ private void BindWorker( } else { - using (var containerSymbols = SharedPools.Default>().GetPooledObject()) + var containerSymbols = ArrayBuilder.GetInstance(); + try { - BindWorker(node.ParentIndex, rootContainer, containerSymbols.Object, cancellationToken); + Bind(node.ParentIndex, rootContainer, containerSymbols, cancellationToken); - foreach (var containerSymbol in containerSymbols.Object.OfType()) + foreach (var containerSymbol in containerSymbols) { cancellationToken.ThrowIfCancellationRequested(); - results.AddRange(containerSymbol.GetMembers(GetName(node))); + var nsOrType = containerSymbol as INamespaceOrTypeSymbol; + if (nsOrType != null) + { + results.AddRange(nsOrType.GetMembers(GetName(node))); + } } } + finally + { + containerSymbols.Free(); + } } } @@ -541,16 +532,37 @@ private OrderPreservingMultiDictionary CreateIndexBasedInheritanceMap( return result; } - public IEnumerable GetDerivedMetadataTypes( + public ImmutableArray GetDerivedMetadataTypes( string baseTypeName, Compilation compilation, CancellationToken cancellationToken) { var baseTypeNameIndex = BinarySearch(baseTypeName); var derivedTypeIndices = _inheritanceMap[baseTypeNameIndex]; - return from derivedTypeIndex in derivedTypeIndices - from symbol in Bind(derivedTypeIndex, compilation.GlobalNamespace, cancellationToken) - let namedType = symbol as INamedTypeSymbol - select namedType; + var builder = ArrayBuilder.GetInstance(); + + foreach (var derivedTypeIndex in derivedTypeIndices) + { + var tempBuilder = ArrayBuilder.GetInstance(); + try + { + Bind(derivedTypeIndex, compilation.GlobalNamespace, tempBuilder, cancellationToken); + foreach (var symbol in tempBuilder) + { + var namedType = symbol as INamedTypeSymbol; + if (namedType != null) + { + builder.Add(namedType); + } + } + + } + finally + { + tempBuilder.Free(); + } + } + + return builder.ToImmutableAndFree(); } } } \ No newline at end of file From 165583ab8df4ac356aaba754e4f28053f35351f3 Mon Sep 17 00:00:00 2001 From: CyrusNajmabadi Date: Tue, 27 Sep 2016 17:50:15 -0700 Subject: [PATCH 2/8] Remove blank line. --- .../Core/Portable/FindSymbols/SymbolTree/SymbolTreeInfo.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Workspaces/Core/Portable/FindSymbols/SymbolTree/SymbolTreeInfo.cs b/src/Workspaces/Core/Portable/FindSymbols/SymbolTree/SymbolTreeInfo.cs index 4d1933b228ea6..26051105c8c37 100644 --- a/src/Workspaces/Core/Portable/FindSymbols/SymbolTree/SymbolTreeInfo.cs +++ b/src/Workspaces/Core/Portable/FindSymbols/SymbolTree/SymbolTreeInfo.cs @@ -554,7 +554,6 @@ public ImmutableArray GetDerivedMetadataTypes( builder.Add(namedType); } } - } finally { From 5b5ccba31ef60f020c5e6933e85fad48c41e0484 Mon Sep 17 00:00:00 2001 From: CyrusNajmabadi Date: Tue, 27 Sep 2016 18:02:01 -0700 Subject: [PATCH 3/8] Reduce more allocations for common paths. --- .../FindSymbols/SymbolFinder_Declarations.cs | 118 +++++++++++------- 1 file changed, 74 insertions(+), 44 deletions(-) diff --git a/src/Workspaces/Core/Portable/FindSymbols/SymbolFinder_Declarations.cs b/src/Workspaces/Core/Portable/FindSymbols/SymbolFinder_Declarations.cs index e5a0a6ee85293..e41efc6d03780 100644 --- a/src/Workspaces/Core/Portable/FindSymbols/SymbolFinder_Declarations.cs +++ b/src/Workspaces/Core/Portable/FindSymbols/SymbolFinder_Declarations.cs @@ -187,7 +187,7 @@ private static async Task> FindDeclarationsAsyncImpl( var compilation = await project.GetCompilationAsync(cancellationToken).ConfigureAwait(false); - var list = new List(); + var list = ArrayBuilder.GetInstance(); // get declarations from the compilation's assembly await AddDeclarationsAsync(project, query, criteria, list, cancellationToken).ConfigureAwait(false); @@ -208,7 +208,7 @@ await AddDeclarationsAsync( } } - return TranslateNamespaces(list, compilation); + return TranslateNamespaces(list.ToImmutableAndFree(), compilation); } private static string GetMetadataReferenceFilePath(MetadataReference metadataReference) @@ -219,70 +219,92 @@ private static string GetMetadataReferenceFilePath(MetadataReference metadataRef /// /// Makes certain all namespace symbols returned by API are from the compilation. /// - private static ImmutableArray TranslateNamespaces(List symbols, Compilation compilation) + private static ImmutableArray TranslateNamespaces( + ImmutableArray symbols, Compilation compilation) { - var result = ArrayBuilder.GetInstance(); + var builder = ArrayBuilder.GetInstance(); foreach (var symbol in symbols) { var ns = symbol as INamespaceSymbol; if (ns != null) { - result.Add(compilation.GetCompilationNamespace(ns)); + builder.Add(compilation.GetCompilationNamespace(ns)); } else { - result.Add(symbol); + builder.Add(symbol); } } - return result.ToImmutableAndFree(); + var result = builder.Count == symbols.Length + ? symbols + : builder.ToImmutable(); + + builder.Free(); + + return result; } - private static async Task AddDeclarationsAsync( - Project project, SearchQuery query, SymbolFilter filter, List list, CancellationToken cancellationToken) + private static Task AddDeclarationsAsync( + Project project, SearchQuery query, SymbolFilter filter, + ArrayBuilder list, CancellationToken cancellationToken) { - await AddDeclarationsAsync( + return AddDeclarationsAsync( project, query, filter, list, startingCompilation: null, startingAssembly: null, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: cancellationToken); } private static async Task AddDeclarationsAsync( Project project, SearchQuery query, SymbolFilter filter, - List list, + ArrayBuilder list, Compilation startingCompilation, IAssemblySymbol startingAssembly, CancellationToken cancellationToken) { using (Logger.LogBlock(FunctionId.SymbolFinder_Project_AddDeclarationsAsync, cancellationToken)) - using (var set = SharedPools.Default>().GetPooledObject()) { if (!await project.ContainsSymbolsWithNameAsync(query.GetPredicate(), filter, cancellationToken).ConfigureAwait(false)) { return; } - var compilation = await project.GetCompilationAsync(cancellationToken).ConfigureAwait(false); - if (startingCompilation != null && startingAssembly != null && compilation.Assembly != startingAssembly) - { - // Return symbols from skeleton assembly in this case so that symbols have the same language as startingCompilation. - list.AddRange( - FilterByCriteria(compilation.GetSymbolsWithName(query.GetPredicate(), filter, cancellationToken), filter) - .Select(s => s.GetSymbolKey().Resolve(startingCompilation, cancellationToken: cancellationToken).Symbol).WhereNotNull()); - } - else - { - list.AddRange(FilterByCriteria(compilation.GetSymbolsWithName(query.GetPredicate(), filter, cancellationToken), filter)); - } + var unfilteredSymbols = await GetUnfilteredSymbolsAsync( + project, query, filter, startingCompilation, startingAssembly, cancellationToken).ConfigureAwait(false); + list.AddRange(FilterByCriteria(unfilteredSymbols, filter)); + } + } + + private static async Task> GetUnfilteredSymbolsAsync( + Project project, + SearchQuery query, + SymbolFilter filter, + Compilation startingCompilation, + IAssemblySymbol startingAssembly, + CancellationToken cancellationToken) + { + var compilation = await project.GetCompilationAsync(cancellationToken).ConfigureAwait(false); + if (startingCompilation != null && startingAssembly != null && compilation.Assembly != startingAssembly) + { + // Return symbols from skeleton assembly in this case so that symbols have the same language as startingCompilation. + return compilation.GetSymbolsWithName(query.GetPredicate(), filter, cancellationToken) + .Select(s => s.GetSymbolKey().Resolve(startingCompilation, cancellationToken: cancellationToken).Symbol) + .WhereNotNull() + .ToImmutableArray(); + } + else + { + return compilation.GetSymbolsWithName(query.GetPredicate(), filter, cancellationToken) + .ToImmutableArray(); } } private static async Task AddDeclarationsAsync( Solution solution, IAssemblySymbol assembly, PortableExecutableReference referenceOpt, - SearchQuery query, SymbolFilter filter, List list, CancellationToken cancellationToken) + SearchQuery query, SymbolFilter filter, ArrayBuilder list, CancellationToken cancellationToken) { // All entrypoints to this function are Find functions that are only searching // for specific strings (i.e. they never do a custom search). @@ -367,7 +389,8 @@ private static async Task> FindSourceDeclarationsAsyncImpl( /// /// Find the symbols for declarations made in source with the specified name. /// - public static Task> FindSourceDeclarationsAsync(Project project, string name, bool ignoreCase, SymbolFilter filter, CancellationToken cancellationToken = default(CancellationToken)) + public static async Task> FindSourceDeclarationsAsync( + Project project, string name, bool ignoreCase, SymbolFilter filter, CancellationToken cancellationToken = default(CancellationToken)) { if (project == null) { @@ -381,21 +404,22 @@ private static async Task> FindSourceDeclarationsAsyncImpl( if (string.IsNullOrWhiteSpace(name)) { - return SpecializedTasks.EmptyEnumerable(); + return ImmutableArray.Empty; } using (Logger.LogBlock(FunctionId.SymbolFinder_Project_Name_FindSourceDeclarationsAsync, cancellationToken)) { - return FindSourceDeclarationsAsyncImpl(project, SearchQuery.Create(name, ignoreCase), filter, cancellationToken); + return await FindSourceDeclarationsAsyncImpl( + project, SearchQuery.Create(name, ignoreCase), filter, cancellationToken).ConfigureAwait(false); } } - private static async Task> FindSourceDeclarationsAsyncImpl( + private static async Task> FindSourceDeclarationsAsyncImpl( Project project, SearchQuery query, SymbolFilter filter, CancellationToken cancellationToken) { - var list = new List(); + var list = ArrayBuilder.GetInstance(); await AddDeclarationsAsync(project, query, filter, list, cancellationToken).ConfigureAwait(false); - return list; + return list.ToImmutableAndFree(); } /// @@ -452,13 +476,15 @@ internal static async Task> FindSourceDeclarationsAsync(Sol /// /// Find the symbols for declarations made in source with a matching name. /// - public static Task> FindSourceDeclarationsAsync( + public static async Task> FindSourceDeclarationsAsync( Project project, Func predicate, SymbolFilter filter, CancellationToken cancellationToken = default(CancellationToken)) { - return FindSourceDeclarationsAsync(project, SearchQuery.CreateCustom(predicate), filter, cancellationToken); + return await FindSourceDeclarationsAsync( + project, SearchQuery.CreateCustom(predicate), filter, cancellationToken).ConfigureAwait(false); } - internal static async Task> FindSourceDeclarationsAsync(Project project, SearchQuery query, SymbolFilter filter, CancellationToken cancellationToken) + internal static async Task> FindSourceDeclarationsAsync( + Project project, SearchQuery query, SymbolFilter filter, CancellationToken cancellationToken) { if (project == null) { @@ -467,28 +493,27 @@ internal static async Task> FindSourceDeclarationsAsync(Pro if (query.Name != null && string.IsNullOrWhiteSpace(query.Name)) { - return SpecializedCollections.EmptyEnumerable(); + return ImmutableArray.Empty; } using (Logger.LogBlock(FunctionId.SymbolFinder_Project_Predicate_FindSourceDeclarationsAsync, cancellationToken)) { - var result = new List(); if (!await project.ContainsSymbolsWithNameAsync(query.GetPredicate(), filter, cancellationToken).ConfigureAwait(false)) { - return result; + return ImmutableArray.Empty; } var compilation = await project.GetCompilationAsync(cancellationToken).ConfigureAwait(false); - result.AddRange(FilterByCriteria(compilation.GetSymbolsWithName(query.GetPredicate(), filter, cancellationToken), filter)); - return result; + var unfiltered = compilation.GetSymbolsWithName(query.GetPredicate(), filter, cancellationToken).ToImmutableArray(); + return FilterByCriteria(unfiltered, filter); } } internal static ImmutableArray FilterByCriteria( - IEnumerable symbols, SymbolFilter criteria) + ImmutableArray symbols, SymbolFilter criteria) { - var result = ArrayBuilder.GetInstance(); + var builder = ArrayBuilder.GetInstance(); foreach (var symbol in symbols) { if (symbol.IsImplicitlyDeclared || symbol.IsAccessor()) @@ -498,11 +523,16 @@ internal static ImmutableArray FilterByCriteria( if (MeetCriteria(symbol, criteria)) { - result.Add(symbol); + builder.Add(symbol); } } - return result.ToImmutableAndFree(); + var result = builder.Count == symbols.Length + ? symbols + : builder.ToImmutable(); + + builder.Free(); + return result; } private static bool MeetCriteria(ISymbol symbol, SymbolFilter filter) From 10db28d23bbbf180d42dc3e2f9f2862e2be70a0f Mon Sep 17 00:00:00 2001 From: CyrusNajmabadi Date: Tue, 27 Sep 2016 18:05:35 -0700 Subject: [PATCH 4/8] Prevent boxing. --- .../Core/Portable/FindSymbols/SymbolFinder_Declarations.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Workspaces/Core/Portable/FindSymbols/SymbolFinder_Declarations.cs b/src/Workspaces/Core/Portable/FindSymbols/SymbolFinder_Declarations.cs index e41efc6d03780..1811ae8916ffd 100644 --- a/src/Workspaces/Core/Portable/FindSymbols/SymbolFinder_Declarations.cs +++ b/src/Workspaces/Core/Portable/FindSymbols/SymbolFinder_Declarations.cs @@ -128,7 +128,7 @@ public static async Task> FindDeclarationsAsync( if (string.IsNullOrWhiteSpace(name)) { - return ImmutableArray.Empty; + return SpecializedCollections.EmptyEnumerable(); } return await FindDeclarationsAsync( @@ -148,7 +148,7 @@ public static async Task> FindDeclarationsAsync( if (string.IsNullOrWhiteSpace(name)) { - return ImmutableArray.Empty; + return SpecializedCollections.EmptyEnumerable(); } return await FindDeclarationsAsync( @@ -404,7 +404,7 @@ public static async Task> FindSourceDeclarationsAsync( if (string.IsNullOrWhiteSpace(name)) { - return ImmutableArray.Empty; + return SpecializedCollections.EmptyEnumerable(); } using (Logger.LogBlock(FunctionId.SymbolFinder_Project_Name_FindSourceDeclarationsAsync, cancellationToken)) From 1166fda9a7233c9236da0c227ae43583177db7de Mon Sep 17 00:00:00 2001 From: CyrusNajmabadi Date: Tue, 27 Sep 2016 20:01:26 -0700 Subject: [PATCH 5/8] Fix test. --- src/Workspaces/CoreTest/FindAllDeclarationsTests.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Workspaces/CoreTest/FindAllDeclarationsTests.cs b/src/Workspaces/CoreTest/FindAllDeclarationsTests.cs index b41ed9c567755..2f3e087ce1ebf 100644 --- a/src/Workspaces/CoreTest/FindAllDeclarationsTests.cs +++ b/src/Workspaces/CoreTest/FindAllDeclarationsTests.cs @@ -454,12 +454,12 @@ public static void FindSourceDeclarationsAsync_Project_Func_Test_NullProject() } [Fact] - public static void FindSourceDeclarationsAsync_Project_Func_Test_NullPredicate() + public async Task FindSourceDeclarationsAsync_Project_Func_Test_NullPredicate() { - Assert.Throws(() => + await Assert.ThrowsAsync(async () => { var project = GetProject(WorkspaceKind.SingleClass); - var declarations = SymbolFinder.FindSourceDeclarationsAsync(project, null).Result; + var declarations = await SymbolFinder.FindSourceDeclarationsAsync(project, null); }); } From 73c97763b519417081afb8b58059190ac509d8be Mon Sep 17 00:00:00 2001 From: CyrusNajmabadi Date: Tue, 27 Sep 2016 20:04:34 -0700 Subject: [PATCH 6/8] Simplify all tests. --- .../CoreTest/FindAllDeclarationsTests.cs | 94 ++++++------------- 1 file changed, 27 insertions(+), 67 deletions(-) diff --git a/src/Workspaces/CoreTest/FindAllDeclarationsTests.cs b/src/Workspaces/CoreTest/FindAllDeclarationsTests.cs index 2f3e087ce1ebf..6385432a85f68 100644 --- a/src/Workspaces/CoreTest/FindAllDeclarationsTests.cs +++ b/src/Workspaces/CoreTest/FindAllDeclarationsTests.cs @@ -380,22 +380,14 @@ await Assert.ThrowsAsync(async () => } [Fact] - public static void FindSourceDeclarationsAsync_Solution_Test_Cancellation() + public async Task FindSourceDeclarationsAsync_Solution_Test_Cancellation() { - Assert.Throws(() => + await Assert.ThrowsAsync(async () => { - try - { - var cts = new CancellationTokenSource(); - var solution = GetSolution(WorkspaceKind.SingleClass); - cts.Cancel(); - var declarations = SymbolFinder.FindSourceDeclarationsAsync(solution, "Test", true, SymbolFilter.All, cts.Token).Result; - } - catch (AggregateException ex) - { - VerifyInnerExceptionIsType(ex); - throw; - } + var cts = new CancellationTokenSource(); + var solution = GetSolution(WorkspaceKind.SingleClass); + cts.Cancel(); + var declarations = await SymbolFinder.FindSourceDeclarationsAsync(solution, "Test", true, SymbolFilter.All, cts.Token); }); } @@ -437,19 +429,11 @@ public static async Task FindSourceDeclarationsAsync_Project_Func_Test_AlwaysFal } [Fact] - public static void FindSourceDeclarationsAsync_Project_Func_Test_NullProject() + public async Task FindSourceDeclarationsAsync_Project_Func_Test_NullProject() { - Assert.Throws(() => + await Assert.ThrowsAsync(async () => { - try - { - var declarations = SymbolFinder.FindSourceDeclarationsAsync((Project)null, str => str.Contains("Test")).Result; - } - catch (AggregateException ex) - { - VerifyInnerExceptionArgumentNull(ex, "project"); - throw; - } + var declarations = await SymbolFinder.FindSourceDeclarationsAsync((Project)null, str => str.Contains("Test")); }); } @@ -464,22 +448,14 @@ await Assert.ThrowsAsync(async () => } [Fact] - public static void FindSourceDeclarationsAsync_Project_Func_Test_Cancellation() + public async Task FindSourceDeclarationsAsync_Project_Func_Test_Cancellation() { - Assert.Throws(() => + await Assert.ThrowsAsync(async () => { - try - { - var cts = new CancellationTokenSource(); - var project = GetProject(WorkspaceKind.SingleClass); - cts.Cancel(); - var declarations = SymbolFinder.FindSourceDeclarationsAsync(project, str => str.Contains("Test"), SymbolFilter.All, cts.Token).Result; - } - catch (AggregateException ex) - { - VerifyInnerExceptionIsType(ex); - throw; - } + var cts = new CancellationTokenSource(); + var project = GetProject(WorkspaceKind.SingleClass); + cts.Cancel(); + var declarations = await SymbolFinder.FindSourceDeclarationsAsync(project, str => str.Contains("Test"), SymbolFilter.All, cts.Token); }); } @@ -521,49 +497,33 @@ public static async Task FindSourceDeclarationsAsync_Solution_Func_Test_AlwaysFa } [Fact] - public static void FindSourceDeclarationsAsync_Solution_Func_Test_NullSolution() + public async Task FindSourceDeclarationsAsync_Solution_Func_Test_NullSolution() { - Assert.Throws(() => + await Assert.ThrowsAsync(async () => { - try - { - var declarations = SymbolFinder.FindSourceDeclarationsAsync((Solution)null, str => str.Contains("Test")).Result; - } - catch (AggregateException ex) - { - VerifyInnerExceptionArgumentNull(ex, "solution"); - throw; - } + await SymbolFinder.FindSourceDeclarationsAsync((Solution)null, str => str.Contains("Test")); }); } [Fact] - public static void FindSourceDeclarationsAsync_Solution_Func_Test_NullPredicate() + public async Task FindSourceDeclarationsAsync_Solution_Func_Test_NullPredicate() { - Assert.Throws(() => + await Assert.ThrowsAsync(async () => { var solution = GetSolution(WorkspaceKind.SingleClass); - var declarations = SymbolFinder.FindSourceDeclarationsAsync(solution, null).Result; + await SymbolFinder.FindSourceDeclarationsAsync(solution, null); }); } [Fact] - public static void FindSourceDeclarationsAsync_Solution_Func_Test_Cancellation() + public async Task FindSourceDeclarationsAsync_Solution_Func_Test_Cancellation() { - Assert.Throws(() => + await Assert.ThrowsAsync(async () => { - try - { - var cts = new CancellationTokenSource(); - var solution = GetSolution(WorkspaceKind.SingleClass); - cts.Cancel(); - var declarations = SymbolFinder.FindSourceDeclarationsAsync(solution, str => str.Contains("Test"), SymbolFilter.All, cts.Token).Result; - } - catch (AggregateException ex) - { - VerifyInnerExceptionIsType(ex); - throw; - } + var cts = new CancellationTokenSource(); + var solution = GetSolution(WorkspaceKind.SingleClass); + cts.Cancel(); + await SymbolFinder.FindSourceDeclarationsAsync(solution, str => str.Contains("Test"), SymbolFilter.All, cts.Token); }); } From e15b77906433b66bbd90cbb96aaa167f73ea7d21 Mon Sep 17 00:00:00 2001 From: CyrusNajmabadi Date: Tue, 27 Sep 2016 20:05:48 -0700 Subject: [PATCH 7/8] Make test method non-static. --- .../CoreTest/FindAllDeclarationsTests.cs | 45 ++++++++++--------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/src/Workspaces/CoreTest/FindAllDeclarationsTests.cs b/src/Workspaces/CoreTest/FindAllDeclarationsTests.cs index 6385432a85f68..ae75752b00fc6 100644 --- a/src/Workspaces/CoreTest/FindAllDeclarationsTests.cs +++ b/src/Workspaces/CoreTest/FindAllDeclarationsTests.cs @@ -82,7 +82,8 @@ public partial class FindAllDeclarationsTests : TestBase InlineData("TestCase", true, WorkspaceKind.TwoNamespacesWithIdenticalClasses, new[] { "TestCase1.TestCase", "TestCase2.TestCase" }), InlineData("TestCase", false, WorkspaceKind.TwoNamespacesWithIdenticalClasses, new[] { "TestCase1.TestCase", "TestCase2.TestCase" }), InlineData("TestCase1.TestCase", true, WorkspaceKind.TwoNamespacesWithIdenticalClasses, new string[0]),] - public static async Task FindDeclarationsAsync_Test(string searchTerm, bool ignoreCase, WorkspaceKind workspaceKind, string[] expectedResults) + + public async Task FindDeclarationsAsync_Test(string searchTerm, bool ignoreCase, WorkspaceKind workspaceKind, string[] expectedResults) { var project = GetProject(workspaceKind); var declarations = await SymbolFinder.FindDeclarationsAsync(project, searchTerm, ignoreCase).ConfigureAwait(false); @@ -90,7 +91,7 @@ public static async Task FindDeclarationsAsync_Test(string searchTerm, bool igno } [Fact] - public static async Task FindDeclarationsAsync_Test_NullProject() + public async Task FindDeclarationsAsync_Test_NullProject() { await Assert.ThrowsAsync(async () => { @@ -99,7 +100,7 @@ await Assert.ThrowsAsync(async () => } [Fact] - public static async Task FindDeclarationsAsync_Test_NullString() + public async Task FindDeclarationsAsync_Test_NullString() { await Assert.ThrowsAsync(async () => { @@ -109,7 +110,7 @@ await Assert.ThrowsAsync(async () => } [Fact] - public static async Task FindDeclarationsAsync_Test_Cancellation() + public async Task FindDeclarationsAsync_Test_Cancellation() { await Assert.ThrowsAsync(async () => { @@ -121,7 +122,7 @@ await Assert.ThrowsAsync(async () => } [Fact, WorkItem(1094411, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1094411")] - public static async Task FindDeclarationsAsync_Metadata() + public async Task FindDeclarationsAsync_Metadata() { var solution = CreateSolution(); var csharpId = ProjectId.CreateNewId(); @@ -142,7 +143,7 @@ public static async Task FindDeclarationsAsync_Metadata() } [Fact, WorkItem(6616, "https://github.com/dotnet/roslyn/issues/6616")] - public static async Task FindDeclarationsAsync_PreviousSubmission() + public async Task FindDeclarationsAsync_PreviousSubmission() { var solution = CreateSolution(); @@ -246,7 +247,8 @@ public class Inner InlineData("TestCase", true, WorkspaceKind.TwoNamespacesWithIdenticalClasses, new[] { "TestCase1.TestCase", "TestCase2.TestCase" }), InlineData("TestCase", false, WorkspaceKind.TwoNamespacesWithIdenticalClasses, new[] { "TestCase1.TestCase", "TestCase2.TestCase" }), InlineData("TestCase1.TestCase", true, WorkspaceKind.TwoNamespacesWithIdenticalClasses, new string[0]),] - public static async Task FindSourceDeclarationsAsync_Project_Test(string searchTerm, bool ignoreCase, WorkspaceKind workspaceKind, string[] expectedResults) + + public async Task FindSourceDeclarationsAsync_Project_Test(string searchTerm, bool ignoreCase, WorkspaceKind workspaceKind, string[] expectedResults) { var project = GetProject(workspaceKind); var declarations = await SymbolFinder.FindSourceDeclarationsAsync(project, searchTerm, ignoreCase).ConfigureAwait(false); @@ -254,7 +256,7 @@ public static async Task FindSourceDeclarationsAsync_Project_Test(string searchT } [Fact] - public static async Task FindSourceDeclarationsAsync_Project_Test_NullProject() + public async Task FindSourceDeclarationsAsync_Project_Test_NullProject() { await Assert.ThrowsAsync(async () => { @@ -263,7 +265,7 @@ await Assert.ThrowsAsync(async () => } [Fact] - public static async Task FindSourceDeclarationsAsync_Project_Test_NullString() + public async Task FindSourceDeclarationsAsync_Project_Test_NullString() { await Assert.ThrowsAsync(async () => { @@ -273,7 +275,7 @@ await Assert.ThrowsAsync(async () => } [Fact] - public static async Task FindSourceDeclarationsAsync_Project_Test_Cancellation() + public async Task FindSourceDeclarationsAsync_Project_Test_Cancellation() { await Assert.ThrowsAsync(async () => { @@ -353,7 +355,8 @@ await Assert.ThrowsAsync(async () => InlineData("TestCase", true, WorkspaceKind.TwoNamespacesWithIdenticalClasses, new[] { "TestCase1.TestCase", "TestCase2.TestCase" }), InlineData("TestCase", false, WorkspaceKind.TwoNamespacesWithIdenticalClasses, new[] { "TestCase1.TestCase", "TestCase2.TestCase" }), InlineData("TestCase1.TestCase", true, WorkspaceKind.TwoNamespacesWithIdenticalClasses, new string[0]),] - public static async Task FindSourceDeclarationsAsync_Solution_Test(string searchTerm, bool ignoreCase, WorkspaceKind workspaceKind, string[] expectedResults) + + public async Task FindSourceDeclarationsAsync_Solution_Test(string searchTerm, bool ignoreCase, WorkspaceKind workspaceKind, string[] expectedResults) { var solution = GetSolution(workspaceKind); var declarations = await SymbolFinder.FindSourceDeclarationsAsync(solution, searchTerm, ignoreCase).ConfigureAwait(false); @@ -361,7 +364,7 @@ public static async Task FindSourceDeclarationsAsync_Solution_Test(string search } [Fact] - public static async Task FindSourceDeclarationsAsync_Solution_Test_NullProject() + public async Task FindSourceDeclarationsAsync_Solution_Test_NullProject() { await Assert.ThrowsAsync(async () => { @@ -370,7 +373,7 @@ await Assert.ThrowsAsync(async () => } [Fact] - public static async Task FindSourceDeclarationsAsync_Solution_Test_NullString() + public async Task FindSourceDeclarationsAsync_Solution_Test_NullString() { await Assert.ThrowsAsync(async () => { @@ -405,7 +408,8 @@ await Assert.ThrowsAsync(async () => InlineData(WorkspaceKind.TwoProjectsEachWithASingleClassWithSingleField, new[] { "TestCases", "TestCases.TestCase", "TestCases.TestCase.TestField" }), InlineData(WorkspaceKind.NestedClass, new[] { "TestCases", "TestCases.TestCase", "TestCases.TestCase.InnerTestCase" }), InlineData(WorkspaceKind.TwoNamespacesWithIdenticalClasses, new[] { "TestCase1", "TestCase1.TestCase", "TestCase2.TestCase", "TestCase2" }),] - public static async Task FindSourceDeclarationsAsync_Project_Func_Test(WorkspaceKind workspaceKind, string[] expectedResults) + + public async Task FindSourceDeclarationsAsync_Project_Func_Test(WorkspaceKind workspaceKind, string[] expectedResults) { var project = GetProject(workspaceKind); var declarations = await SymbolFinder.FindSourceDeclarationsAsync(project, str => str.Contains("Test")).ConfigureAwait(false); @@ -413,7 +417,7 @@ public static async Task FindSourceDeclarationsAsync_Project_Func_Test(Workspace } [Fact] - public static async Task FindSourceDeclarationsAsync_Project_Func_Test_AlwaysTruePredicate() + public async Task FindSourceDeclarationsAsync_Project_Func_Test_AlwaysTruePredicate() { var project = GetProject(WorkspaceKind.SingleClass); var declarations = await SymbolFinder.FindSourceDeclarationsAsync(project, str => true).ConfigureAwait(false); @@ -421,7 +425,7 @@ public static async Task FindSourceDeclarationsAsync_Project_Func_Test_AlwaysTru } [Fact] - public static async Task FindSourceDeclarationsAsync_Project_Func_Test_AlwaysFalsePredicate() + public async Task FindSourceDeclarationsAsync_Project_Func_Test_AlwaysFalsePredicate() { var project = GetProject(WorkspaceKind.SingleClass); var declarations = await SymbolFinder.FindSourceDeclarationsAsync(project, str => false).ConfigureAwait(false); @@ -473,7 +477,8 @@ await Assert.ThrowsAsync(async () => InlineData(WorkspaceKind.TwoProjectsEachWithASingleClassWithSingleField, new[] { "TestCases", "TestCases.TestCase", "TestCases.TestCase.TestField", "TestCases", "TestCases.TestCase", "TestCases.TestCase.TestField" }), InlineData(WorkspaceKind.NestedClass, new[] { "TestCases", "TestCases.TestCase", "TestCases.TestCase.InnerTestCase" }), InlineData(WorkspaceKind.TwoNamespacesWithIdenticalClasses, new[] { "TestCase1", "TestCase1.TestCase", "TestCase2.TestCase", "TestCase2" }),] - public static async Task FindSourceDeclarationsAsync_Solution_Func_Test(WorkspaceKind workspaceKind, string[] expectedResult) + + public async Task FindSourceDeclarationsAsync_Solution_Func_Test(WorkspaceKind workspaceKind, string[] expectedResult) { var solution = GetSolution(workspaceKind); var declarations = await SymbolFinder.FindSourceDeclarationsAsync(solution, str => str.Contains("Test")).ConfigureAwait(false); @@ -481,7 +486,7 @@ public static async Task FindSourceDeclarationsAsync_Solution_Func_Test(Workspac } [Fact] - public static async Task FindSourceDeclarationsAsync_Solution_Func_Test_AlwaysTruePredicate() + public async Task FindSourceDeclarationsAsync_Solution_Func_Test_AlwaysTruePredicate() { var solution = GetSolution(WorkspaceKind.SingleClass); var declarations = await SymbolFinder.FindSourceDeclarationsAsync(solution, str => true).ConfigureAwait(false); @@ -489,7 +494,7 @@ public static async Task FindSourceDeclarationsAsync_Solution_Func_Test_AlwaysTr } [Fact] - public static async Task FindSourceDeclarationsAsync_Solution_Func_Test_AlwaysFalsePredicate() + public async Task FindSourceDeclarationsAsync_Solution_Func_Test_AlwaysFalsePredicate() { var solution = GetSolution(WorkspaceKind.SingleClass); var declarations = await SymbolFinder.FindSourceDeclarationsAsync(solution, str => false).ConfigureAwait(false); @@ -528,7 +533,7 @@ await Assert.ThrowsAsync(async () => } [Fact] - public static async Task TestSymbolTreeInfoSerialization() + public async Task TestSymbolTreeInfoSerialization() { var solution = GetSolution(WorkspaceKind.SingleClass); var compilation = await solution.Projects.First().GetCompilationAsync(); From 548f47a8b640001a5131fc2eae9e08ca49988ec8 Mon Sep 17 00:00:00 2001 From: CyrusNajmabadi Date: Tue, 27 Sep 2016 23:00:58 -0700 Subject: [PATCH 8/8] Update tests. --- .../CoreTest/FindAllDeclarationsTests.cs | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/Workspaces/CoreTest/FindAllDeclarationsTests.cs b/src/Workspaces/CoreTest/FindAllDeclarationsTests.cs index ae75752b00fc6..f811c5a3d7cfb 100644 --- a/src/Workspaces/CoreTest/FindAllDeclarationsTests.cs +++ b/src/Workspaces/CoreTest/FindAllDeclarationsTests.cs @@ -93,7 +93,7 @@ public async Task FindDeclarationsAsync_Test(string searchTerm, bool ignoreCase, [Fact] public async Task FindDeclarationsAsync_Test_NullProject() { - await Assert.ThrowsAsync(async () => + await Assert.ThrowsAnyAsync(async () => { var declarations = await SymbolFinder.FindDeclarationsAsync(null, "Test", true); }); @@ -102,7 +102,7 @@ await Assert.ThrowsAsync(async () => [Fact] public async Task FindDeclarationsAsync_Test_NullString() { - await Assert.ThrowsAsync(async () => + await Assert.ThrowsAnyAsync(async () => { var project = GetProject(WorkspaceKind.SingleClass); var declarations = await SymbolFinder.FindDeclarationsAsync(project, null, true); @@ -112,7 +112,7 @@ await Assert.ThrowsAsync(async () => [Fact] public async Task FindDeclarationsAsync_Test_Cancellation() { - await Assert.ThrowsAsync(async () => + await Assert.ThrowsAnyAsync(async () => { var cts = new CancellationTokenSource(); cts.Cancel(); @@ -258,7 +258,7 @@ public async Task FindSourceDeclarationsAsync_Project_Test(string searchTerm, bo [Fact] public async Task FindSourceDeclarationsAsync_Project_Test_NullProject() { - await Assert.ThrowsAsync(async () => + await Assert.ThrowsAnyAsync(async () => { var declarations = await SymbolFinder.FindSourceDeclarationsAsync((Project)null, "Test", true); }); @@ -267,7 +267,7 @@ await Assert.ThrowsAsync(async () => [Fact] public async Task FindSourceDeclarationsAsync_Project_Test_NullString() { - await Assert.ThrowsAsync(async () => + await Assert.ThrowsAnyAsync(async () => { var project = GetProject(WorkspaceKind.SingleClass); var declarations = await SymbolFinder.FindSourceDeclarationsAsync(project, null, true); @@ -277,7 +277,7 @@ await Assert.ThrowsAsync(async () => [Fact] public async Task FindSourceDeclarationsAsync_Project_Test_Cancellation() { - await Assert.ThrowsAsync(async () => + await Assert.ThrowsAnyAsync(async () => { var cts = new CancellationTokenSource(); var project = GetProject(WorkspaceKind.SingleClass); @@ -366,7 +366,7 @@ public async Task FindSourceDeclarationsAsync_Solution_Test(string searchTerm, b [Fact] public async Task FindSourceDeclarationsAsync_Solution_Test_NullProject() { - await Assert.ThrowsAsync(async () => + await Assert.ThrowsAnyAsync(async () => { var declarations = await SymbolFinder.FindSourceDeclarationsAsync((Solution)null, "Test", true); }); @@ -375,7 +375,7 @@ await Assert.ThrowsAsync(async () => [Fact] public async Task FindSourceDeclarationsAsync_Solution_Test_NullString() { - await Assert.ThrowsAsync(async () => + await Assert.ThrowsAnyAsync(async () => { var solution = GetSolution(WorkspaceKind.SingleClass); var declarations = await SymbolFinder.FindSourceDeclarationsAsync(solution, null, true); @@ -385,7 +385,7 @@ await Assert.ThrowsAsync(async () => [Fact] public async Task FindSourceDeclarationsAsync_Solution_Test_Cancellation() { - await Assert.ThrowsAsync(async () => + await Assert.ThrowsAnyAsync(async () => { var cts = new CancellationTokenSource(); var solution = GetSolution(WorkspaceKind.SingleClass); @@ -435,7 +435,7 @@ public async Task FindSourceDeclarationsAsync_Project_Func_Test_AlwaysFalsePredi [Fact] public async Task FindSourceDeclarationsAsync_Project_Func_Test_NullProject() { - await Assert.ThrowsAsync(async () => + await Assert.ThrowsAnyAsync(async () => { var declarations = await SymbolFinder.FindSourceDeclarationsAsync((Project)null, str => str.Contains("Test")); }); @@ -444,7 +444,7 @@ await Assert.ThrowsAsync(async () => [Fact] public async Task FindSourceDeclarationsAsync_Project_Func_Test_NullPredicate() { - await Assert.ThrowsAsync(async () => + await Assert.ThrowsAnyAsync(async () => { var project = GetProject(WorkspaceKind.SingleClass); var declarations = await SymbolFinder.FindSourceDeclarationsAsync(project, null); @@ -454,7 +454,7 @@ await Assert.ThrowsAsync(async () => [Fact] public async Task FindSourceDeclarationsAsync_Project_Func_Test_Cancellation() { - await Assert.ThrowsAsync(async () => + await Assert.ThrowsAnyAsync(async () => { var cts = new CancellationTokenSource(); var project = GetProject(WorkspaceKind.SingleClass); @@ -504,7 +504,7 @@ public async Task FindSourceDeclarationsAsync_Solution_Func_Test_AlwaysFalsePred [Fact] public async Task FindSourceDeclarationsAsync_Solution_Func_Test_NullSolution() { - await Assert.ThrowsAsync(async () => + await Assert.ThrowsAnyAsync(async () => { await SymbolFinder.FindSourceDeclarationsAsync((Solution)null, str => str.Contains("Test")); }); @@ -513,7 +513,7 @@ await Assert.ThrowsAsync(async () => [Fact] public async Task FindSourceDeclarationsAsync_Solution_Func_Test_NullPredicate() { - await Assert.ThrowsAsync(async () => + await Assert.ThrowsAnyAsync(async () => { var solution = GetSolution(WorkspaceKind.SingleClass); await SymbolFinder.FindSourceDeclarationsAsync(solution, null); @@ -523,7 +523,7 @@ await Assert.ThrowsAsync(async () => [Fact] public async Task FindSourceDeclarationsAsync_Solution_Func_Test_Cancellation() { - await Assert.ThrowsAsync(async () => + await Assert.ThrowsAnyAsync(async () => { var cts = new CancellationTokenSource(); var solution = GetSolution(WorkspaceKind.SingleClass);