-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Fix symbol-finder crash in mixed C#/TypeScript projects #60173
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,11 +89,11 @@ private static async Task<ImmutableArray<INamedTypeSymbol>> DescendInheritanceTr | |
// So we can just limit ourselves to that single project. | ||
|
||
// First find all the projects that could potentially reference this type. | ||
List<Project> orderedProjectsToExamine; | ||
ImmutableArray<Project> orderedProjectsToExamine; | ||
|
||
if (projects.Count == 1) | ||
{ | ||
orderedProjectsToExamine = projects.ToList(); | ||
orderedProjectsToExamine = projects.ToImmutableArray(); | ||
} | ||
else | ||
{ | ||
|
@@ -136,14 +136,16 @@ private static async Task<ImmutableArray<INamedTypeSymbol>> DescendInheritanceTr | |
{ | ||
cancellationToken.ThrowIfCancellationRequested(); | ||
|
||
Debug.Assert(project.SupportsCompilation); | ||
await DescendInheritanceTreeInProjectAsync( | ||
searchInMetadata, result, | ||
currentMetadataTypes, currentSourceAndMetadataTypes, | ||
project, | ||
typeMatches, | ||
shouldContinueSearching, | ||
transitive, cancellationToken).ConfigureAwait(false); | ||
if (project.SupportsCompilation) | ||
{ | ||
await DescendInheritanceTreeInProjectAsync( | ||
searchInMetadata, result, | ||
currentMetadataTypes, currentSourceAndMetadataTypes, | ||
project, | ||
typeMatches, | ||
shouldContinueSearching, | ||
transitive, cancellationToken).ConfigureAwait(false); | ||
} | ||
} | ||
|
||
return result.ToImmutableArray(); | ||
|
@@ -294,7 +296,7 @@ private static IEnumerable<ProjectId> GetProjectsThatCouldReferenceType( | |
.Concat(project.Id); | ||
} | ||
|
||
private static List<Project> GetOrderedProjectsToExamine( | ||
private static ImmutableArray<Project> GetOrderedProjectsToExamine( | ||
Solution solution, | ||
IImmutableSet<Project> projects, | ||
IEnumerable<ProjectId> projectsThatCouldReferenceType) | ||
|
@@ -308,7 +310,7 @@ private static List<Project> GetOrderedProjectsToExamine( | |
return OrderTopologically(solution, projectsToExamine); | ||
} | ||
|
||
private static List<Project> OrderTopologically( | ||
private static ImmutableArray<Project> OrderTopologically( | ||
Solution solution, IEnumerable<Project> projectsToExamine) | ||
{ | ||
var order = new Dictionary<ProjectId, int>(capacity: solution.ProjectIds.Count); | ||
|
@@ -322,10 +324,10 @@ private static List<Project> OrderTopologically( | |
index++; | ||
} | ||
|
||
return projectsToExamine.OrderBy((p1, p2) => order[p1.Id] - order[p2.Id]).ToList(); | ||
return projectsToExamine.OrderBy((p1, p2) => order[p1.Id] - order[p2.Id]).ToImmutableArray(); | ||
} | ||
|
||
private static IEnumerable<Project> GetProjectsToExamineWorker( | ||
private static ImmutableArray<Project> GetProjectsToExamineWorker( | ||
Solution solution, | ||
IImmutableSet<Project> projects, | ||
IEnumerable<ProjectId> projectsThatCouldReferenceType) | ||
|
@@ -358,8 +360,7 @@ private static IEnumerable<Project> GetProjectsToExamineWorker( | |
// that actually supports compilations. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Comment needs update |
||
return projectsThatCouldReferenceType.Intersect(allProjectsThatTheseProjectsDependOn) | ||
.Select(id => solution.GetRequiredProject(id)) | ||
.Where(p => p.SupportsCompilation) | ||
.ToList(); | ||
.ToImmutableArray(); | ||
} | ||
|
||
private static async Task AddDescendantMetadataTypesInProjectAsync( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,7 @@ public static async Task<ImmutableArray<INamedTypeSymbol>> FindTypesAsync( | |
var client = await RemoteHostClient.TryGetClientAsync(solution.Workspace, cancellationToken).ConfigureAwait(false); | ||
if (client != null) | ||
{ | ||
var projectIds = projects?.SelectAsArray(p => p.Id) ?? default; | ||
var projectIds = projects?.Where(p => RemoteSupportedLanguages.IsSupported(p.Language)).SelectAsArray(p => p.Id) ?? default; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this required for the fix, or just an optimization? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is required. Oop doesn't support other languages and crashes trying to find these projects on the other side. |
||
|
||
var result = await client.TryInvokeAsync<IRemoteDependentTypeFinderService, ImmutableArray<SerializableSymbolAndProjectId>>( | ||
solution, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either this comment is wrong, or your removal of the
Where
is wrong, but I have no idea whichThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. That's fair.