代码检查:对由非可空基类型约束的类型参数的冗余 'notnull' 约束。
当另一个约束已经确保类型参数不能为空时,此检查会报告 notnull 约束。 在这种情况下,额外的 notnull 并不会强化约定。
示例
#nullable enable
using System;
class C
{
void M<T>() where T : notnull, IDisposable
{
}
}
#nullable enable
using System;
class C
{
void M<T>() where T : IDisposable
{
}
}
快速修复
快速修复将移除冗余的 notnull 约束。 这通常发生在非可空基类型约束已经使类型参数为非可空时。
2026年 5月 8日