View unanswered posts | View active topics



Reply to topic  [ 4 posts ] 
Runtime error helper for anonymous functions 
Author Message
Member

Joined: Wed Feb 13, 2013 2:17 pm
Posts: 45
Reply with quote
Hi guys,

Errors in anonymous functions are very difficult to debug in release mode since the stack trace only shows the class name and not the method and/or line number.

My idea to improve this is to process each .as file as you save it replacing:

..
23
24 doSomething().then(function () { ... });
25
..
With
..
23
24 doSomething().then(function _anonymous_comMyPackageMyClassName_l24() { ... });
25
..

Errors will then show the function name and.. voilĂ , easy debugging :)

So far, made a python script (would make it .cs later maybe), works nicely but I have a couple of issues:

1. I get the reload prompt after running the macro which i'd like to force to yes or better, reload in the macro without having the prompt (Reload|$(CurFile) shows 2x prompts!)
2. I'd like to run the inverse process on file open (remove all the debugging names) to keep the code clean

Could you give me some advice on these issues ? :)

Edit: I guess one could also do this just before building. I guess there is a temporary workspace for building since one can edit file during compilation, so would be awesome to "just" run a script on the files before they get to the compiler, this way the source code stays clean.


Thu Nov 26, 2015 5:30 pm
Profile
Admin

Joined: Wed Aug 31, 2005 7:27 am
Posts: 12172
Location: London
Reply with quote
What you want to do is rather complicated I'm afraid.

A C# plugin is probably the best option as you can respond to many internal events. Ideally you'd want to process the file's content in the scintilla buffer when the file is open and when it is saved.
You'll probably have to disable warnings in FD settings so you don't get a dialogue when the file on disk changes.

Finally to safest solution would be to generate a hidden classpath of the modified classes. But arguably that would cause issues when debugging.


Thu Nov 26, 2015 6:49 pm
Profile WWW
Member

Joined: Wed Feb 13, 2013 2:17 pm
Posts: 45
Reply with quote
Thanks for your answers Philippe!

Finally, the solution I'll use is to run a prebuild script that adds the names and a post build script that removes them.

Indeed, doing it on close/open file will mean the code on the repository and the code we see would be different.

Doing it pre/post build will keep everything transparent & clean, also it makes things a lot simpler, I can even keep my python script :)


Fri Nov 27, 2015 9:26 am
Profile
Admin

Joined: Wed Aug 31, 2005 7:27 am
Posts: 12172
Location: London
Reply with quote
Doing that just for the build is indeed a good idea.


Fri Nov 27, 2015 9:56 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.