Merge pull request #7628 from michaelnebel/csharp/issue-7609

C#: Fix false positive alert for shadowing on record types.
This commit is contained in:
Michael Nebel
2022-01-19 12:24:57 +01:00
committed by GitHub
3 changed files with 12 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
---
category: minorAnalysis
---
* The query `cs/local-shadows-member` no longer highlights parameters of `record` types.

View File

@@ -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
)
}

View File

@@ -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
}