We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
"CS8602 - Dereference of a possibly null reference" isn't raised at build time (with dotnet build) when the error is in a collection expression.
dotnet build
List<string>? a = null; string[]? c = [.. a];
In VS Code (with C# extension) I can see a yellow squiggly line under a at line 2, but when running dotnet build, there's no warning raised.
a
When <WarningsAsErrors>nullable</WarningsAsErrors> is set on the project, the build should fail, but doesn't.
<WarningsAsErrors>nullable</WarningsAsErrors>
dotnet --info output:
dotnet --info
.NET SDK: Version: 8.0.404 Commit: 7b190310f2 Workload version: 8.0.400-manifests.b1234fe1 MSBuild version: 17.11.9+a69bbaaf5 Runtime Environment: OS Name: Windows OS Version: 10.0.19045 OS Platform: Windows RID: win-x64 Base Path: C:\Program Files\dotnet\sdk\8.0.404\ .NET workloads installed: Configured to use loose manifests when installing new manifests. There are no installed workloads to display. Host: Version: 9.0.0 Architecture: x64 Commit: 9d5a6a9aa4 .NET SDKs installed: 8.0.404 [C:\Program Files\dotnet\sdk] 9.0.101 [C:\Program Files\dotnet\sdk] .NET runtimes installed: Microsoft.AspNetCore.App 8.0.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 9.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 6.0.33 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 8.0.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 9.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 8.0.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 8.0.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 9.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Other architectures found: None Environment variables: Not set global.json file: C:\Users\cbao\Downloads\cstest\hello\global.json Learn more: https://aka.ms/dotnet/info Download .NET: https://aka.ms/dotnet/download
IDE: VS Code with C# extension (no C# Dev Kit)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Describe the bug
"CS8602 - Dereference of a possibly null reference" isn't raised at build time (with
dotnet build
) when the error is in a collection expression.To Reproduce
List<string>? a = null; string[]? c = [.. a];
In VS Code (with C# extension) I can see a yellow squiggly line under
a
at line 2, but when runningdotnet build
, there's no warning raised.When
<WarningsAsErrors>nullable</WarningsAsErrors>
is set on the project, the build should fail, but doesn't.Further technical details
dotnet --info
output:IDE: VS Code with C# extension (no C# Dev Kit)
The text was updated successfully, but these errors were encountered: