oleg-shilo / cs-script

C# scripting platform
http://www.cs-script.net
MIT License
1.63k stars 236 forks source link

Enhance file management for easy debug access in hosted applications. #385

Open rexxitall opened 2 months ago

rexxitall commented 2 months ago

If you work with a hosted application the error message shows up with the temporary file name which is not the real name. for debugging purposes its more handy to get the original filename. A workaround is currently to add a comment with the original filename to every code file. You can then load the temporary copy by its temporary filename and try to find this comment.

It might be a enhancement to internally add a dictionary and the functionality to avoid this workaround. So also in a hosted environment the real filename can be obtained.

oleg-shilo commented 1 month ago

Hi Thomas, I looked at various paths of implementing this feature and unfortunately, I do not see any viable opinion for that. This is rather an architectural problem.

The whole concept of preserving a script file path for script hosting scenarios is problematic.

Thus the scenario you are asking for cannot be implemented in a managed way. I apologise for asking you to create this enhancement issue.

What you can do is implement it in your app. You can use this "global dictionary" approach you suggested earlier.

Or you can use .NET SymbolProvider to read the source information from the pdb file created for all scripts executed with debug symbols enabled.

rexxitall commented 1 month ago

hm how i just could do it by automatically adding a original file comment to the source files (a loop over the source file folders and a file watcher). Cause i do not want to dig into what is the magic behind csscript. And on a error i just load the temp file with has now the //filename: comment in its first line. brutaly, not elegant but hey. Ok i am a pragmatic oldtimer (made in 1965) i follow the KISS pragma and the "better then nothing" paradigm. Ive also added a routine which adds all file in that source tree automatically and injects them into the main file. So i can now play with that source tree and get also the right filename on a error. What i suggest is to make this what i did transparent behind the scene. (on user wish of course). I was guessing it is possible to fill a dictionary with each file which is loaded by //css_include and friends. ... Anyhow, i got my things working, thanks again and have a nice day. :)

oleg-shilo commented 1 month ago

LOL, I am glad you got what you wanted to achieve. BTW we are made in the same year. And it looks like we share the same passion for pragmatism. Good on you mate