C # code conversion to Python

Source: Internet
Author: User

: 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:

    1. The C # or vb.net code is parsed using SharpDevelop's parsing library nrefactory and an abstract syntax tree (AST) is Gener Ated.
    2. A visitor class then walks the this AST and generates Python code which are added to a StringBuilder.
    3. Once The visit is complete the generated Python code was then displayed or saved to disk.

C # code conversion to Python

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.