S4158 FP: Collection filled using delegates #4261
Labels
Area: C#
C# rules related issues.
Area: CFG/SE
CFG and SE related issues.
Type: CFG/SE FPs
Rule IS triggered when it shouldn't be for CFG and SE rules.
Milestone
Description
In one of our unit tests, S4158 triggers false positives, the collection clearly is not empty when S4158 claims it is.
Repro steps
This is a cut down snippet from one of our unit tests, requires FluentAssertions (or replace with your favorite assertion syntax).
Expected behavior
The rule does not fire when delegates of any methods which can add members have been passed as callback somewhere.
Actual behavior
The rule fires
Known workarounds
Wrap the delegate in a lambda:
Related information
The text was updated successfully, but these errors were encountered: