ReSharper 2026.1 Help

代码检查:带有 [Optional] 属性的 'ref' 或 'out' 参数​.

此检查会报告使用 refout 声明的可选参数。 可选参数可以由调用方省略,但 refout 参数需要传递实际变量,因此这种组合是无效的。

示例

using System.Runtime.InteropServices; void Add([Optional] ref object template) { }
using System.Runtime.InteropServices; void Add([Optional] object template) { }

如何修复它

没有针对此检查的专用快速修复。 请移除 refout ,或将参数设为非可选。

2026年 5月 8日