A Three-Phase Approach to Efficiently Transform C# into KDM
The Knowledge Discovery Metamodel (KDM) of the Object Management Group (OMG) is used in diverse research areas for describing software artifacts. It was recently adopted as standard ISO/IEC 19506 and its source, code, and action packages are highly suited for enabling language-independent source code analysis. However, a program needs to be transformed to KDM before corresponding source level metrics can be computed. To be of practical use, such a transformation (1) has to be resource-efficient and (2) ideally can be constructed on the basis of existing grammars to mitigate construction effort for a specific programming language. In this paper, we present such an efficient transformation for C# that is structured along three fundamental phases covering distinct sub-transformations for the types, members and methods, and statements. As our approach systematically analyzes and re-engineers existing grammars and integrates appropriate decompilers, it provides insights for fluently building those program transformations in general. Our quantitative evaluation uses three C# open source systems and an industrial software from the financial sector. It shows that our approach can be successfully applied to these systems and that the transformation can efficiently transform the programs to KDM while keeping resource demand low.