From c11adc8c286c19e83d76337505965382589d4ebd Mon Sep 17 00:00:00 2001 From: Tamas Vajk Date: Thu, 18 Apr 2024 08:49:48 +0200 Subject: [PATCH] C#: Adjust known type telemetry query --- csharp/ql/src/Telemetry/ExtractorInformation.ql | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/csharp/ql/src/Telemetry/ExtractorInformation.ql b/csharp/ql/src/Telemetry/ExtractorInformation.ql index febe2c91f91f..64f90e481706 100644 --- a/csharp/ql/src/Telemetry/ExtractorInformation.ql +++ b/csharp/ql/src/Telemetry/ExtractorInformation.ql @@ -134,10 +134,18 @@ module CallTargetStats implements StatsSig { string getNotOkText() { result = "calls with missing call target" } } +private class SourceExpr extends Expr { + SourceExpr() { this.getFile().fromSource() } +} + +private predicate hasGoodType(Expr e) { + exists(e.getType()) and not e.getType() instanceof UnknownType +} + module ExprTypeStats implements StatsSig { - int getNumberOfOk() { result = count(Expr e | not e.getType() instanceof UnknownType) } + int getNumberOfOk() { result = count(SourceExpr e | hasGoodType(e)) } - int getNumberOfNotOk() { result = count(Expr e | e.getType() instanceof UnknownType) } + int getNumberOfNotOk() { result = count(SourceExpr e | not hasGoodType(e)) } string getOkText() { result = "expressions with known type" }