From 3d82f38a4d1847f78f513d3087a338d784eb2a62 Mon Sep 17 00:00:00 2001 From: Xavier Pinho Date: Wed, 22 Jan 2025 17:09:18 +0000 Subject: [PATCH] [c#] fix erroneous not-handled-yet warning for MemberBindingExpression (#5244) --- .../astcreation/AstForExpressionsCreator.scala | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/joern-cli/frontends/csharpsrc2cpg/src/main/scala/io/joern/csharpsrc2cpg/astcreation/AstForExpressionsCreator.scala b/joern-cli/frontends/csharpsrc2cpg/src/main/scala/io/joern/csharpsrc2cpg/astcreation/AstForExpressionsCreator.scala index 6dd03044f057..947282524cf5 100644 --- a/joern-cli/frontends/csharpsrc2cpg/src/main/scala/io/joern/csharpsrc2cpg/astcreation/AstForExpressionsCreator.scala +++ b/joern-cli/frontends/csharpsrc2cpg/src/main/scala/io/joern/csharpsrc2cpg/astcreation/AstForExpressionsCreator.scala @@ -507,21 +507,15 @@ trait AstForExpressionsCreator(implicit withSchemaValidation: ValidationMode) { baseType: Option[String] = None ): Seq[Ast] = { val baseNode = createDotNetNodeInfo(condAccExpr.json(ParserKeys.Expression)) - val baseAst = astForNode(baseNode) - val baseTypeFullName = - if (getTypeFullNameFromAstNode(baseAst).equals(Defines.Any)) baseType - else Option(getTypeFullNameFromAstNode(baseAst)) + baseType.orElse(Some(getTypeFullNameFromAstNode(astForNode(baseNode)))).filterNot(_.equals(Defines.Any)) Try(createDotNetNodeInfo(condAccExpr.json(ParserKeys.WhenNotNull))).toOption match { case Some(node) => node.node match { - case ConditionalAccessExpression => - astForConditionalAccessExpression(node, baseTypeFullName) - case MemberBindingExpression => astForMemberBindingExpression(node, baseTypeFullName) - case InvocationExpression => - astForInvocationExpression(node) - case _ => astForNode(node) + case ConditionalAccessExpression => astForConditionalAccessExpression(node, baseTypeFullName) + case MemberBindingExpression => astForMemberBindingExpression(node, baseTypeFullName) + case _ => astForNode(node) } case None => Seq.empty[Ast] }