Nullability removed when creating anonymous type
- Dominant language
- C#
- Stars
- 20.7k
- Forks
- 4.3k
- PR merge metrics
- PR metrics pending
Description
**Version Used**:
```
$ dotnet --version
10.0.201
```
**Steps to Reproduce**:
Repro: https://lab.razor.fyi/#fY9BSwMxEIXp3jI3exLxMOSk0IZkoQVZREQvCop4FcEY0yWyJiXJbpUlf8R_4L-UDdUtHrwMj_e9x8zAVwFw513t5RtTYfpZgGpkCLj1oAdExBBlNAo7Z17wRhp7dJztHggJ0Rtb48PjGdq2ac69lx94mnX1B7vb3YDe4C_EHumlfm5rOkN6rxstg6aYKgBCOulx7d2rVvHKrlzYdocSEEIGnQW5cHZl6tbLaJzNsZ91s4GnPP-Lj_eNhVTlTxMkmO4t2JLxecnKpVicMCHKg33BGWd8vva6M3ozEnooBONM8B020utChafJ--Qb
Sample code:
```cs
string []? nullArray = null;
string []? noNullArray = new string [] { "Debug", "Release" };
var projectInfos = new [] {
new {
Configurations = nullArray,
},
new {
Configurations = noNullArray,
},
};
```
**Expected Behavior**:
No warning
**Actual Behavior**:
> warning CS8619: Nullability of reference types in value of type '' doesn't match target type ''.
It seems the nullable `noNullArray` ends up being a non-nullable type at some point, causing a type mismatch in the anonymous type.
Contributor guide
Assessment
This issue has not been assessed yet.