SLaks/Ref12

F12 redirects to source.roslyn.codeplex.com/mscorlib/ instead of referencesource.microsoft.com

Closed this issue · 5 comments

If I press F12 on, say, String.Format(...) I end up on http://source.roslyn.codeplex.com/mscorlib/R/#c07c3772222caaff.html which displays a blank page (reponse body is empty), while it should probably end up at http://referencesource.microsoft.com/#mscorlib/system/string.cs,691a34e179b91fdb (or equivalent since there are multiple overloads of String.Format).

It looks to me like the RoslynReferenceResourceProvider accepts symbols from the BCL while it shouldn't, and gets selected before the DotNetReferenceSourceProvider in

var target = references.FirstOrDefault(r => r.AvailableAssemblies.Contains(symbol.AssemblyName));

I'm not exactly sure how I can enable or disable the Roslyn provider when the extension is installed?

This is due to the presence of mscorlib in this file: http://source.roslyn.codeplex.com/assemblies.txt (mscorlib;-1;127)

As a quick fix you can swap those classes:

[Export(typeof(IReferenceSourceProvider))]
public class RoslynReferenceSourceProvider : ReferenceSourceProvider {
[ImportingConstructor]
public RoslynReferenceSourceProvider(ILogger logger) : base(logger, "http://index", "http://source.roslyn.codeplex.com") {
}
}
[Export(typeof(IReferenceSourceProvider))]
public class DotNetReferenceSourceProvider : ReferenceSourceProvider {
[ImportingConstructor]
public DotNetReferenceSourceProvider(ILogger logger) : base(logger, "http://index", "http://referencesource.microsoft.com") {
}
}
This will force the DotNetReferenceSourceProvider to be lookup first in
var target = references.FirstOrDefault(r => r.AvailableAssemblies.Contains(symbol.AssemblyName));

Yes it seems that only types in mscorlib are incorrectly redirected to roslyn, while all others are correctly sent to referencesource (like Enumerable.Range which is not in mscorlib.dll).

Maybe someone mistakenly put mscorlib in the /assemblies.txt on source.roslyn.codeplex.com in the last update... Unfortunately I'm not sure who can be contacted to fix that?

This wouldn't be the right fix (since mscorlib has to be in that list for various other reasons).

Instead, you can ignore all lines in assemblies.txt which have -1 in their second column:

                // Format:
                // AssemblyName; ProjectIndex; DependentAssemblies
                var assemblies = new HashSet<string>(
                    assemblyList.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries)
                                .Where(s => !s.Contains(";-1;"))
                                .Select(s => s.Remove(s.IndexOf(';')))
                );

This will correctly filter out all assemblies not backed by a project.

SLaks commented

I'll release this later tonight.