From 8b65cb09f6c658c13d1fa84f727a6c08781765b2 Mon Sep 17 00:00:00 2001 From: Michael Nebel Date: Tue, 21 Oct 2025 13:35:40 +0200 Subject: [PATCH 1/2] C#: Enable overlay compilation in lib/qlpack.yml. --- csharp/ql/lib/qlpack.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/csharp/ql/lib/qlpack.yml b/csharp/ql/lib/qlpack.yml index 92a08088be73..f8ee05e306f4 100644 --- a/csharp/ql/lib/qlpack.yml +++ b/csharp/ql/lib/qlpack.yml @@ -18,3 +18,4 @@ dataExtensions: - ext/*.model.yml - ext/generated/*.model.yml warnOnImplicitThis: true +compileForOverlayEval: true From 034372728fb46a84ed558ff5ae41953c4c984b3a Mon Sep 17 00:00:00 2001 From: Michael Nebel Date: Wed, 29 Oct 2025 15:49:43 +0100 Subject: [PATCH 2/2] C#: Fix bad join due to overlay compilation. --- csharp/ql/lib/semmle/code/csharp/Conversion.qll | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/csharp/ql/lib/semmle/code/csharp/Conversion.qll b/csharp/ql/lib/semmle/code/csharp/Conversion.qll index 7a1314abe163..99c58ee51c68 100644 --- a/csharp/ql/lib/semmle/code/csharp/Conversion.qll +++ b/csharp/ql/lib/semmle/code/csharp/Conversion.qll @@ -719,6 +719,15 @@ private Type convTypeParameterBase(TypeParameter tp) { result = getATypeParameterFromConstraints+(tp) } +pragma[noinline] +private Class typeConstraintToBaseType(TypeParameterConstraints tpc) { + tpc.hasValueTypeConstraint() and result instanceof SystemValueTypeClass + or + result = tpc.getATypeConstraint() + or + tpc.hasRefTypeConstraint() and result instanceof ObjectType +} + /** * 10.1.5: Candidates for the effective base class of type parameter `tp`. * @@ -731,13 +740,9 @@ private Class effectiveBaseClassCandidate(TypeParameter tp) { not hasPrimaryConstraints(tp) and result instanceof ObjectType or exists(TypeParameterConstraints tpc | tpc = tp.getConstraints() | - tpc.hasValueTypeConstraint() and result instanceof SystemValueTypeClass - or - result = tpc.getATypeConstraint() + result = typeConstraintToBaseType(tpc) or result = effectiveBaseClassCandidate(tpc.getATypeConstraint()) - or - tpc.hasRefTypeConstraint() and result instanceof ObjectType ) }