dotnet / dotnet/aspnetcore

Report nullable warnings from netstandard2.0 targets when nullable is explicitly enabled

Open
#45,455 2 comments 0 reactions 1 assignee Claimed by @JamesNK View on GitHub
area-infrastructure
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 5h
Merged PRs (30d)
276

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Describe the bug

By default, netstandard2.0 projects will never report nullable warnings because of this configuration:

https://github.com/dotnet/aspnetcore/blob/d06bd3a79ba437322cb660127eb400a8a35a0220/eng/targets/CSharp.Common.targets#L125

There are some cases when a netstandard2.0 project still wants nullable reference warnings, e.g. analyzer projects. You can work around this by setting `SuppressNullableAttributesImport` to false, but that is hacky.

### Expected Behavior

netstandard2.0 targets should default to `annotations`. If a project is explicitly set to `enable` then they should report nullable warnings.

### Steps To Reproduce

_No response_

### Exceptions (if any)

_No response_

### .NET Version

_No response_

### Anything else?

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.