SCA1048: Member Nested Too Deeply
Break up code that is nested too deeply to be checked.
Example
string Join(string a) => a + a + a + a + /* ... thousands more ... */ a; // SCA1048: the member is not checked
string Join(string a) // OK: built in steps
{
var builder = new StringBuilder();
for (int i = 0; i < 5000; i++) builder.Append(a);
return builder.ToString();
}
How to Fix
Break up the expression, with locals or with methods of its own.
Details
A member is nested too deeply for the analyzer, which walks an expression by recursion and stops before the stack runs out. That is a chain of thousands of operators, hundreds of nested ?:, or a thousand chained calls.
The member is not checked, and a copy in it gets no warning. This warning says so, at the member, so that a member that is not checked never looks clean. The other members are checked as usual.
See Also
These articles explain the rule behind this warning:
- Turning Rules Down - suppressing this warning where a member stays unchecked on purpose.
Didn't add this analyzer yourself? See Why Am I Seeing This?