JetBrains Rider 2026.1 Help

代码检查:“ref” 或 “out” 参数使用 [Optional] 特性

此检查会报告使用 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日