Skip to content

Commit

Permalink
C#: Update AST printing to include generated cast (wrapping) expressi…
Browse files Browse the repository at this point in the history
…ons and generated ToString calls.
  • Loading branch information
michaelnebel committed Jan 10, 2025
1 parent 3754177 commit 33bc604
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion csharp/ql/lib/semmle/code/csharp/PrintAst.qll
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ private predicate shouldPrint(Element e, Location l) {
}

private predicate isImplicitExpression(ControlFlowElement element) {
element.(Expr).isImplicit() and
// Include compiler generated cast expressions and `ToString` calls if
// they wrap actual source expressions.
element.(Expr).stripImplicit().isImplicit() and
not element instanceof CastExpr and
not element.(OperatorCall).getTarget() instanceof ImplicitConversionOperator and
not element instanceof ElementInitializer
Expand Down

0 comments on commit 33bc604

Please sign in to comment.