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

Code wrapped in defines not highlighting correctly with Unity #2461

Closed
ahuertabhg opened this issue Aug 16, 2018 · 6 comments
Closed

Code wrapped in defines not highlighting correctly with Unity #2461

ahuertabhg opened this issue Aug 16, 2018 · 6 comments

Comments

@ahuertabhg
Copy link

ahuertabhg commented Aug 16, 2018

Environment data

VS Code version: 1.26
C# Extension version: 1.15.2
Unity version: 2017.3.1f1 .Net3.5
OS: Windows 10

Steps to reproduce

  1. Create unity project
  2. Create code with defined out code Ex. #if UNITY_ANDROID

Expected behavior

Code that is not being compiled due to defines should be grayed out

Actual behavior

Code looks normal or has incorrect highlighting. In the screenshot below the highlighting at the top is reversed because the RECORD_RAND_FLOAT_CALLS is not defined. Hovering works as expected with the defined out code not giving any results. You can also see towards the bottom that another #if #else has different behavior with the same define.
image 3

I've also looked at the Assembly-CSharp.csproj file and confirmed that it does contain a UNITY_ANDROID define but highlighting does not occur.

@DustinCampbell
Copy link
Member

Unfortunately, there's not much we can do about this at the moment. Today, VS Code colorization is handled with regular expressions rather than a proper parse tree that properly represents code surrounded by conditional compilation symbols. So, it's very easy to trick the colorization.

In this case, the content between the end of the method declaration header and opening curly brace of the method body are not considered colorable by the regular expression engine.

@ahuertabhg
Copy link
Author

Is it now possible to solve this with the new Semantic Token API?

@GideonUng
Copy link

Good thing that the code editor from micrsoft when used by the language made by microsoft is unable to do simple syntax highlighting. What an age of technology we live in

@XeonG
Copy link

XeonG commented Apr 17, 2021

ffs when is this getting fix in vscode? still broken

@JoeRobich
Copy link
Member

@XeonG This should be handed by semantic highlighting. Do you have csharp.semanticHighlighting.enable set to true in your vscode settings?

@heartacker
Copy link
Contributor

@XeonG This should be handed by semantic highlighting. Do you have csharp.semanticHighlighting.enable set to true in your vscode settings?

why don't you make it true by default?curiousness

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

No branches or pull requests

6 participants