Code inspection: 'DefaultParameterValueAttribute' must be used in conjunction with 'OptionalAttribute'
This inspection reports DefaultParameterValueAttribute when it is used without OptionalAttribute. In that form, the default value metadata is meaningless to callers.
Example
using System.Runtime.InteropServices;
void M([DefaultParameterValue("text")] string value)
{
}
Quick-fix
There is no dedicated quick-fix for this inspection. A typical improvement is to either add OptionalAttribute or remove DefaultParameterValueAttribute if the parameter is not actually optional.
13 April 2026