KirillOsenkov / SourceBrowser

Source browser website generator that powers http://referencesource.microsoft.com and http://sourceroslyn.io
Apache License 2.0
1.08k stars 197 forks source link

Add support for clicking Target-typed new expressions #202

Closed eerhardt closed 3 years ago

eerhardt commented 3 years ago

With the Target-typed new expression feature, it removes the ability to click on a constructor and source.dot.net takes me to the constructor being called.

Take this code for example:

https://github.com/dotnet/aspnetcore/blob/f993b272df3187500f5afef52dc9a726118cfbc0/src/DefaultBuilder/src/WebApplication.cs#L101-L107

    /// <summary>
    /// Initializes a new instance of the <see cref="WebApplicationBuilder"/> class with preconfigured defaults.
    /// </summary>
    /// <param name="args">Command line arguments</param>
    /// <returns>The <see cref="WebApplicationBuilder"/>.</returns>
    public static WebApplicationBuilder CreateBuilder(string[] args) =>
        new(new() { Args = args });

There is no way for me to navigate to that inner new() expression in https://source.dot.net/#Microsoft.AspNetCore/WebApplication.cs,107.

We support add support for clicking the new() expression, and it should take me to the constructor being invoked.

KirillOsenkov commented 3 years ago

If you wanted to take a stab at it, here's where it would happen: https://github.com/KirillOsenkov/SourceBrowser/blob/6e4900c1087e66523834541cf5e6db3af8cb4d18/src/HtmlGenerator/Pass1-Generation/DocumentGenerator.Links.cs#L53

Honestly just by looking at that code if you remove that check it might just work by default.

git clone the repo, then make the fix, then GenerateTestSite.cmd, then RunTestSite.cmd to test

eerhardt commented 3 years ago

Thanks for the pointer, @KirillOsenkov. I might take a stab at it if I get time, it should be fun to learn.