C# to Oxygene code converter - c#

I know CodeGear made BabelCode that uses the Code DOM to convert C# to Delphi for .NET. I am curious if there are any other similar tools to convert C# to Delphi Prism? If not, what is involved in using the Code DOM to create one (yeah, that is open ended!)
Update: This is now built into Delphi Prism. Just paste or import your C# and you have Oxygene aka Delphi Prism Code.

It's in its early stages but Carlo just published a first revision of his open source "C# to Oxygene" tool:
http://code.remobjects.com/p/csharptoxy/

One option I saw was to use .NET Reflector on the C# compiled assembly. It has an Oxygene syntax. That is kind of the long way around and not exactly optimal.

Use BabelCode to convert your C# to Delphi, and then use Oxidizer to convert Delphi to Prism. Not a stellar idea, I realize, but it might at least be a little more automatable than going through Reflector. Good luck.

Related

Use VB Library that made by VB Net in C#

Sometimes we meet some code of VB.net that doesn't support on C#,
such as Mid, AscW,Asc, Right, Left .. etc
so that i have made the Libraries that made by VBnet.
well, my question is simple
is this going to get any problem? if i'm developing with 2 language of NET?
There's no problem. Just add a reference to Microsoft.VisualBasic and use the functions in your C# code. More discussion of the pros and cons in this question
You can import .net libraries into any other .net language project. Not a problem.
I think this page (Cross-Language Interoperability) may help you.
Both those .net languages (all I think) compile to CLI. An intermediate language between machine code and C#/VB.NET.
When you link to a managed DLL it makes no difference what the source language is, the resulting DLL code is the same. Indeed many reflectors (that show a source code representation of a managed DLL's code) have an option to choose the source code language.
Hence, you can link to any managed DLL created from any .net language, using it in any (other) .net language.
If you are only making a library using VB.NET because of functions like Mid, Left, Right etc. you might want to just research the C# equivalents or just code them in C#.
Alle .net languages can be used with each other - there should be no problem. But I would check VB.net code with "mid" etc. VERY carefully, that are old deprecated VB 6 style functions - there is a huge change that the programmer did not change his programming model as needed.

C# scripting from C++?

Is there any C# interpreter that can be used inside C++ and yet still allow .Net access?
I want to use C# scripts for games and I'm not sure how to proceed with that.
You can write a simple class in C#, let's call it ScriptRunner that would take your C# code as input, compile it at runtime to produce a new assembly in memory, then it will use Reflection to load a specific Type from this new assembly, and will run some method with an expected name.
Then, use COM Interop (for example) to create a ScriptRunner .NET object from your C++ native application, and you'll be able to use it to run scripts.
Start with:
var myProvider = Microsoft.CSharp.CSharpCodeProvider.CreateProvider();
var myCompiler = myProvider.CreateCompiler();
and it's really easy to continue on your own by using IntelliSense to see what's on the ICodeCompiler interface.
If you've got some specific questions about this approach please ask.
C# is not an interpreted language, it is a compiled language.
You can write C# scripts, but why not use Python or Ruby or Lua or some other true-blue scripting language?
I feel somewhat dirty mentioning this, but it looks like there is an ECMA compliant C# scripting engine.
I believe C# is a compiled language only. Your best bet would be to call the csharp compiler (csc.exe) and load the assembly dynamically.
YOu can have .net dlls and use them in your C++ code.
Is it C++ or C++/CLI? If it's the "normal" C++ I don't think it will be possible to use C# as it is a compiled language and a managed one, your best bet would be to use the managed version of C++ and compile the C# code, then load it.
I've never tried to do that but I think C# is definitely not a suitable language for scripting, for your purpose Lua or Python (for example) are certainly better...
I assume you want to use C++ for DirectX/OpenGL support and then want to load in the entire .Net Framework on top of that to support scripting? That would be a very heavy footprint if it were possible. Since C# is compiled into bytecode (just like Java), you would have to precompile your scripts.
Your best best is to to use an opensource scripting language (php, lua, etc).

what are the possible ways to using c# code in c++

I'm just looking for a best way to re-use code written in c#, in my c++ projects. Creating a com\service doesn't look like a best option for my needs. How difficult it is to export c# code into a dll and use it in c++? can i get some suggestion or example? is this usual requirement or ? Please help me.
i use win7, VS2008, win7sdk
Thanks & Rgds, ~calvin
Executing managed code from an unnamaged executable is possible, though not quite easy. You can look into this article for an introduction and this book to go further.
I personally would avoid this kind of things in most cases and, if possible, switch the C++ project to C++/CLI to obtain an immediate compatibility with .Net assemblies for a minimal cost.
You can't export C# code into a native dll afaik. At least without very much pain in your buttocks. You should have thought beforehand and write the reusable part in C, thus creating a native DLL which could be used from all languages.
Also, you could try managed C++ - I personally hate it... but there you go
In case you need to use code written in C# C++, then you need to first see what all data types you would be passing from your C++ code to C# code.
1. Basic data types like int, enum etc can be passed from unmanaged to managed code.
2. in case you want to pass on class object, than you need to use marshalling.
If you can't use COM (if the .NET code is already written for example), then you can host the CLR, but this is a long road...
See these other articles
How to load CLR into process and Create a C# DLL That Can Be Imported in a Delphi App Using stdcall - Possible?

Convert Java to C# or VB.net to C#

Is it possible to convert code from Java to C# or VB.net to C#?
You could decompile the VB.NET code using Reflector (http://www.red-gate.com/products/reflector/) to get it as C#. You might also try someting like this online converter http://www.developerfusion.com/tools/convert/vb-to-csharp/
Try Telerik Code Converter for a free C#/VB code converter. I've used it - it isn't bad. There are also many commercial ones with lots of features.
Java and C# are very similar and converting between the two (and to/from VB) is possible. A quick search should reveal many commercial options.
If you know a little bit of both C# and Java, converting Java to C# by hand would be the best route to go. That's what I did for a relativley medium sized Java project. Then you can use Sharpdevelop (http://www.icsharpcode.net/opensource/sd/) to convert C# to VB and vice versa.
For Java to C# &VB.Net, you can also use Tangible Java to VB & C# Converter.
http://tangiblesoftwaresolutions.com
I hope this could be useful. But it might not work with complex code structures..
https://varycode.com/converter.html

Generate and parse Python code from C# application

I need to generate Python code to be more specific IronPyton. I also need to be able to parse the code and to load it into AST. I just started looking at some tools. I played with "Oslo" and made a decision that it's not the right tool for me. I just looked very briefly at Coco/R and it looks promising.
Does anyone use Coco/R?
If you did what's your experience with the tool
Can you recommend some other tool?
The IronPython implementation itself includes a parser and an AST representation of Python programs which can be walked with a PythonWalker.
Not really my area of expertise but you might want to try ANTLR 4. It has support for generating Python 2 and Python 3.
I think you should look at the Dynamic Language Runtime. This will be a standard part of some later version of .Net and C# (.Net 4 from memory).
I've used it to compile and execute Python code generated at runtime, but I haven't played with all the AST stuff yet.

Categories