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

0

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

Ajitesh Kumar

Ajitesh has been recently working in the area of AI and machine learning. Currently, his research area includes Safe & Quality AI. In addition, he is also passionate about various different technologies including programming languages such as Java/JEE, Javascript and technologies such as Blockchain, mobile computing, cloud-native technologies, application security, cloud computing platforms, big data etc.

He has also authored the book, Building Web Apps with Spring 5 and Angular.
Ajitesh Kumar

Leave A Reply

Time limit is exhausted. Please reload the CAPTCHA.