views:

59

answers:

1

I am looking for a way to transform some classes from Java to .Net in a code gen way.

Not at run time, but re-generate a handful of business objects as needed (not often).

the catch is, i want to have full control of how they end up. So while java classes have get and set methods, i will create a property out of them.

the only way i can think of for now, is to read the file using c#, get the necessary members, and maybe feed them to a code gen template. at the very lease, i could throw them into a database, and something like code smith could generate .net classes based on a template and the updated database table.

any other ideas/utilities?

my solution was to use reflection to write out java class members as xml, and than plugging that into codesmith template to create .net classes. the neat part is that it can be automated as a step on build server

+1  A: 

Have a look at IKVM.

Thorbjørn Ravn Andersen
well i don't need to make java and .net interoperable. there are just a few classes that need to be synchronized because they both use another 3rd party tool. so its about synchronizing a handful of objects (sychronizing their signature)
Sonic Soul
Use Java reflection to analyze the classes to get the signatures of the methods you want to use, and write out a C# class for each corresponding to this.
Thorbjørn Ravn Andersen
Thorbj0rn that's what i ended up doing, and than running codesmith template to create .net classes.. all automated in the build. too bad you didn't post this as an answer, or else i would have marked it..
Sonic Soul