Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
rexxitall opened this issue Sep 17, 2024 · 3 comments
Open

Comments

@rexxitall
Copy link

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
Copy link
Owner

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.

  • Sometimes the user specifies no script file at all
  • Sometimes the script has other imported (secondary) scripts
  • Keeping the script paths in some global dictionary means potentially uncontrolled growth of such dictionary
  • Looking up script path in the global dictionary needs support for the identity of the script. Currently, it is script content hash. And it is exactly what you do not have - you are trying to discover what script text/file was used to build a specific script assembly.
  • Supporting an alternative script identity - assembly, is theoretically possible. But... sometimes the assembly is not physical but in-memory only. Sometimes it is a Roslyn assembly itself (for pure dynamic Rosliyn backed scripts).

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
Copy link
Author

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
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants