dotnet / vscode-csharp

Official C# support for Visual Studio Code
MIT License
2.88k stars 676 forks source link

syntax highlighting fails in new anonymous object with LINQ #3044

Closed vispariana closed 2 weeks ago

vispariana commented 5 years ago

Defining a new anonumous object having a field valued by LINQ breaks syntax highlighting.

Steps to reproduce: write the following code

public class Program {
    [Attribute1]
    [Attribute2(P = 1)]
    public static void Main(string[] args) {
        for(int i = 0; i < 10; i++) {}
        var a = new {Field1 = from a in b select a}};
        for(int i = 0; i < 10; i++) {}
    }
    [Attribute1]
    [Attribute2(P = 1)]
    public static void Method() {
    }
}

Note: found out that if i put parentheses around the LINQ it is fixed, but i think it should be working without the parentheses either, because the code also works that way!

victormikael commented 2 years ago

It´s not just with Linq, it happens with any anonymous type.

image

yuriyzaynulin commented 2 years ago

happening here as well image

victormikael commented 1 year ago

Any update on this?

JoeRobich commented 2 weeks ago

Since this issue was opened we have added semantic highlighting support as well as a much improved textmate grammar.