为什么在 Visual Studio Coded UI 测试中编辑 UIMap.designer.cs 文件不好? [英] Why is it bad to edit the UIMap.designer.cs file in a Visual Studio Coded UI test?

查看:24
本文介绍了为什么在 Visual Studio Coded UI 测试中编辑 UIMap.designer.cs 文件不好?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读到编辑 UIMap.Designer.cs 文件很糟糕,但是,我不明白为什么.

I have read that it is bad to edit the UIMap.Designer.cs file, however, I do not understand why.

每个 MSDN:不要直接修改 UIMap.designer.cs 文件.如果这样做,对文件的更改将被覆盖."http://msdn.microsoft.com/en-us/library/dd380782.aspx

Per MSDN: "Do not modify the UIMap.designer.cs file directly. If you do this, the changes to the file will be overwritten." http://msdn.microsoft.com/en-us/library/dd380782.aspx

有人知道什么会被覆盖吗?这是否意味着如果在设计器文件之后编辑 UIMap.uitest 文件,设计器文件会被反转?请帮忙.

Does anybody know what gets overwritten? Does this mean that if the UIMap.uitest file is edited after the Designer file, the designer file gets reversed? please help.

推荐答案

UIMap.designer.cs 文件在每次编辑(即保存)后从 UIMap.uitest 文件重新生成到 <强>UIMap.uitest 文件.文件顶部有注释说这是一个生成的文件,编辑将丢失.

The UIMap.designer.cs file is regenerated from the UIMap.uitest file after every edit (that is saved) to the UIMap.uitest file. There is a comment at the top of the file saying that it is a generated file and that edits will be lost.

乍一看似乎需要在设计器文件中编辑代码的大量更改可以通过 UIMap 编辑器中显示的操作和 UI 控件的属性面板进行编辑来完成.有些更改确实需要手动编辑.对于这些,有一个命令(按钮或右键单击菜单)可以将操作移动到 UIMap.cs 文件中,可以根据需要对其进行编辑和扩展.这两个 UIMap...cs 文件都在它们的类头中指定了 partial,因此它们都有助于同一个 UIMap.

Large numbers of changes that, at first sight, appear to need editing of code in the designer file can be done by editing via the properties panels of the actions and UI-controls shown in the UIMap editor. Some changes do need manual editing. For these there is a command (button or right-click-menu) to move an action into the UIMap.cs file where it can be edited and extended as much as desired. Both of these UIMap...cs files specify partial in their class headers so both contribute to the same UIMap.

当方法中只有一个操作需要手动编辑时,可以将该方法拆分为两到三个部分,以便将需要编辑的操作放入其自己的方法中.拆分命令可通过按钮或右键单击菜单使用.将动作隔离后,其方法可以移动到 UIMap.cs 文件中.

When just one action of a method needs manual editing it can be worth splitting that method into two or three pieces to place the action needing edits into its own method. The split command is available via a button or the right-click-menu. Having isolated the action, its method can be moved into the UIMap.cs file.

在移动方法然后编辑它们时,我推荐以下活动顺序.

When moving methods and then editing them I recommend the following order of activity.

  1. 如果需要:将方法拆分为多个部分,然后使用 UIMap 编辑器重命名拆分的方法.保存 UIMap.uitest 文件,从而重新生成设计器文件.然后添加对拆分和重命名方法的调用.构建测试,或许还可以检查测试是否仍按预期工作.

  1. If needed: Split the method into pieces then rename the split methods using the UIMap editor. Save the UIMap.uitest file causing regeneration of the designer file. Then add calls to the split and renamed methods. Build the test and, perhaps, check that the test still works as expected.

使用 UIMap 编辑器将方法移动到 UIMap.cs 文件中.

Move method into the UIMap.cs file using the UIMap editor.

保存所有导致设计器文件重新生成的文件.省略此全部保存可能会导致在 C# 文件中显示令人困惑的错误.

Save all files causing regeneration of the designer file. Omitting this save-all can cause confusing errors to be displayed on the C# files.

编辑刚刚移入 UIMap.cs 文件的代码.

Edit the code just moved into the UIMap.cs file.

UI 地图编辑器是 Visual Studio 2012 的标准配置.对于 Visual Studio 2010,该编辑器是由 Feature Pack 2 添加的.

The UI Map editor is standard with Visual Studio 2012. For Visual Studio 2010 the editor was added by Feature Pack 2.

这篇关于为什么在 Visual Studio Coded UI 测试中编辑 UIMap.designer.cs 文件不好?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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