Fix for google-code-prettify w/ c#

前端 未结 4 1191
忘掉有多难
忘掉有多难 2021-02-07 09:19

Prettify gives types and methods the same class when tokenizing c# so they are colored the same. This is because methods are pascal case in c# instead of camel case like in java

4条回答
  •  旧巷少年郎
    2021-02-07 10:00

    It is possible for identical syntax to have different meanings. There just isn't enough information to properly syntax highlight everything.

    Take a look at this example:

    static class Program
    {
        class Foo { public class Bar { public static void Func() { } } }
        class Foo2 { public static Baz Bar2 { get; set; } }
        class Baz { public void Func2() { } }
    
        static void Main()
        {
            Foo.Bar.Func();
            Foo2.Bar2.Func2();
        }
    }
    

    In the first line, Bar is an inner class, and should be highlighted green. In the second line, Bar2 is a property of type Foo2, and should be highlighted black. Both Func and Func2 are functions, and should be highlighted black.

    Here's how Visual Studio highlights that code.

    alt text

提交回复
热议问题