views:

115

answers:

2

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

+1  A: 

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.

JaredPar
A: 

Adding to JaredPar's reply, make the class partial.

This will let you keep the main file (the one that gets checked in) updated. The other file (the one containing IF DEBUG) will be local & won't get checked in.

Hope that helps.

shahkalpesh