-
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
Avoid producing compilations in Add-Import when we can prove there are no results in that project. #65655
Conversation
symbolsWithName = symbolsWithName.Select(s => s.GetSymbolKey(cancellationToken).Resolve(startingCompilation, cancellationToken: cancellationToken).Symbol) | ||
.WhereNotNull() | ||
.ToImmutableArray(); | ||
} |
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.
moved this logic to the caller.
list.AddRange(FilterByCriteria(symbolsWithName, filter)); | ||
} | ||
} | ||
|
||
private static async Task AddMetadataDeclarationsWithNormalQueryAsync( | ||
Project project, | ||
IAssemblySymbol assembly, | ||
PortableExecutableReference? reference, | ||
AsyncLazy<IAssemblySymbol?> lazyAssembly, |
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.
changed to lazyAssembly. Avoids creation compilation when no results are found.
// get declarations from directly referenced projects and metadata | ||
foreach (var assembly in compilation.GetReferencedAssemblySymbols()) | ||
// get declarations from directly referenced projects | ||
foreach (var projectReference in project.ProjectReferences) |
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.
instead of walking GetReferencedAssemblySymbols (which needs both a compilation, and creates assembly symbols for all references), we can instead just manually walk project-references and metadtareferences, search each (using indices) And only realize the compilation if we find a match.
@@ -206,6 +206,9 @@ public SymbolTreeInfo WithChecksum(Checksum checksum) | |||
if (ignoreCase || StringComparer.Ordinal.Equals(name, node.Name)) | |||
{ | |||
assemblySymbol ??= await lazyAssembly.GetValueAsync(cancellationToken).ConfigureAwait(false); | |||
if (assemblySymbol is null) |
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.
❔ Where's the source of this null value?
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.
we are delaying getting the IAssemblySymbol for a particular PE reference, but the compiler does'nt guarantee all pe-references will produce an IAssemblySymbol.
using var _ = ArrayBuilder<ISymbol>.GetInstance(out var buffer); | ||
|
||
var referencedProject = project.Solution.GetProject(projectReference.ProjectId); | ||
if (referencedProject is null) |
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.
is this true when you have a ProjectReference
item in the csproj but no project exists on disk for example?
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.
yeah, i think jason has said this can occur.
No description provided.