Provide a way to efficiently get the list of global aliases in a compilation. #59088
Labels
api-needs-work
API needs work before it is approved, it is NOT ready for implementation
Area-Compilers
Concept-API
This issue involves adding, removing, clarification, or modification of an API.
Feature Request
Milestone
Background and Motivation
The IDE needs to know the set of global aliases in a compilation in order to address bugs like #59042
While it is possible for us to go to every file, and find/bind every using, this is quite expensive as it will require parsing all files in the project, and it scales linearly with that cost, as opposed to the cost only being relative the number of global-usings actually present.
Proposed API
I have two proposals. One highly symbolic, one syntactic.
The syntactic approach is to have something like the following:
public class CSharpCompilation { + public bool ImmutableArray<SyntaxTree> GetTreesWithGlobalUsings(); }
This function can be powered by the internal decl table (which already has a bit on it stating if a file contains global usings).
Alternatively, we can go for a more symbolic approach like so:
Usage Examples
We currently have an analyzer that walks the user's code and sees if the name in source at least matches the name of some alias prior to do any expensive semantic work. This syntactic check is critical (it made this feature go from insanely expensive, to totally reasonable in terms of running time).
THat anlayzer already populates a set of names that the aliases map to for the usings in the file:
Risks
Low. We already have the information on the compiler side. this is just about lazily retrieving it for us to use.
The text was updated successfully, but these errors were encountered: