CSharp.lua icon indicating copy to clipboard operation
CSharp.lua copied to clipboard

Suggestion: code map files

Open NanoBob opened this issue 6 years ago • 3 comments

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#
        ]
    }
}

NanoBob avatar Aug 10 '19 22:08 NanoBob

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.

yanghuan avatar Aug 12 '19 02:08 yanghuan

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.

NanoBob avatar Aug 14 '19 18:08 NanoBob

Thanks for your understanding.

yanghuan avatar Aug 15 '19 03:08 yanghuan