Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nullable and IAsyncEnumerable break syntax highlighting #1786

Closed
jaredpar opened this issue May 8, 2020 · 3 comments
Closed

Nullable and IAsyncEnumerable break syntax highlighting #1786

jaredpar opened this issue May 8, 2020 · 3 comments
Labels

Comments

@jaredpar
Copy link

jaredpar commented May 8, 2020

This will reproduce on pretty much every C# project I've tested, even dotnet new console.

Type in the following code to the editor

            string s1 = "hello"; // string is colored
            await foreach (var x in e) { }
            string s2 = "world"; // string is not colored

Notice that the presence of await foreach causes the second usage of string to not get properly syntax highlighted. It will be white instead of blue. The moment you delete await then everything will snap back to normal.

This problem appears to impact a number of C# 8 features. For instance the same effect occurs when using a nullable array.

            string s1 = "hello"; // string is colored
            int[]? example;
            string s2 = "world"; // string is not colored
@jaredpar
Copy link
Author

jaredpar commented May 8, 2020

One way to work around this is to add an empty statement after the await foreach

                ; // empty statement to fix vs code syntax bug around await foreach

@filipw
Copy link
Member

filipw commented May 10, 2020

This is really an issue of C# extension for VS Code not of OmniSharp.
It uses https://github.com/dotnet/csharp-tmLanguage for highlighting, which is very limited and hasn't been updated in quite a while.

OmniSharp exposes semantic highlighting endpoint based on Roslyn's semantic highlighting (I added your two cases as tests here to make sure they are covered (#1789)) but at the moment the C# extension still doesn't use that endpoint - it's a work in progress to incorporate it github.com/dotnet/vscode-csharp/pull/3667

@filipw
Copy link
Member

filipw commented Jun 6, 2020

this is resolved via semantic highlighting

@filipw filipw closed this as completed Jun 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants