www.digitalmars.com         C & C++   DMDScript  

c++.announce - How CodePorting Engine converts C# Code to Java

CodePorting is a web-based C# to Java converter that allows you 
to convert your C# code to java accurately.  CodePorting use a 
powerful parsing engine that translates million of lines of codes 
from C# to java and also ensures that quality and formatting of 
the generated code is preserved. Codeporting makes your 
application platform independent and you can get your code 
converted in no time. CodePorting provides you the most secure, 
reliable and productive code conversion by using absolute 
converting engine.

CodePorting is very simple to use and it provides you accurate 
result. You only need to sign-in and start converting your code 
without installing any application. Let’s now have a look at 
how it actually works to provide the code translation that is 
quick, secure and accurate.

•	Parses C# source code
•	Translates the syntax
•	Intelligently converts .NET classes/methods to Java using 
CodePorting C#2Java maps
•	Prints newly generated code to Java file

CodePorting use highly developed C# 2 Java parser which convert 
C# code to tree. This tree goes through many phases and convert 
the C# syntax into Java syntax and finally generate the accurate 
java code. In the last phase classes/members that are found in 
the mapping file provided by user are converted to java names and 
their imports are added. Once this is done tree is embedded to 
java file.

The first thing you need to do is to upload your C# source code 
to codeporting. We support three different methods for the 
purpose; let’s have a look at each of it:

•	Direct source code upload: You can upload the C# code 
directly to the porting engine.

•	Source code repository import: You can create your project by 
importing C# code in CodePorting from code repositories, both 
public and private.

•	Source code conversion through Microsoft Visual Studio 
Add-in: You can convert  your complete .NET application to 
CodePorting through this add-in instantly. Upload the source code 
from Visual Studio and get your code converted into Java without 
leaving the local environment. You may choose to convert a single 
file or a complete project by installing the add-in to your 
Visual Studio environment.

After uploading the code using one of the above method, the 
conversion cycle starts. The parsing engine performs various core 
activities where C# code and library mappings work together to 
generate the final output file.  The C# Code is parsed and syntax 
tree is generated to be translated into java.

The important part of the whole process is mapping and 
codeporting mapping library includes Java classes with interfaces 
matching .NET classes.  Codeporting has created classes/methods 
for most frequently used C# classes and and they are continuously 
adding more classes/methods in the library. CodepOrting has also 
given this opportunity to user to add a class in the C#2Java 
library in case of the class does not exist with the same 

After mapping and conversion the parsing engine generated the 
file java code ready to be used as a platform independent 
application/code which provides the same functionality as C# 
code. This process eliminates the massive amount of work needed 
to convert to C# code to Java manually.
Jul 10 2012