In my previous blog post, I explained the conversion of code formatting with the help of an example. Today I will be explaining about conversion of C# method names and other code formatting to java that can be achieved by using CodePorting C#2Java Application.
Using CodePorting you can import your .Net Project directly from your repository, instantly convert it to java and download it or export it back to your favorite repository. CodePorting has made it very easy to access your online repositories without leaving the Codeporting Environment and it also supports version control systems like Git, Subversion, Mercurial (hg).
Lets take an example of code formatting conversion:
C# Code:
namespace CsPorter.Examples.Formatter
{
public class Test16
{
void Method(float f1, float f2,float f3)
{
float ff = f1 + f2;
ff = f1 + f2 - f3 * ff / f1;
double d = f1 + f2 * f3;
d = ff*ff + 42f;
ff = f1/2 + (float) d;
f1 = MethodF(f1 + f2*f3);
f1 = MethodF(f1 + f2*f3)*f1 + f2;
ff = f1 * (FX - FX);
}
float MethodF(float f)
{
return 42f * f;
}
float FX { get { return 42f; } }
}
}
Java Code:
package CsPorter.Examples.Formatter;
// ********* THIS FILE IS AUTO PORTED FORM C# USING CODEPORTING.COM *********
public class Test16
{
private void method(float f1, float f2,float f3)
{
float ff = f1 + f2;
ff = f1 + f2 - f3 * ff / f1;
double d = f1 + f2 * f3;
d = ff*ff + 42f;
ff = f1/2 + (float) d;
f1 = methodF(f1 + f2*f3);
f1 = methodF(f1 + f2*f3)*f1 + f2;
ff = f1 * (getFX() - getFX());
}
private float methodF(float f)
{
return 42f * f;
}
private float getFX() { return 42f; }
In the above example it is clear that C# method names have been converted to Java style method names and same goes for getter names.