Visual Studio调试器-自动变量分配 [英] Visual Studio Debugger - Automatic Variable Assignment

查看:106
本文介绍了Visual Studio调试器-自动变量分配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从事一个多开发人员项目,正在开发的应用程序是通过启动器应用程序启动的,该启动器应用程序传递诸如用户登录名,用户位置等参数.现在,当我调试该应用程序时,我在其上设置了一个断点解析输入参数的代码,然后将用户名变量分配给我的用户名等.

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:

  • 我认为这是不好的做法.
  • 我担心该文件将被检入我们的VCS,并造成灾难性的连锁反应.
  • 有多个开发人员正在从事该项目,因此实际上无法选择硬编码我的姓名,位置分配等.
  • 我不能将文件设为只读,因为它处于活动开发中,并且我不断需要获取该文件的更新版本.

我的问题是:

  • 是否存在内置方式或扩展方式,可以在调试模式下自动为变量分配值.现在,我突出显示变量并键入我的文本,这可以自动执行吗?

预先感谢

推荐答案

遇到这种情况时,我通常将条件编译和环境变量/reg键组合在一起.您可以使用这些存储机制来托管信息,而无需将其硬编码到应用程序中.

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.

这篇关于Visual Studio调试器-自动变量分配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆