yanghuan / CSharp.lua

The C# to Lua compiler
Other
1.23k stars 202 forks source link

Suggestion: code map files #233

Open NanoBob opened 5 years ago

NanoBob commented 5 years ago

This isn't as much an issue as it is a suggestion.

Would it be possible to generate some form of code maps? By this I mean a file which would contain which lines of Lua code correspond to which lines of C# code, and which Lua file corresponds to which C# file.

My reasoning behind a feature like this would be so we could show errors with proper file names and line nubers in the C# files, even when thrown at runtime from Lua.

So basically something like:

{
    "Dist/Models/Player.lua": {
        "name": "Source/Models/Player.cs",
        "lines": [
            0,  // line 0 in Lua refers to line 0 in C# 
            1,  // line 1 in Lua refers to line 1 in C#
            2,  // line 2 in Lua refers to line 2 in C#
            3,  // line 3 in Lua refers to line 3 in C#
            4,  // line 4 in Lua refers to line 4 in C#
            4,  // line 5 in Lua refers to line 4 in C#
            5   // line 6 in Lua refers to line 5 in C#
        ]
    }
}
yanghuan commented 5 years ago

Thanks your suggestion. CSharp.lua has always put the readability of the output first.This is easy to debug and misarrange, and the corresponding code on one line by one will not be a burden.

JavaScript requires map files because it is often compressed and confused and loses readability, which is not currently present on CSharp.lua.

So this suggestion won't be supported at the moment.

NanoBob commented 5 years ago

Alright, I understand. I hope at some point in the future you will change your mind.

The reasoning behind the suggestion is more about debugging / reading errors than the readability of code. Currently if I get a runtime error I have to go to the .lua file, look at the line. And then go back to the C# file to fix it. It would just be a bit more streamlined to have the C# file and line number in the runtime errors.

yanghuan commented 5 years ago

Thanks for your understanding.