From d7a2c7da18fac6ea813b2a23098898abdf9b448b Mon Sep 17 00:00:00 2001 From: Michael Nebel Date: Tue, 30 Sep 2025 11:23:58 +0200 Subject: [PATCH] C#: Adjust the QL library to use the locations of the unbound declarations. --- csharp/ql/lib/semmle/code/csharp/Callable.qll | 2 +- csharp/ql/lib/semmle/code/csharp/Event.qll | 4 ++-- csharp/ql/lib/semmle/code/csharp/Property.qll | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/csharp/ql/lib/semmle/code/csharp/Callable.qll b/csharp/ql/lib/semmle/code/csharp/Callable.qll index 7e17f853913..ef0d0673ce2 100644 --- a/csharp/ql/lib/semmle/code/csharp/Callable.qll +++ b/csharp/ql/lib/semmle/code/csharp/Callable.qll @@ -265,7 +265,7 @@ class Method extends Callable, Virtualizable, Attributable, @method { result = Virtualizable.super.getAnUltimateImplementor() } - override Location getALocation() { method_location(this, result) } + override Location getALocation() { method_location(this.getUnboundDeclaration(), result) } /** Holds if this method is an extension method. */ predicate isExtensionMethod() { this.getParameter(0).hasExtensionMethodModifier() } diff --git a/csharp/ql/lib/semmle/code/csharp/Event.qll b/csharp/ql/lib/semmle/code/csharp/Event.qll index a7079952478..39e2fdb7894 100644 --- a/csharp/ql/lib/semmle/code/csharp/Event.qll +++ b/csharp/ql/lib/semmle/code/csharp/Event.qll @@ -68,7 +68,7 @@ class Event extends DeclarationWithAccessors, @event { result = DeclarationWithAccessors.super.getAnUltimateImplementor() } - override Location getALocation() { event_location(this, result) } + override Location getALocation() { event_location(this.getUnboundDeclaration(), result) } override string getAPrimaryQlClass() { result = "Event" } } @@ -99,7 +99,7 @@ class EventAccessor extends Accessor, @event_accessor { override Event getDeclaration() { event_accessors(this, _, _, result, _) } - override Location getALocation() { event_accessor_location(this, result) } + override Location getALocation() { event_accessor_location(this.getUnboundDeclaration(), result) } } /** diff --git a/csharp/ql/lib/semmle/code/csharp/Property.qll b/csharp/ql/lib/semmle/code/csharp/Property.qll index 60ea83c3011..e651639b631 100644 --- a/csharp/ql/lib/semmle/code/csharp/Property.qll +++ b/csharp/ql/lib/semmle/code/csharp/Property.qll @@ -196,7 +196,7 @@ class Property extends DeclarationWithGetSetAccessors, @property { override PropertyAccess getAnAccess() { result.getTarget() = this } - override Location getALocation() { property_location(this, result) } + override Location getALocation() { property_location(this.getUnboundDeclaration(), result) } override Expr getAnAssignedValue() { result = DeclarationWithGetSetAccessors.super.getAnAssignedValue() @@ -328,7 +328,7 @@ class Indexer extends DeclarationWithGetSetAccessors, Parameterizable, @indexer result = DeclarationWithGetSetAccessors.super.getAnUltimateImplementor() } - override Location getALocation() { indexer_location(this, result) } + override Location getALocation() { indexer_location(this.getUnboundDeclaration(), result) } override string toStringWithTypes() { result = this.getName() + "[" + this.parameterTypesToString() + "]" @@ -408,7 +408,7 @@ class Accessor extends Callable, Modifiable, Attributable, Overridable, @callabl override Accessor getUnboundDeclaration() { accessors(this, _, _, _, result) } - override Location getALocation() { accessor_location(this, result) } + override Location getALocation() { accessor_location(this.getUnboundDeclaration(), result) } override string toString() { result = this.getName() } }