在C#8中,我们现在可以启用空值,这意味着引用类型默认情况下被编译器视为非空值,除非显式声明为可空。然而,当编译器试图返回带有notnull约束的默认泛型时,似乎仍然会抛出警告。TReturn : notnull return default; // default is flagged with a compiler warning for possible nullreference return
我将一个项目更新到NetCore 6,并收到警告: Converting null literal or possible null value to non-nullable type.例如,在单元测试中: String source = null;
String actual = source.ToSafeBase64Url(); 我在我的代码的多个地方收到了这个警告