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

Inconsistent new syntax highlighting for C# #232

Closed
alexr00 opened this issue Nov 19, 2021 · 1 comment
Closed

Inconsistent new syntax highlighting for C# #232

alexr00 opened this issue Nov 19, 2021 · 1 comment

Comments

@alexr00
Copy link

alexr00 commented Nov 19, 2021

Originally from @gustavo-shigueo in microsoft/vscode#136442

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: 1.61.2
  • OS Version: Windows 10 21H1

Some keywords have the wrong scope causing weird syntax highlighting

Steps to Reproduce:

  1. Use more recent C# features such as target-typed new or the is not operation or the and/or keywords in a switch statement
  2. Open the command pallete
  3. Use the command "Developer: Inspect Editor Tokens and Scopes"

Sample code

using System;

namespace HelloWorld
{
	public class MyClass 
	{
		public MyClass()
		{
		}
	}

	class Program
	{
		static void Main(string[] args)
		{
			var stringArr = new[] { "", "" }; // new shows as keyword which is probably the expected behavior
			MyClass myClassInstance = new(); // new shows as a function call

			if (myClassInstance is not null) // is shows as keyword but not shows as a type annotation
			{
			}

			int x = 10;
			switch (x)
			{
				case > 1 and < 5 or 10: // both and and or show as variable names
					break;
				default:
					break;
			}
		}
	}
}

Screenshots:
image
image
image
image
image

@wise0704
Copy link
Contributor

wise0704 commented Aug 8, 2023

new is fixed in #258

pattern combinators are a separate issue (better described in #239)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants