From bbe1d6b202b31e89761f21549277350889799f65 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Mon, 20 Apr 2020 16:18:11 -0700 Subject: [PATCH] Siplify code --- ...stractFindUsagesService.ProgressAdapter.cs | 3 +- .../FindUsages/AbstractFindUsagesService.cs | 28 +++++++------------ .../Core/FindUsages/FindUsagesHelpers.cs | 12 ++++---- .../IDefinitionsAndReferencesFactory.cs | 14 +++++----- .../Core/GoToBase/AbstractGoToBaseService.cs | 14 ++++------ .../Core/GoToBase/FindBaseHelpers.cs | 5 ++-- .../AbstractGoToDefinitionService.cs | 4 +-- .../AbstractGoToSymbolService.cs | 5 ++-- .../GoToDefinition/GoToDefinitionHelpers.cs | 17 ++++++----- .../Implementation/IntelliSense/Helpers.cs | 2 +- .../Peek/PeekableItemFactory.cs | 2 +- .../NavigableSymbolService.NavigableSymbol.cs | 2 +- .../Portable/FindUsages/DefinitionItem.cs | 9 ++++-- .../Debugger/DebuggerFindReferencesService.cs | 3 +- .../AbstractObjectBrowserLibraryManager.cs | 3 +- .../VisualStudioSymbolNavigationService.cs | 6 ++-- .../Core/Impl/RoslynVisualStudioWorkspace.cs | 2 +- .../FindReferences/BaseTypeFinder.cs | 3 +- .../CoreTest/FindReferencesTests.cs | 2 +- 19 files changed, 63 insertions(+), 73 deletions(-) diff --git a/src/EditorFeatures/Core/FindUsages/AbstractFindUsagesService.ProgressAdapter.cs b/src/EditorFeatures/Core/FindUsages/AbstractFindUsagesService.ProgressAdapter.cs index 87c13d95f7d..89e540203dc 100644 --- a/src/EditorFeatures/Core/FindUsages/AbstractFindUsagesService.ProgressAdapter.cs +++ b/src/EditorFeatures/Core/FindUsages/AbstractFindUsagesService.ProgressAdapter.cs @@ -102,8 +102,7 @@ private async Task GetDefinitionItemAsync(ISymbol definition) if (!_definitionToItem.TryGetValue(definition, out var definitionItem)) { definitionItem = await definition.ToClassifiedDefinitionItemAsync( - _solution.GetOriginatingProject(definition), includeHiddenLocations: false, - _options, _context.CancellationToken).ConfigureAwait(false); + _solution, includeHiddenLocations: false, _options, _context.CancellationToken).ConfigureAwait(false); _definitionToItem[definition] = definitionItem; } diff --git a/src/EditorFeatures/Core/FindUsages/AbstractFindUsagesService.cs b/src/EditorFeatures/Core/FindUsages/AbstractFindUsagesService.cs index a586d19bdcb..a4f2849fa36 100644 --- a/src/EditorFeatures/Core/FindUsages/AbstractFindUsagesService.cs +++ b/src/EditorFeatures/Core/FindUsages/AbstractFindUsagesService.cs @@ -52,8 +52,7 @@ protected AbstractFindUsagesService(IThreadingContext threadingContext) foreach (var implementation in implementations) { var definitionItem = await implementation.ToClassifiedDefinitionItemAsync( - solution.GetOriginatingProject(implementation), includeHiddenLocations: false, - FindReferencesSearchOptions.Default, cancellationToken).ConfigureAwait(false); + solution, includeHiddenLocations: false, FindReferencesSearchOptions.Default, cancellationToken).ConfigureAwait(false); await context.OnDefinitionFoundAsync(definitionItem).ConfigureAwait(false); } @@ -122,16 +121,16 @@ protected AbstractFindUsagesService(IThreadingContext threadingContext) cancellationToken.ThrowIfCancellationRequested(); // Find the symbol we want to search and the solution we want to search in. - var symbolAndProjectOpt = await FindUsagesHelpers.GetRelevantSymbolAndProjectAtPositionAsync( + var symbolAndSolutionOpt = await FindUsagesHelpers.GetRelevantSymbolAndSolutionAtPositionAsync( document, position, cancellationToken).ConfigureAwait(false); - if (symbolAndProjectOpt == null) + if (symbolAndSolutionOpt == null) return; - var (symbol, project) = symbolAndProjectOpt.Value; + var (symbol, solution) = symbolAndSolutionOpt.Value; await FindSymbolReferencesAsync( _threadingContext, context, - symbol, project, + symbol, solution, cancellationToken).ConfigureAwait(false); } @@ -141,9 +140,9 @@ protected AbstractFindUsagesService(IThreadingContext threadingContext) /// public static async Task FindSymbolReferencesAsync( IThreadingContext threadingContext, IFindUsagesContext context, - ISymbol symbol, Project project, CancellationToken cancellationToken) + ISymbol symbol, Solution solution, CancellationToken cancellationToken) { - var monikerUsagesService = project.Solution.Workspace.Services.GetRequiredService(); + var monikerUsagesService = solution.Workspace.Services.GetRequiredService(); await context.SetSearchTitleAsync(string.Format(EditorFeaturesResources._0_references, FindUsagesHelpers.GetDisplayName(symbol))).ConfigureAwait(false); @@ -154,20 +153,13 @@ protected AbstractFindUsagesService(IThreadingContext threadingContext) // engine will push results into the 'progress' instance passed into it. // We'll take those results, massage them, and forward them along to the // FindReferencesContext instance we were given. + var progress = new FindReferencesProgressAdapter(threadingContext, solution, context, options); var normalFindReferencesTask = SymbolFinder.FindReferencesAsync( - symbol, - project.Solution, - new FindReferencesProgressAdapter(threadingContext, project.Solution, context, options), - documents: null, - options, - cancellationToken); + symbol, solution, progress, documents: null, options, cancellationToken); // Kick off work to search the online code index system in parallel var codeIndexReferencesTask = FindSymbolMonikerReferencesAsync( - monikerUsagesService, - symbol, - context, - cancellationToken); + monikerUsagesService, symbol, context, cancellationToken); await Task.WhenAll(normalFindReferencesTask, codeIndexReferencesTask).ConfigureAwait(false); } diff --git a/src/EditorFeatures/Core/FindUsages/FindUsagesHelpers.cs b/src/EditorFeatures/Core/FindUsages/FindUsagesHelpers.cs index 2ee5022088b..b80755df56e 100644 --- a/src/EditorFeatures/Core/FindUsages/FindUsagesHelpers.cs +++ b/src/EditorFeatures/Core/FindUsages/FindUsagesHelpers.cs @@ -31,7 +31,7 @@ public static string GetDisplayName(ISymbol symbol) /// there may be symbol mapping involved (for example in Metadata-As-Source /// scenarios). /// - public static async Task<(ISymbol symbol, Project project)?> GetRelevantSymbolAndProjectAtPositionAsync( + public static async Task<(ISymbol symbol, Solution solution)?> GetRelevantSymbolAndSolutionAtPositionAsync( Document document, int position, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); @@ -49,19 +49,19 @@ public static string GetDisplayName(ISymbol symbol) if (mapping == null) return null; - return (mapping.Symbol, mapping.Project); + return (mapping.Symbol, mapping.Project.Solution); } public static async Task<(Solution solution, ISymbol symbol, ImmutableArray implementations, string message)?> FindSourceImplementationsAsync(Document document, int position, CancellationToken cancellationToken) { - var symbolAndProjectOpt = await GetRelevantSymbolAndProjectAtPositionAsync( + var symbolAndSolutionOpt = await GetRelevantSymbolAndSolutionAtPositionAsync( document, position, cancellationToken).ConfigureAwait(false); - if (symbolAndProjectOpt == null) + if (symbolAndSolutionOpt == null) return null; - var (symbol, project) = symbolAndProjectOpt.Value; + var (symbol, solution) = symbolAndSolutionOpt.Value; return await FindSourceImplementationsAsync( - project.Solution, symbol, cancellationToken).ConfigureAwait(false); + solution, symbol, cancellationToken).ConfigureAwait(false); } private static async Task<(Solution solution, ISymbol symbol, ImmutableArray implementations, string message)?> FindSourceImplementationsAsync( diff --git a/src/EditorFeatures/Core/FindUsages/IDefinitionsAndReferencesFactory.cs b/src/EditorFeatures/Core/FindUsages/IDefinitionsAndReferencesFactory.cs index 942cd9660cf..90c1c8dca82 100644 --- a/src/EditorFeatures/Core/FindUsages/IDefinitionsAndReferencesFactory.cs +++ b/src/EditorFeatures/Core/FindUsages/IDefinitionsAndReferencesFactory.cs @@ -53,7 +53,7 @@ internal static class DefinitionItemExtensions { public static DefinitionItem ToNonClassifiedDefinitionItem( this ISymbol definition, - Project project, + Solution solution, bool includeHiddenLocations) { // Because we're passing in 'false' for 'includeClassifiedSpans', this won't ever have @@ -61,25 +61,25 @@ internal static class DefinitionItemExtensions // to compute the classified spans for the locations of the definition. So it's totally // fine to pass in CancellationToken.None and block on the result. return ToDefinitionItemAsync( - definition, project, includeHiddenLocations, includeClassifiedSpans: false, + definition, solution, includeHiddenLocations, includeClassifiedSpans: false, options: FindReferencesSearchOptions.Default, cancellationToken: CancellationToken.None).WaitAndGetResult_CanCallOnBackground(CancellationToken.None); } public static Task ToClassifiedDefinitionItemAsync( this ISymbol definition, - Project project, + Solution solution, bool includeHiddenLocations, FindReferencesSearchOptions options, CancellationToken cancellationToken) { - return ToDefinitionItemAsync(definition, project, + return ToDefinitionItemAsync(definition, solution, includeHiddenLocations, includeClassifiedSpans: true, options, cancellationToken); } private static async Task ToDefinitionItemAsync( this ISymbol definition, - Project project, + Solution solution, bool includeHiddenLocations, bool includeClassifiedSpans, FindReferencesSearchOptions options, @@ -121,7 +121,7 @@ internal static class DefinitionItemExtensions if (location.IsInMetadata) { return DefinitionItem.CreateMetadataDefinition( - tags, displayParts, nameDisplayParts, project, + tags, displayParts, nameDisplayParts, solution, definition, properties, displayIfNoReferences); } else if (location.IsInSource) @@ -132,7 +132,7 @@ internal static class DefinitionItemExtensions continue; } - var document = project.Solution.GetDocument(location.SourceTree); + var document = solution.GetDocument(location.SourceTree); if (document != null) { var documentLocation = !includeClassifiedSpans diff --git a/src/EditorFeatures/Core/GoToBase/AbstractGoToBaseService.cs b/src/EditorFeatures/Core/GoToBase/AbstractGoToBaseService.cs index 8bacf38c4ca..f6ece802cf9 100644 --- a/src/EditorFeatures/Core/GoToBase/AbstractGoToBaseService.cs +++ b/src/EditorFeatures/Core/GoToBase/AbstractGoToBaseService.cs @@ -16,21 +16,20 @@ internal abstract partial class AbstractGoToBaseService : IGoToBaseService public async Task FindBasesAsync(Document document, int position, IFindUsagesContext context) { var cancellationToken = context.CancellationToken; - var symbolAndProjectOpt = await FindUsagesHelpers.GetRelevantSymbolAndProjectAtPositionAsync( + var symbolAndSolutionOpt = await FindUsagesHelpers.GetRelevantSymbolAndSolutionAtPositionAsync( document, position, cancellationToken).ConfigureAwait(false); - if (symbolAndProjectOpt == null) + if (symbolAndSolutionOpt == null) { await context.ReportMessageAsync( EditorFeaturesResources.Cannot_navigate_to_the_symbol_under_the_caret).ConfigureAwait(false); return; } - var (symbol, project) = symbolAndProjectOpt.Value; - var solution = project.Solution; + var (symbol, solution) = symbolAndSolutionOpt.Value; var bases = FindBaseHelpers.FindBases( - symbol, project, cancellationToken); + symbol, solution, cancellationToken); await context.SetSearchTitleAsync( string.Format(EditorFeaturesResources._0_bases, @@ -48,8 +47,7 @@ public async Task FindBasesAsync(Document document, int position, IFindUsagesCon if (sourceDefinition != null) { var definitionItem = await sourceDefinition.ToClassifiedDefinitionItemAsync( - solution.GetOriginatingProject(sourceDefinition), includeHiddenLocations: false, - FindReferencesSearchOptions.Default, cancellationToken: cancellationToken).ConfigureAwait(false); + solution, includeHiddenLocations: false, FindReferencesSearchOptions.Default, cancellationToken: cancellationToken).ConfigureAwait(false); await context.OnDefinitionFoundAsync(definitionItem).ConfigureAwait(false); found = true; @@ -57,7 +55,7 @@ public async Task FindBasesAsync(Document document, int position, IFindUsagesCon else if (baseSymbol.Locations.Any(l => l.IsInMetadata)) { var definitionItem = baseSymbol.ToNonClassifiedDefinitionItem( - project, includeHiddenLocations: true); + solution, includeHiddenLocations: true); await context.OnDefinitionFoundAsync(definitionItem).ConfigureAwait(false); found = true; } diff --git a/src/EditorFeatures/Core/GoToBase/FindBaseHelpers.cs b/src/EditorFeatures/Core/GoToBase/FindBaseHelpers.cs index 5af8c6d06d4..660af290919 100644 --- a/src/EditorFeatures/Core/GoToBase/FindBaseHelpers.cs +++ b/src/EditorFeatures/Core/GoToBase/FindBaseHelpers.cs @@ -11,7 +11,7 @@ namespace Microsoft.CodeAnalysis.Editor.GoToBase internal static class FindBaseHelpers { public static ImmutableArray FindBases( - ISymbol symbol, Project project, CancellationToken cancellationToken) + ISymbol symbol, Solution solution, CancellationToken cancellationToken) { if (symbol is INamedTypeSymbol namedTypeSymbol && (namedTypeSymbol.TypeKind == TypeKind.Class || @@ -24,8 +24,7 @@ internal static class FindBaseHelpers symbol.Kind == SymbolKind.Method || symbol.Kind == SymbolKind.Event) { - return BaseTypeFinder.FindOverriddenAndImplementedMembers( - symbol, project, cancellationToken); + return BaseTypeFinder.FindOverriddenAndImplementedMembers(symbol, solution, cancellationToken); } else { diff --git a/src/EditorFeatures/Core/GoToDefinition/AbstractGoToDefinitionService.cs b/src/EditorFeatures/Core/GoToDefinition/AbstractGoToDefinitionService.cs index aed1b76caab..2d0ee79f72e 100644 --- a/src/EditorFeatures/Core/GoToDefinition/AbstractGoToDefinitionService.cs +++ b/src/EditorFeatures/Core/GoToDefinition/AbstractGoToDefinitionService.cs @@ -63,7 +63,7 @@ public bool TryGoToDefinition(Document document, int position, CancellationToken var isThirdPartyNavigationAllowed = IsThirdPartyNavigationAllowed(symbol, position, document, cancellationToken); return GoToDefinitionHelpers.TryGoToDefinition(symbol, - document.Project, + document.Project.Solution, _streamingPresenter.Value, thirdPartyNavigationAllowed: isThirdPartyNavigationAllowed, cancellationToken: cancellationToken); @@ -100,7 +100,7 @@ public bool TryGoToDefinition(Document document, int position, CancellationToken var definitions = interfaceImpls.SelectMany( i => GoToDefinitionHelpers.GetDefinitions( - i, project, thirdPartyNavigationAllowed: false, cancellationToken)).ToImmutableArray(); + i, solution, thirdPartyNavigationAllowed: false, cancellationToken)).ToImmutableArray(); var title = string.Format(EditorFeaturesResources._0_implemented_members, FindUsagesHelpers.GetDisplayName(symbol)); diff --git a/src/EditorFeatures/Core/GoToDefinition/AbstractGoToSymbolService.cs b/src/EditorFeatures/Core/GoToDefinition/AbstractGoToSymbolService.cs index 0fc4ec602e5..7988b7d696e 100644 --- a/src/EditorFeatures/Core/GoToDefinition/AbstractGoToSymbolService.cs +++ b/src/EditorFeatures/Core/GoToDefinition/AbstractGoToSymbolService.cs @@ -40,8 +40,9 @@ public async Task GetSymbolsAsync(GoToSymbolContext context) await ThreadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(alwaysYield: true, cancellationToken); cancellationToken.ThrowIfCancellationRequested(); - var definitions = GoToDefinitionHelpers.GetDefinitions(symbol, document.Project, thirdPartyNavigationAllowed: true, cancellationToken) - .WhereAsArray(d => d.CanNavigateTo(document.Project.Solution.Workspace)); + var solution = document.Project.Solution; + var definitions = GoToDefinitionHelpers.GetDefinitions(symbol, solution, thirdPartyNavigationAllowed: true, cancellationToken) + .WhereAsArray(d => d.CanNavigateTo(solution.Workspace)); await TaskScheduler.Default; diff --git a/src/EditorFeatures/Core/GoToDefinition/GoToDefinitionHelpers.cs b/src/EditorFeatures/Core/GoToDefinition/GoToDefinitionHelpers.cs index 92039318f63..6cd201c2f64 100644 --- a/src/EditorFeatures/Core/GoToDefinition/GoToDefinitionHelpers.cs +++ b/src/EditorFeatures/Core/GoToDefinition/GoToDefinitionHelpers.cs @@ -20,7 +20,7 @@ internal static class GoToDefinitionHelpers { public static ImmutableArray GetDefinitions( ISymbol symbol, - Project project, + Solution solution, bool thirdPartyNavigationAllowed, CancellationToken cancellationToken) { @@ -36,13 +36,12 @@ internal static class GoToDefinitionHelpers // VB global import aliases have a synthesized SyntaxTree. // We can't go to the definition of the alias, so use the target type. - var solution = project.Solution; if (alias != null) { var sourceLocations = NavigableItemFactory.GetPreferredSourceLocations( solution, symbol, cancellationToken); - if (sourceLocations.All(l => project.Solution.GetDocument(l.SourceTree) == null)) + if (sourceLocations.All(l => solution.GetDocument(l.SourceTree) == null)) { symbol = alias.Target; } @@ -81,7 +80,7 @@ internal static class GoToDefinitionHelpers // So, if we only have a single location to go to, this does no unnecessary work. And, // if we do have multiple locations to show, it will just be done in the BG, unblocking // this command thread so it can return the user faster. - var definitionItem = symbol.ToNonClassifiedDefinitionItem(project, includeHiddenLocations: true); + var definitionItem = symbol.ToNonClassifiedDefinitionItem(solution, includeHiddenLocations: true); if (thirdPartyNavigationAllowed) { @@ -96,23 +95,23 @@ internal static class GoToDefinitionHelpers public static bool TryGoToDefinition( ISymbol symbol, - Project project, + Solution solution, IStreamingFindUsagesPresenter streamingPresenter, CancellationToken cancellationToken, bool thirdPartyNavigationAllowed = true) { - var definitions = GetDefinitions(symbol, project, thirdPartyNavigationAllowed, cancellationToken); + var definitions = GetDefinitions(symbol, solution, thirdPartyNavigationAllowed, cancellationToken); var title = string.Format(EditorFeaturesResources._0_declarations, FindUsagesHelpers.GetDisplayName(symbol)); return streamingPresenter.TryNavigateToOrPresentItemsAsync( - project.Solution.Workspace, title, definitions).WaitAndGetResult(cancellationToken); + solution.Workspace, title, definitions).WaitAndGetResult(cancellationToken); } public static bool TryGoToDefinition( ImmutableArray definitions, - Project project, + Solution solution, string title, IStreamingFindUsagesPresenter streamingPresenter, CancellationToken cancellationToken) @@ -123,7 +122,7 @@ internal static class GoToDefinitionHelpers } return streamingPresenter.TryNavigateToOrPresentItemsAsync( - project.Solution.Workspace, title, definitions).WaitAndGetResult(cancellationToken); + solution.Workspace, title, definitions).WaitAndGetResult(cancellationToken); } } } diff --git a/src/EditorFeatures/Core/Implementation/IntelliSense/Helpers.cs b/src/EditorFeatures/Core/Implementation/IntelliSense/Helpers.cs index e4cd35feedc..b3557315624 100644 --- a/src/EditorFeatures/Core/Implementation/IntelliSense/Helpers.cs +++ b/src/EditorFeatures/Core/Implementation/IntelliSense/Helpers.cs @@ -168,7 +168,7 @@ private static void NavigateToQuickInfoTarget(string navigationTarget, Document if (resolvedSymbolKey.GetAnySymbol() is { } symbol) { - GoToDefinitionHelpers.TryGoToDefinition(symbol, document.Project, streamingPresenter, CancellationToken.None); + GoToDefinitionHelpers.TryGoToDefinition(symbol, document.Project.Solution, streamingPresenter, CancellationToken.None); return; } } diff --git a/src/EditorFeatures/Core/Implementation/Peek/PeekableItemFactory.cs b/src/EditorFeatures/Core/Implementation/Peek/PeekableItemFactory.cs index 198196cd857..27ea061e1c0 100644 --- a/src/EditorFeatures/Core/Implementation/Peek/PeekableItemFactory.cs +++ b/src/EditorFeatures/Core/Implementation/Peek/PeekableItemFactory.cs @@ -62,7 +62,7 @@ public PeekableItemFactory(IMetadataAsSourceFileService metadataAsSourceFileServ } var symbolNavigationService = solution.Workspace.Services.GetService(); - var definitionItem = symbol.ToNonClassifiedDefinitionItem(project, includeHiddenLocations: true); + var definitionItem = symbol.ToNonClassifiedDefinitionItem(solution, includeHiddenLocations: true); if (symbolNavigationService.WouldNavigateToSymbol( definitionItem, solution, cancellationToken, diff --git a/src/EditorFeatures/Core/NavigableSymbols/NavigableSymbolService.NavigableSymbol.cs b/src/EditorFeatures/Core/NavigableSymbols/NavigableSymbolService.NavigableSymbol.cs index 6be3268716e..bba54735dba 100644 --- a/src/EditorFeatures/Core/NavigableSymbols/NavigableSymbolService.NavigableSymbol.cs +++ b/src/EditorFeatures/Core/NavigableSymbols/NavigableSymbolService.NavigableSymbol.cs @@ -52,7 +52,7 @@ private class NavigableSymbol : INavigableSymbol showProgress: false, action: context => GoToDefinitionHelpers.TryGoToDefinition( _definitions, - _document.Project, + _document.Project.Solution, _definitions[0].NameDisplayParts.GetFullText(), _presenter, context.CancellationToken) diff --git a/src/Features/Core/Portable/FindUsages/DefinitionItem.cs b/src/Features/Core/Portable/FindUsages/DefinitionItem.cs index 40213db4b58..b648e259c71 100644 --- a/src/Features/Core/Portable/FindUsages/DefinitionItem.cs +++ b/src/Features/Core/Portable/FindUsages/DefinitionItem.cs @@ -213,7 +213,7 @@ internal abstract partial class DefinitionItem ImmutableArray tags, ImmutableArray displayParts, ImmutableArray nameDisplayParts, - Project project, + Solution solution, ISymbol symbol, ImmutableDictionary properties = null, bool displayIfNoReferences = true) @@ -222,9 +222,12 @@ internal abstract partial class DefinitionItem var symbolKey = symbol.GetSymbolKey().ToString(); + var projectId = solution.GetOriginatingProjectId(symbol); + Contract.ThrowIfNull(projectId); + properties = properties.Add(MetadataSymbolKey, symbolKey) - .Add(MetadataSymbolOriginatingProjectIdGuid, project.Id.Id.ToString()) - .Add(MetadataSymbolOriginatingProjectIdDebugName, project.Id.DebugName); + .Add(MetadataSymbolOriginatingProjectIdGuid, projectId.Id.ToString()) + .Add(MetadataSymbolOriginatingProjectIdDebugName, projectId.DebugName); var originationParts = GetOriginationParts(symbol); return new DefaultDefinitionItem( diff --git a/src/Tools/ExternalAccess/Debugger/DebuggerFindReferencesService.cs b/src/Tools/ExternalAccess/Debugger/DebuggerFindReferencesService.cs index 32da405a62e..00052c316b0 100644 --- a/src/Tools/ExternalAccess/Debugger/DebuggerFindReferencesService.cs +++ b/src/Tools/ExternalAccess/Debugger/DebuggerFindReferencesService.cs @@ -39,7 +39,8 @@ public async Task FindSymbolReferencesAsync(ISymbol symbol, Project project, Can // the context object that the FAR service will push results into. var context = streamingPresenter.StartSearch(EditorFeaturesResources.Find_References, supportsReferences: true); - await AbstractFindUsagesService.FindSymbolReferencesAsync(_threadingContext, context, symbol, project, cancellationToken).ConfigureAwait(false); + await AbstractFindUsagesService.FindSymbolReferencesAsync( + _threadingContext, context, symbol, project.Solution, cancellationToken).ConfigureAwait(false); // Note: we don't need to put this in a finally. The only time we might not hit // this is if cancellation or another error gets thrown. In the former case, diff --git a/src/VisualStudio/Core/Def/Implementation/Library/ObjectBrowser/AbstractObjectBrowserLibraryManager.cs b/src/VisualStudio/Core/Def/Implementation/Library/ObjectBrowser/AbstractObjectBrowserLibraryManager.cs index c2cbdd4275b..c178ab77d6d 100644 --- a/src/VisualStudio/Core/Def/Implementation/Library/ObjectBrowser/AbstractObjectBrowserLibraryManager.cs +++ b/src/VisualStudio/Core/Def/Implementation/Library/ObjectBrowser/AbstractObjectBrowserLibraryManager.cs @@ -553,8 +553,7 @@ private static async Task FindReferencesAsync(IThreadingContext threadingContext if (symbol != null) { await AbstractFindUsagesService.FindSymbolReferencesAsync( - threadingContext, - context, symbol, project, cancellationToken).ConfigureAwait(false); + threadingContext, context, symbol, project.Solution, cancellationToken).ConfigureAwait(false); } } } diff --git a/src/VisualStudio/Core/Def/Implementation/Workspace/VisualStudioSymbolNavigationService.cs b/src/VisualStudio/Core/Def/Implementation/Workspace/VisualStudioSymbolNavigationService.cs index 60ab69b242c..d0dc05ec052 100644 --- a/src/VisualStudio/Core/Def/Implementation/Workspace/VisualStudioSymbolNavigationService.cs +++ b/src/VisualStudio/Core/Def/Implementation/Workspace/VisualStudioSymbolNavigationService.cs @@ -178,14 +178,14 @@ public bool TryNavigateToSymbol(ISymbol symbol, Project project, OptionSet optio } public bool TrySymbolNavigationNotify(ISymbol symbol, Project project, CancellationToken cancellationToken) - => TryNotifyForSpecificSymbol(symbol, project, cancellationToken); + => TryNotifyForSpecificSymbol(symbol, project.Solution, cancellationToken); private bool TryNotifyForSpecificSymbol( - ISymbol symbol, Project project, CancellationToken cancellationToken) + ISymbol symbol, Solution solution, CancellationToken cancellationToken) { AssertIsForeground(); - var definitionItem = symbol.ToNonClassifiedDefinitionItem(project, includeHiddenLocations: true); + var definitionItem = symbol.ToNonClassifiedDefinitionItem(solution, includeHiddenLocations: true); definitionItem.Properties.TryGetValue(DefinitionItem.RQNameKey1, out var rqName); if (!TryGetNavigationAPIRequiredArguments( diff --git a/src/VisualStudio/Core/Impl/RoslynVisualStudioWorkspace.cs b/src/VisualStudio/Core/Impl/RoslynVisualStudioWorkspace.cs index 7c448ed6ce7..1b09fd5a3c2 100644 --- a/src/VisualStudio/Core/Impl/RoslynVisualStudioWorkspace.cs +++ b/src/VisualStudio/Core/Impl/RoslynVisualStudioWorkspace.cs @@ -122,7 +122,7 @@ internal override IInvisibleEditor OpenInvisibleEditor(DocumentId documentId) } return GoToDefinitionHelpers.TryGoToDefinition( - searchSymbol, searchProject, + searchSymbol, searchProject.Solution, _streamingPresenter.Value, cancellationToken); } diff --git a/src/Workspaces/Core/Portable/FindSymbols/FindReferences/BaseTypeFinder.cs b/src/Workspaces/Core/Portable/FindSymbols/FindReferences/BaseTypeFinder.cs index 8d4683cf7f5..3fb742e9d33 100644 --- a/src/Workspaces/Core/Portable/FindSymbols/FindReferences/BaseTypeFinder.cs +++ b/src/Workspaces/Core/Portable/FindSymbols/FindReferences/BaseTypeFinder.cs @@ -15,9 +15,8 @@ public static ImmutableArray FindBaseTypesAndInterfaces(INamedTypeSymbo => FindBaseTypes(type).AddRange(type.AllInterfaces).CastArray(); public static ImmutableArray FindOverriddenAndImplementedMembers( - ISymbol symbol, Project project, CancellationToken cancellationToken) + ISymbol symbol, Solution solution, CancellationToken cancellationToken) { - var solution = project.Solution; var results = ArrayBuilder.GetInstance(); // This is called for all: class, struct or interface member. diff --git a/src/Workspaces/CoreTest/FindReferencesTests.cs b/src/Workspaces/CoreTest/FindReferencesTests.cs index a9998ee2fcb..a0261269c34 100644 --- a/src/Workspaces/CoreTest/FindReferencesTests.cs +++ b/src/Workspaces/CoreTest/FindReferencesTests.cs @@ -325,7 +325,7 @@ public System.Uri Get() var projectIds = new HashSet(); foreach (var r in references) - projectIds.Add(solution.GetExactProjectId(r.Definition)); + projectIds.Add(solution.GetOriginatingProjectId(r.Definition)); Assert.True(projectIds.Contains(desktopProject.Id)); } -- GitLab