Open nalka0 opened 1 month ago
S1450 is raised on the following snippet despite foundMultiple being used on both methods
foundMultiple
private class LookForSinglePropertyAccessExpressionVisitor : ExpressionVisitor { private PropertyInfo foundProperty; private bool foundMultiple; // S1450 FP here (but it's used on both methods) public PropertyInfo GetUsedProperty(Expression expression) { foundProperty = null; foundMultiple = false; Visit(expression); if (foundMultiple) { throw new ArgumentException($"{expression} contains more than one property access", nameof(expression)); } return foundProperty ?? throw new ArgumentException($"{expression} contains no property access", nameof(expression)); } protected override Expression VisitMember(MemberExpression node) { if (node.Member is PropertyInfo prop) { if (foundProperty != null) { foundMultiple = true; } foundProperty = prop; } return base.VisitMember(node); } }
No occurrence of S1450 in the above snippet
S1450 is raised on the above snippet despite foundMultiple being used on both methods
None
Hi @nalka0!
It's a FP, indeed. I discovered that we already have a reproducer for this on our repo. I'll make sure to add a link to this since it seems we don't have a ticket for it yet.
Thanks,
Description
S1450 is raised on the following snippet despite
foundMultiple
being used on both methodsRepro steps
Expected behavior
No occurrence of S1450 in the above snippet
Actual behavior
S1450 is raised on the above snippet despite
foundMultiple
being used on both methodsKnown workarounds
None
Related information