Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
575 views
in Technique[技术] by (71.8m points)

user interface - Why is it bad to edit the UIMap.designer.cs file in a Visual Studio Coded UI test?

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

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

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.

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.

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. 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.

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

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

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

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...