File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed
csharp/ql/lib/semmle/code/csharp/exprs Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -223,6 +223,42 @@ class ParameterAccess extends LocalScopeVariableAccess, @parameter_access_expr {
223223 override string getAPrimaryQlClass ( ) { result = "ParameterAccess" }
224224}
225225
226+ /**
227+ * An access to a synthetic parameter for an extension method, for example the
228+ * access to `s` on line 3 in
229+ *
230+ * ```csharp
231+ * static class MyExtensions {
232+ * extension(string s) {
233+ * public bool IsEmpty() { return s == string.Empty; }
234+ * }
235+ * }
236+ * ```
237+ */
238+ class SyntheticParameterAccess extends ParameterAccess {
239+ private Parameter p ;
240+
241+ SyntheticParameterAccess ( ) {
242+ exists ( ExtensionType et |
243+ p = et .getReceiverParameter ( ) and
244+ expr_access ( this , p )
245+ )
246+ }
247+
248+ override Parameter getTarget ( ) {
249+ exists ( ExtensionCallable c |
250+ this .getEnclosingCallable + ( ) = c and
251+ result = c .getParameter ( 0 )
252+ )
253+ }
254+
255+ override string toString ( ) {
256+ result = "access to synthetic parameter " + this .getTarget ( ) .getName ( )
257+ }
258+
259+ override string getAPrimaryQlClass ( ) { result = "SyntheticParameterAccess" }
260+ }
261+
226262/**
227263 * An access to a parameter that reads the underlying value, for example
228264 * the access to `p` on line 2 in
You can’t perform that action at this time.
0 commit comments