Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Debugger - Automatic Variable Assignment

I am working on a multi-developer project and the application being developed is launcher through a launcher application which passes parameters such as the user logged in, their location, etc. Right now when I debug the application I set a breakpoint on the code that parses the input parameters and I assign the username variable my username etc.

I could hard-code these values but:

  • I believe this is bad practice.
  • I am worried the file will get checked into our VCS and have disastrous ripple effects.
  • Multiple developers are working on the project so hard-coding my name, location assignments etc. isn’t really an option.
  • I cannot make the file read-only as it is in active development and I continuously need to get updated version of said file.

My question is:

  • Is there a built-in way or an extension to AUTOMATICALLY assign variables a value in debug mode. Right now I highlight the variable and type my text, can this be automated?

Thanks in advance

like image 980
Jason Irwin Avatar asked Jul 23 '09 16:07

Jason Irwin


People also ask

How can I see the variable value while debugging in Visual Studio?

When stopped in the debugger hover the mouse cursor over the variable you want to look at. The DataTip will appear showing you the value of that variable. If the variable is an object, you can expand the object by clicking on the arrow to see the elements of that object.

Is it possible to change the value of a variable while debugging?

Yes u can if you have the authorization: while debugging do a doubleclick on the variable, the system'll show the name and the value of the variable, change the value and press CHANGE icon.


1 Answers

When I hit situations like this, I usually a combination of conditional compilation and environment variable / reg key. You can use these storage mechanisms to host your information without hard coding it into the application.

#if DEBUG
if ( null != Environment.GetVariable("CUSTOM_INFO")) {
  userName = Environment.GetVariable("CUSTOM_USERNAME");
  ...
}
#endif

This way it won't affect any other developers. Unless of course, they want to accomplish the same thing.

like image 50
JaredPar Avatar answered Nov 15 '22 04:11

JaredPar