Skip to content

Commit 33671c9

Browse files
committed
C#: Shift arguments to extension property calls as the qualifier is an explicit argument to the getter/setter.
1 parent 33361c6 commit 33671c9

File tree

1 file changed

+15
-1
lines changed
  • csharp/ql/lib/semmle/code/csharp/exprs

1 file changed

+15
-1
lines changed

csharp/ql/lib/semmle/code/csharp/exprs/Call.qll

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,21 @@ class IndexerCall extends AccessorCall, IndexerAccessExpr {
722722
* ```
723723
*/
724724
class ExtensionPropertyCall extends PropertyCall {
725-
ExtensionPropertyCall() { this.getProperty() instanceof ExtensionProperty }
725+
private ExtensionProperty prop;
726+
727+
ExtensionPropertyCall() { this.getProperty() = prop }
728+
729+
override Expr getArgument(int i) {
730+
if prop.isStatic()
731+
then result = super.getArgument(i)
732+
else (
733+
// Shift arguments as the qualifier is an explicit argument in the getter/setter.
734+
i = 0 and
735+
result = this.getQualifier()
736+
or
737+
result = super.getArgument(i - 1)
738+
)
739+
}
726740

727741
override string getAPrimaryQlClass() { result = "ExtensionPropertyCall" }
728742
}

0 commit comments

Comments
 (0)