Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Merge pull request #54654 from CyrusNajmabadi/farOrder2" #54874

Merged
merged 1 commit into from
Jul 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,19 @@ internal class DelegateInvokeMethodReferenceFinder : AbstractReferenceFinder<IMe
protected override bool CanFind(IMethodSymbol symbol)
=> symbol.MethodKind == MethodKind.DelegateInvoke;

protected override async Task<ImmutableArray<ISymbol>> DetermineCascadedSymbolsAsync(
protected override async Task<ImmutableArray<(ISymbol symbol, FindReferencesCascadeDirection cascadeDirection)>> DetermineCascadedSymbolsAsync(
IMethodSymbol symbol,
Solution solution,
IImmutableSet<Project> projects,
FindReferencesSearchOptions options,
FindReferencesCascadeDirection cascadeDirection,
CancellationToken cancellationToken)
{
using var _ = ArrayBuilder<ISymbol>.GetInstance(out var result);
using var _ = ArrayBuilder<(ISymbol symbol, FindReferencesCascadeDirection cascadeDirection)>.GetInstance(out var result);

var beginInvoke = symbol.ContainingType.GetMembers(WellKnownMemberNames.DelegateBeginInvokeName).FirstOrDefault();
if (beginInvoke != null)
result.Add(beginInvoke);
result.Add((beginInvoke, cascadeDirection));

// All method group references
foreach (var project in solution.Projects)
Expand All @@ -53,7 +55,7 @@ protected override async Task<ImmutableArray<ISymbol>> DetermineCascadedSymbolsA
var changeSignatureService = document.GetLanguageService<AbstractChangeSignatureService>();
var cascaded = await changeSignatureService.DetermineCascadedSymbolsFromDelegateInvokeAsync(
symbol, document, cancellationToken).ConfigureAwait(false);
result.AddRange(cascaded);
result.AddRange(cascaded.SelectAsArray(s => (s, cascadeDirection)));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,33 +83,20 @@ private static async Task<ImmutableArray<INamedTypeSymbol>> DescendInheritanceTr
// are passed in. There is no need to check D as there's no way it could
// contribute an intermediate type that affects A or C. We only need to check
// A, B and C
//
// An exception to the above rule is if we're just searching a single project.
// in that case there can be no intermediary projects that could add types.
// So we can just limit ourselves to that single project.

// First find all the projects that could potentially reference this type.
List<Project> orderedProjectsToExamine;
var projectsThatCouldReferenceType = await GetProjectsThatCouldReferenceTypeAsync(
type, solution, searchInMetadata, cancellationToken).ConfigureAwait(false);

if (projects.Count == 1)
{
orderedProjectsToExamine = projects.ToList();
}
else
{
var projectsThatCouldReferenceType = await GetProjectsThatCouldReferenceTypeAsync(
type, solution, searchInMetadata, cancellationToken).ConfigureAwait(false);

// Now, based on the list of projects that could actually reference the type,
// and the list of projects the caller wants to search, find the actual list of
// projects we need to search through.
//
// This list of projects is properly topologically ordered. Because of this we
// can just process them in order from first to last because we know no project
// in this list could affect a prior project.
orderedProjectsToExamine = GetOrderedProjectsToExamine(
solution, projects, projectsThatCouldReferenceType);
}
// Now, based on the list of projects that could actually reference the type,
// and the list of projects the caller wants to search, find the actual list of
// projects we need to search through.
//
// This list of projects is properly topologically ordered. Because of this we
// can just process them in order from first to last because we know no project
// in this list could affect a prior project.
var orderedProjectsToExamine = GetOrderedProjectsToExamine(
solution, projects, projectsThatCouldReferenceType);

// The final set of results we'll be returning.
using var _1 = GetSymbolSet(out var result);
Expand Down Expand Up @@ -291,7 +278,7 @@ private static IEnumerable<ProjectId> GetProjectsThatCouldReferenceType(
{
// Get all the projects that depend on 'project' as well as 'project' itself.
return dependencyGraph.GetProjectsThatTransitivelyDependOnThisProject(project.Id)
.Concat(project.Id);
.Concat(project.Id);
}

private static List<Project> GetOrderedProjectsToExamine(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;

namespace Microsoft.CodeAnalysis.FindSymbols
{
[Flags]
internal enum FindReferencesCascadeDirection
{
/// <summary>
/// Cascade up the inheritance hierarchy.
/// </summary>
Up = 1,

/// <summary>
/// Cascade down the inheritance hierarchy.
/// </summary>
Down = 2,

/// <summary>
/// Cascade in both directions.
/// </summary>
UpAndDown = Up | Down,
}

internal static class FindReferencesCascadeDirectionExtensions
{
public static bool HasFlag(this FindReferencesCascadeDirection value, FindReferencesCascadeDirection flag)
=> (value & flag) == flag;
}
}

This file was deleted.

This file was deleted.

Loading