Roslyn allows additional *primary_constraints* when the `notnull` primary constraint is used
- Dominant language
- C#
- Stars
- 20.7k
- Forks
- 4.3k
- PR merge metrics
- PR metrics pending
Description
**Version Used**:
C# 12 and C# 13, with LangVersion set from C# 8 through C# 13.
Use the following code:
```csharp
using System.IO;
public class C1 where T : notnull, Stream {}
public class C2 where T : notnull, Stream? {}
```
See [sharplab](https://sharplab.io/#v2:EYLgxg9gTgpgtADwGwBYA+ABADAAgwRgDoBJAeQG4BYAKBowGY8AmHAYXwB4AVAPhwHcAFjFg4uOEDgB2EAC5SArgBslAGhwBlWbACGAWxwBvAL51GGFqybc+QkTDETpcxSvVbdegPxHjQA=)
**Expected Behavior**:
According to [15.2.5](https://github.com/dotnet/csharpstandard/blob/draft-v8/standard/classes.md#1525-type-parameter-constraints) only one *primary_constraint* can be specified. The [Nullable reference types specification - 9.0](https://github.com/dotnet/csharplang/blob/main/proposals/csharp-9.0/nullable-reference-types-specification.md#notnull-constraint) classifies the `notnull` constraint as a primary constraint. Therefore, both the above declarations should be prohibited.
**Actual Behavior**:
Both declarations are allowed.
See https://github.com/dotnet/csharpstandard/pull/1178#issuecomment-2448424973
Contributor guide
Assessment
This issue has not been assessed yet.