mirror of
https://github.com/github/codeql.git
synced 2026-04-28 18:25:24 +02:00
Merge pull request #7628 from michaelnebel/csharp/issue-7609
C#: Fix false positive alert for shadowing on record types.
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
---
|
||||
category: minorAnalysis
|
||||
---
|
||||
* The query `cs/local-shadows-member` no longer highlights parameters of `record` types.
|
||||
@@ -39,6 +39,10 @@ private predicate acceptableShadowing(LocalScopeVariable v, Member m) {
|
||||
)
|
||||
or
|
||||
t.getAConstructor().getAParameter() = v
|
||||
or
|
||||
// Record types have auto-generated Deconstruct methods, which declare an out parameter
|
||||
// with the same name as the property field(s).
|
||||
t.(RecordType).getAMethod("Deconstruct").getAParameter() = v
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -61,4 +61,8 @@ class LocalScopeVariableShadowsMember
|
||||
{
|
||||
public C4(int f) { } // GOOD
|
||||
}
|
||||
|
||||
record class GoodRecordClass(object Prop1, object Prop2) { } // GOOD
|
||||
|
||||
record struct GoodRecordStruct(object Prop1, object Prop2) { } // GOOD
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user