I updated a project to NetCore 6 and I am getting the warning:
Converting null literal or possible null value to non-nullable type.
For example on a unit test:
String source = null;
String expect = null;
String actual = source.ToSafeBase64Url();
I am getting this warning in multiple places of my code.
How should I solve this?
In the new .NET6 templates, nullable reference types are enabled by default. You can see this if you open the csproj file, the line:
<Nullable>enable</Nullable>
That warning is telling you that you are assigning a null to a non-nullable type. To fix it, make the strings nullable:
string? source = null;
string? expect = null;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With