De_Vasta
De_Vasta

Reputation: 13

Syntax Highlighting isn't working correctly for c# 10.0 in vscode

Starting from c# 10.0 came a new way of a namespace declaration, aka File-Scoped. For Visual Studio 2022 all look fine, but not for VSCode: See the old way of namespace declaration and the new one.
And it's not up to the selected theme.
Is it possible to get around this problem?

Upvotes: 1

Views: 5554

Answers (2)

Zoran Horvat
Zoran Horvat

Reputation: 11301

I had the same issue recently. I think that OmniSharp is not up to date yet. To fix the issue, add these settings to the Settings JSON:

"editor.semanticHighlighting.enabled": true,
"csharp.semanticHighlighting.enabled": true,

That worked for me.

Upvotes: 7

Karl-Johan Sjögren
Karl-Johan Sjögren

Reputation: 17522

This works fine for me with VSCode 1.63 and C# extension version 1.23.17.

Sample picture with working highlightning for file level namespaces.

Make sure that both versions are up to date. It should auto update extensions and suggest updates for VSCode itself as default but it seems like it isn't updating properly for everyone (or at least not fast enough).

Upvotes: 1

Related Questions