Code analysis using the .NET Compiler Platform

OData support
Supervisor:
Dr. Kővári Bence András
Department of Automation and Applied Informatics

The source code is an integral part of the software as a product. It describes the operations that the software must do, the business requirements and business rules that software must adhere to. Since it has a great impact on the final product, analyzing and examining it is an important task. The information collected during the analysis of object-oriented source code – beside providing the possibility of defining derived metrics regarding the quality of the code – makes searching for and discovering complex software patterns in the code possible.

Such complex software patterns are the object-oriented design patterns. Ever since their first documented appearance [1] they have been widely used in the software industry. They enhance the maintainability and the extensibility of the code and they promote the core engineering concept of using documented and proven solutions. They describe the solutions in a programming language agnostic way, so they can be applied in every object-oriented programming language.

Analyzing design patterns in the source of a software helps understand the purpose of a given code snippet and can shed some light on the decisions behind the implementation details. On the other hand, the manual analysis (performed by a software developer) of the code is a time consuming and complicated task.

With the release of the .NET Compiler Platform [2] (formerly Roslyn) the language and compilation services of the C# and Visual Basic programming languages have become directly available to developers. I have used this new tool to implement a framework to automatically detect design patterns in source code written in C#.

To implement the recognition of design patterns I have analyzed concrete patterns. I realized the recognition as a flexible criteria-checking system in C#. I have validated my results by running the solution on the source code of open source libraries and compared the results with analysis done on Java based libraries.

As the literature has mainly been focusing on the Java language in this domain, my work is an important step in analyzing C# language source code. In the long run the recognition of other complex software patterns (S.O.L.I.D. principle violations, anti-patterns) can also be implemented with my framework.

[1] E. Gamma, R. Helm, R. Johnson és J. Vlissides, Design patterns: Elements of reusable object-oriented software, Pearson Education, 1994.

[2] „.NET compiler platform,” [Online]. Available: http://msdn.microsoft.com/en-us/vstudio/roslyn.aspx. [Accessed: 29. April 2015.].

Downloads

Please sign in to download the files of this thesis.