Code inspection: 'ref' or 'out' parameter with [Optional] attribute
This inspection reports an optional parameter declared with ref or out. Optional arguments can be omitted by the caller, but ref and out parameters require an actual variable to be passed, so the combination is invalid.
Example
using System.Runtime.InteropServices;
void Add([Optional] ref object template)
{
}
using System.Runtime.InteropServices;
void Add([Optional] object template)
{
}
How to fix it
There is no dedicated quick-fix for this inspection. Remove ref or out, or make the parameter non-optional.
01 April 2026