Code Conversion from C++ to C#: Tips & Techniques

Migration

Following are some of tips & techniques for doing code migration of your C++ application to C#:

  1. Conversion using Tool: One strategy can be to use some of the existing tools such as that provided by Tangible Software Solutions or sourceforge project on c++ to C# code conversion. Once the code gets migrated, you may want to look out for traps which may lead to error while code migration. Given that C# looks a lot like C++, there are areas (traps) you may want to review to make sure that code conversion took care of those so-called traps. This is not known on how effective these tools do the automated migration and you may want to check for all aspects before making up your mind for using the tool.
  2. Conversion using Lutz Reflector: Another strategy can be to use Reflector from Lutz Roeder. Following can be strategy:
    • Compile C++ code with /CLR option.
    • Load assembly into Reflector.
    • Use de-compiler to get C# code.
  3. Manual Conversion: Yet another strategy can be to go for manual code conversion. However, this is time taking and can prove quite cumbersome if the C++ code does not adhere to code quality standards and consists of various code smells. However, one has a better visibility and control on overall code conversion process.

Common to all of the above strategies are following additional steps that can be taken to ensure minimum acceptable quality:

  1. Static Code Analysis: Use static code analysis tool such as FxCop to analyze the converted code and create reports on areas such such as design, localization, performance, security etc and suggest possible improvements.
  2. Unit Tests: Try and create unit tests around key functions in order to make sure that converted code passes the unit tests on regular basis.
  3. Code Review Policy & Tool: Lay down the code review policy and have the team do the code review, preferably, using the tool such as Crucible, code collaborator etc. These code review tools enhance the collaboration on code review and cut down on time taken in doing code review using emails.
  4. Release frequently: In any conversion project, one may want to adopt the strategy of releasing frequently in order to have business users validate the migration. Agile based development methodology such as SCRUM can prove very useful.
  5. Integration test frequently: A migration project may involve the migration of decomposed modules. One may want to adopt the strategy of integrating these modules on regular basis and do frequent integration testing in order to surprises at the end.
Ajitesh Kumar
Follow me

Ajitesh Kumar

I have been recently working in the area of Data analytics including Data Science and Machine Learning / Deep Learning. I am also passionate about different technologies including programming languages such as Java/JEE, Javascript, Python, R, Julia, etc, and technologies such as Blockchain, mobile computing, cloud-native technologies, application security, cloud computing platforms, big data, etc. For latest updates and blogs, follow us on Twitter. I would love to connect with you on Linkedin. Check out my latest book titled as First Principles Thinking: Building winning products using first principles thinking. Check out my other blog, Revive-n-Thrive.com
Posted in Migration, Software Engg. Tagged with , .

Leave a Reply

Your email address will not be published. Required fields are marked *