Skip to content

Commit 194da45

Browse files
committed
C#: Add record deconstruct method as an exception from the bad practice rule.
1 parent 2eea6ca commit 194da45

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

csharp/ql/src/Bad Practices/Declarations/LocalScopeVariableShadowsMember.ql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ private predicate acceptableShadowing(LocalScopeVariable v, Member m) {
3939
)
4040
or
4141
t.getAConstructor().getAParameter() = v
42+
or
43+
// Record types have auto-generated Deconstruct methods, which declare an out parameter
44+
// with the same name as the property field(s).
45+
t.(RecordType).getAMethod("Deconstruct").getAParameter() = v
4246
)
4347
}
4448

0 commit comments

Comments
 (0)