JetBrains Rider 2026.2 Help

代码检查:冗余的空 'with()'

此检查会报告 C# 集合表达式中空的 with() 元素。 空的 with() 不会传递构造函数实参,也不会改变集合内容,因此可以移除。

示例

using System.Collections.Generic; List<int> numbers = [with(), 1, 2, 3];
using System.Collections.Generic; List<int> numbers = [1, 2, 3];

快速修复

从集合表达式中移除空的 with() 元素。

2026年 7月 17日