-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Description
Scenario
Implement improvements in Go To Definition when navigating to a metadata symbol (see #24349).
When the user invokes GTD on a metadata symbol we plan to identify the source file where the symbol is defined based on information stored in the PDB (combination of MethodDebugInformation, CustomDebugInformation and Document PDB tables).
Using debugger provided service we can first retrieve the PDB, find the source info in the PDB tables, then use Source Link (assuming it's present in the PDB), download the source file(s) that define the symbol from the source server, open these files in the editor and finally navigate to the requested symbol.
Problem
Currently ISymbol that represents a metadata symbol does not expose its metadata token. It is possible to find the token within the metadata using MetadataReader APIs but it would involve reimplementing the metadata signature decoder logic that's already implemented in the compiler. Instead we propose to expose the token from ISymbol directly.
Proposal
interface ISymbol
{
...
/// <summary>
/// If this symbol represents a metadata entity returns its metadata token, otherwise returns 0.
/// </summary>
int MetadataToken { get; }
...
}The API would return 0 in all cases when the symbol is not backed by a metadata entity (internally implemented as a PE symbol).