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

Declaration identifier tokens are not highlighted as type names except for interfaces #184

Open jnm2 opened 3 years ago

jnm2 commented 3 years ago

Visual Studio/SourceBrowser: image image

Also, I've really become accustomed to VS and VS Code's advanced styling for structs, enums, interfaces, and type parameters.

jnm2 commented 3 years ago

@KirillOsenkov Wonder if there is a correlation between the fact that interfaces are different than other types here and the same thing in https://github.com/KirillOsenkov/SourceBrowser/issues/179

KirillOsenkov commented 3 years ago

could be. We should check which classification(s) are returned by Roslyn for these, could be we need to filter some out (like we already do for static symbol)

KirillOsenkov commented 3 years ago

Hmm, I can't reproduce this: image

I've added this sample to the test code, so you can just GenerateTestSite.cmd and RunTestSite.cmd to check: https://github.com/KirillOsenkov/SourceBrowser/commit/ea86c3dfac044ee76fec43a3d884006842b2e49d

Check http://localhost:5000/Project2/diagnostics.txt, maybe you have errors that prevent the classifier from working properly? Each project generates a diagnostics.txt with a list of diagnostics for that project returned by Roslyn.

We don't have distinct classification for various type kinds, this is a relatively recent addition to VS.

jnm2 commented 3 years ago

I still repro by debugging HtmlGenerator to point it at a .sln file that points to these two files (Repro.zip):

void M<SomeTypeParameter>(
    SomeClass a,
    SomeStruct b,
    SomeRecord c,
    SomeEnum d,
    SomeInterface e,
    SomeDelegate f,
    SomeTypeParameter g)
{
}

class SomeClass { }
struct SomeStruct { }
record SomeRecord;
enum SomeEnum { }
interface SomeInterface { }
delegate void SomeDelegate();

And:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net5.0</TargetFramework>
  </PropertyGroup>

</Project>

The repro project builds successfully before running HtmlGenerator.

The debug arguments are:

"C:\Users\Joseph\Source\Repos\Repro\Repro.sln" /out:$(SolutionDir)src\SourceIndexServer\index /force

Diagnostics.txt:

C:\Users\Joseph\Source\Repos\Repro\Repro\Program.cs(1,6): warning CS8321: The local function 'M' is declared but never used
C:\Users\Joseph\Source\Repos\Repro\Repro\obj\Debug\net5.0\Repro.AssemblyInfo.cs(12,1): hidden CS8019: Unnecessary using directive.
C:\Users\Joseph\Source\Repos\Repro\Repro\obj\Debug\net5.0\.NETCoreApp,Version=v5.0.AssemblyAttributes.cs(2,1): hidden CS8019: Unnecessary using directive.
C:\Users\Joseph\Source\Repos\Repro\Repro\obj\Debug\net5.0\.NETCoreApp,Version=v5.0.AssemblyAttributes.cs(3,1): hidden CS8019: Unnecessary using directive.
C:\Users\Joseph\Source\Repos\Repro\Repro\obj\Debug\net5.0\Repro.AssemblyInfo.cs(11,1): hidden CS8019: Unnecessary using directive.
jnm2 commented 3 years ago

I'll do some digging as I have time too.

We don't have distinct classification for various type kinds, this is a relatively recent addition to VS.

I'd be interested in implementing this.

KirillOsenkov commented 3 years ago

You can see that I picked a single-letter css class for types, to minimize the html as much as possible. If you introduce new css for type kinds, see if you can minimize resulting Html. Otherwise it should be pretty straightforward. It’s all in Pass1, around Document*.cs and Classifier.