diff --git a/joern-cli/frontends/csharpsrc2cpg/src/main/scala/io/joern/csharpsrc2cpg/astcreation/AstForDeclarationsCreator.scala b/joern-cli/frontends/csharpsrc2cpg/src/main/scala/io/joern/csharpsrc2cpg/astcreation/AstForDeclarationsCreator.scala index 0b15556d0433..c594efead85f 100644 --- a/joern-cli/frontends/csharpsrc2cpg/src/main/scala/io/joern/csharpsrc2cpg/astcreation/AstForDeclarationsCreator.scala +++ b/joern-cli/frontends/csharpsrc2cpg/src/main/scala/io/joern/csharpsrc2cpg/astcreation/AstForDeclarationsCreator.scala @@ -535,6 +535,7 @@ trait AstForDeclarationsCreator(implicit withSchemaValidation: ValidationMode) { case "readonly" => newModifierNode(ModifierTypes.READONLY) case "virtual" => newModifierNode(ModifierTypes.VIRTUAL) case "const" => newModifierNode(CSharpModifiers.CONST) + case "abstract" => newModifierNode(ModifierTypes.ABSTRACT) case x => logger.warn(s"Unhandled modifier name '$x'") null diff --git a/joern-cli/frontends/csharpsrc2cpg/src/test/scala/io/joern/csharpsrc2cpg/querying/ast/ClassDeclarationTests.scala b/joern-cli/frontends/csharpsrc2cpg/src/test/scala/io/joern/csharpsrc2cpg/querying/ast/ClassDeclarationTests.scala new file mode 100644 index 000000000000..dbf957cd7c5b --- /dev/null +++ b/joern-cli/frontends/csharpsrc2cpg/src/test/scala/io/joern/csharpsrc2cpg/querying/ast/ClassDeclarationTests.scala @@ -0,0 +1,22 @@ +package io.joern.csharpsrc2cpg.querying.ast + +import io.joern.csharpsrc2cpg.testfixtures.CSharpCode2CpgFixture +import io.shiftleft.codepropertygraph.generated.ModifierTypes +import io.shiftleft.semanticcpg.language.* + +class ClassDeclarationTests extends CSharpCode2CpgFixture { + + "empty abstract class" should { + val cpg = code(""" + |abstract class C {} + |""".stripMargin) + + "have correct modifiers" in { + cpg.typeDecl.nameExact("C").modifier.modifierType.sorted.l shouldBe List( + ModifierTypes.ABSTRACT, + ModifierTypes.INTERNAL + ) + } + } + +} diff --git a/joern-cli/frontends/csharpsrc2cpg/src/test/scala/io/joern/csharpsrc2cpg/querying/ast/MethodTests.scala b/joern-cli/frontends/csharpsrc2cpg/src/test/scala/io/joern/csharpsrc2cpg/querying/ast/MethodTests.scala index 474b6a0251ea..15730d42442c 100644 --- a/joern-cli/frontends/csharpsrc2cpg/src/test/scala/io/joern/csharpsrc2cpg/querying/ast/MethodTests.scala +++ b/joern-cli/frontends/csharpsrc2cpg/src/test/scala/io/joern/csharpsrc2cpg/querying/ast/MethodTests.scala @@ -77,4 +77,19 @@ class MethodTests extends CSharpCode2CpgFixture { } } + "empty public abstract method" should { + val cpg = code(""" + |abstract class C + |{ + | public abstract void DoStuff(); + |} + |""".stripMargin) + + "have correct modifiers" in { + cpg.method.nameExact("DoStuff").modifier.modifierType.sorted.l shouldBe List( + ModifierTypes.ABSTRACT, + ModifierTypes.PUBLIC + ) + } + } }