microsoft / vscode-mono-debug

A simple VS Code debug adapter for mono
Other
159 stars 173 forks source link

add .hx to MONO_EXTENSIONS #35

Closed VysotskiVadim closed 7 years ago

VysotskiVadim commented 7 years ago

Let's add .hx extension to supported extensions. Haxe is language which can be compiled to c#, it overrides path and line number using line directive.

This Haxe code:

 public static function main() 
 {
        var array = 1...10;
        for (i in array){
            trace('Hello world $i');
        }

 }

will be compiled to this c# code:

public static void main() {
        unchecked {
            #line 5 "/Users/vadzimv/Projects/haxe_cs_debug/sample/Test.hx"
            global::IntIterator array = new global::IntIterator(1, 10);
            {
                #line 6 "/Users/vadzimv/Projects/haxe_cs_debug/sample/Test.hx"
                global::IntIterator _g = array;
                #line 6 "/Users/vadzimv/Projects/haxe_cs_debug/sample/Test.hx"
                while (( _g.min < _g.max )) {
                    #line 6 "/Users/vadzimv/Projects/haxe_cs_debug/sample/Test.hx"
                    int i = _g.min++;
                    global::haxe.Log.trace.__hx_invoke2_o(default(double), global::haxe.lang.Runtime.concat("Hello world ", global::haxe.lang.Runtime.toString(i)), default(double), new global::haxe.lang.DynamicObject(new int[]{302979532, 1547539107, 1648581351}, new object[]{"main", "Test", "Test.hx"}, new int[]{1981972957}, new double[]{((double) (7) )}));
                }

            }

        }
        #line default
    }

Because of line directive mono debugger works well with .hx files, so I believe mono debugger can be used to debug haxe code for c# target without any other changes.

weinand commented 7 years ago

I would like to verify this. How do I compile Haxe to C# on macOS?

VysotskiVadim commented 7 years ago

Please install haxe: https://haxe.org/download/ I've published a simple project for you to test: https://github.com/VysotskiVadim/haxe-vscode-monodebug-sample , just open, put breakpoint and launch.

weinand commented 7 years ago

@VysotskiVadim thanks a lot for the PR and even more so for the sample project! That helped a lot.

VysotskiVadim commented 7 years ago

I'm glad to help! thanks.