: HTTP://PAN.BAIDU.COM/S/1DDAZJXV
SharpDevelop 3.1 now supports converting C # and vb.net code to IronPython. It can convert a single file or an entire project. The code to convert between these languages are still under development and has some limitations.
Converting an individual File
To convert a C # or vb.net file, open it in SharpDevelop's text editor, then from Tools menu select Convert Co De to Python.
The code conversion is limited to converting classes so it won't convert an arbitary piece of code that's not inside a Class.
Converting a Project
To convert a C # or vb.net project, open it in SharpDevelop, then from the Project menu select Convert from C # To Python.
Once converted the project would most likely not compile straight away due to limitations in the implementation. At the time of writing converting a project have the following limitations:
- Project ' s Main File is not set.
- No code generated to call the project ' s Main entry method.
- Namespace imports do include all the used classes.
Code Conversion Internals
Converting code to IronPython is originally supported in SharpDevelop 2.2 and is based on converting code to Amicrosoft CodeDOM and then getting IronPython 1.0 to generate the Python code. In IronPython 2.0 this CodeDOM support is removed so the code conversion feature is removed from SharpDevelop 3.0 since That is using IronPython 2.0. In SharpDevelop 3.1 The code conversion have been rewritten to no longer use the CodeDOM support. It now works by executing the following simple steps:
- The C # or vb.net code is parsed using SharpDevelop's parsing library nrefactory and an abstract syntax tree (AST) is Gener Ated.
- A visitor class then walks the this AST and generates Python code which are added to a StringBuilder.
- Once The visit is complete the generated Python code was then displayed or saved to disk.
C # code conversion to Python