代码检查:类无法实例化
此检查会报告无法实例化的类。 这通常意味着该类只有私有构造函数,且没有实例创建路径。 这种类通常用于作为 static 工具类,或者缺少调用方所需的构造函数。
示例
public sealed class StringUtil
{
private StringUtil() { }
public static string CustomSplit(string s, char c)
{
return s;
}
}
public static class StringUtil
{
public static string CustomSplit(string s, char c)
{
return s;
}
}
快速修复
此检查可提供修复建议,例如将该类转换为 static 类,或在需要时生成构造函数。
2026年 5月 8日