Description
In order to improve Go To Definition in Metadata experience (dotnet/roslyn#24349) the IDE needs a way to find all implementation assemblies that have shipped for a given reference assembly.
There are to main cases to consider:
a) the reference assembly is in a package in the nuget cache
b) the assembly does not ship in a package (it’s in a reference assemblies directory in an SDK)
[a] is trivial to make work. We just walk the nuget cache directory structure starting with the reference assembly path and find the lib directory that has implementation assemblies. We gather implementation assemblies for all TFMs from there.
[b] is more complicated. What need is a map of reference assembly identity to the MVID of the latest version of implementation assembly for each supported TFM.
This map would need to be updated as the products that ship the implementation assemblies evolve (both .NET Framework and .NET Core).
The main question is how would this map be distributed. Since .NET Framework doesn’t change that often, and if so the changes usually affect only a few source files, we could ship the map with the IDE and update it every time the IDE is updated.
.NET SDK could also ship with the map and if there is a way to locate it reliably based on the location of the reference assembly.
The IDE would use this map as follows.
When the user navigates from source file to a metadata symbol that comes from a reference assembly, the IDE queries the map to find a list of all TFMs that the reference has an implementation for.
The IDE considers the project context the current source file is opened in (displayed above the text buffer on the left in a combo box in VS). Based on the project context TFM it select the most appropriate TFM the reference assembly has an implementation for and queries the Microsoft symbol server for the MVID of the implementation assembly as well as for the PDB corresponding to this implementation assembly (both MVID and PDB ID would be stored in the map). Once the implementation assembly and PDB is available the IDE finds the metadata symbol in the implementation assembly and determines what source file contains its definition based on debug information in the PDB. It then uses Source Link record present in the PDB to locate the source file on GitHub, it downloads the source file and opens it in the editor. It also fills the project context combo-box with TFMs that the reference assembly is available for and with an extra item that represents the reference assembly itself. This allows the user to switch to a different TFM, repeat the above process and see the source of the symbol definition in other implementation assemblies, or just the declaration header of the reference assembly.