Razor highlighting incorrect following an `as` keyword with a Null-Coalescing Operator in a @code block.
- Dominant language
- TypeScript
- Stars
- 3.1k
- Forks
- 737
- Avg merge
- 18h 40m
- Merged PRs (30d)
- 31
Description
## Issue Description ##
Syntax highlighting changes after an `as` statement with a Null-Coalescing Operator, for example `string var = e as bool ?? "";`.
## Steps to Reproduce ##
Create a new .razor file with the following contents:
```
Hello world
@code {
[Parameter]
public string Param1 { get; set; }
private async Foo() {
object e = "hello";
string var = e as bool ?? "";
}
private async Bar() {
}
}
```
## Expected Behavior ##
Syntax highlighting is maintained through the whole file.
## Actual Behavior ##
The "private" and "async" keywords on `Bar`, lose syntax highlighting.
Example:

## Logs ##
### OmniSharp log ###
Post the output from Output-->OmniSharp log here
### C# log ###
Post the output from Output-->C# here
## Environment information ##
**VSCode version**: 1.76.2
**C# Extension**: 1.25.5
Mono Information
There is a problem with running OmniSharp on mono: Error: Unable to find Mono. Ensure that Mono's '/bin' folder is added to your environment's PATH variable.
Dotnet Information
.NET SDK:
Version: 7.0.101
Commit: bb24aafa11
Runtime Environment:
OS Name: Mac OS X
OS Version: 13.0
OS Platform: Darwin
RID: osx.13-arm64
Base Path: /usr/local/share/dotnet/sdk/7.0.101/
Host:
Version: 7.0.1
Architecture: arm64
Commit: 97203d38ba
.NET SDKs installed:
6.0.201 [/usr/local/share/dotnet/sdk]
6.0.402 [/usr/local/share/dotnet/sdk]
6.0.404 [/usr/local/share/dotnet/sdk]
7.0.100 [/usr/local/share/dotnet/sdk]
7.0.101 [/usr/local/share/dotnet/sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.3 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.10 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.12 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.3 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.10 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.12 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.1 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Other architectures found:
x64 [/usr/local/share/dotnet/x64]
Environment variables:
Not set
global.json file:
Not found
Learn more:
https://aka.ms/dotnet/info
Download .NET:
https://aka.ms/dotnet/download
Visual Studio Code Extensions
|Extension|Author|Version|
|---|---|---|
|blazorwasm-companion|ms-dotnettools|1.1.4|
|csharp|ms-dotnettools|1.25.5|
|godot-tools|geequlim|1.3.1|
|intellicode-api-usage-examples|VisualStudioExptTeam|0.2.7|
|jbockle-format-files|jbockle|3.4.0|
|Kotlin|mathiasfrohlich|1.7.1|
|live-server|ms-vscode|0.4.7|
|multi-file-renamer|dandidevs|1.0.0|
|remote-containers|ms-vscode-remote|0.288.0|
|remote-wsl|ms-vscode-remote|0.76.1|
|terraform|hashicorp|2.25.4|
|vscode-docker|ms-azuretools|1.24.0|
|vscode-dotnet-runtime|ms-dotnettools|1.6.0|
|vscode-tailwindcss|bradlc|0.9.11|
|vscode-xml|redhat|0.24.0|
|vscodeintellicode|VisualStudioExptTeam|1.2.30|;
Contributor guide
Assessment
This issue has not been assessed yet.