Rule S1144: Unused private types or members should be removed tries to detect which private members can be removed as they are not called. If we look the following example:
public class Compliant
{
public int Value(int value) => new Durs(value)[3];
[DebuggerDisplay("{this[0]}, {this[1]}, {this[2]}, {this[3]}, {this[4]}")]
readonly record struct Durs(int Value)
{
public int this[int pos] => (Value >> (pos << 2)) & 7; // FP: Called by both Value as DebuggerDisplay.
}
}
We see that it reports that the index property is not used. If we remove the [DebuggerDisplay] declaration the warning disappears.
In this example, the debugger display even references the index property, but the content of the [DebuggerDisplay] does not seems to make a difference.
Reported by SonarAnalyzer.CSharp v10.16.1.129956.