Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an easier way to merge Windows Forms .Designer files?

We just recently switched from TFS to Mercurial for our small team. The main project that 3 people work on is a Windows Forms application in C#. Every time you use the designer, even for simple changes, it does a whole lot of rearranging and changing to the .Designer file. If two people work on this file, even making simple changes, the merge is an absolute nightmare. Is there an easy way to solve this problem? In TFS, we turned off concurrent edits so we did not have this problem.

like image 211
TheCodeMonk Avatar asked Mar 16 '12 16:03

TheCodeMonk


2 Answers

This is what I do:

  1. Copy/Use .Desinger.cs from master/develop branch and open project in VS
  2. Copy whole project (all files with .git) and checkout your_feature branch and open project in VS
    • now at this point you should have 2 instances of VS (one on master branch and one on your_feature)
  3. Copy controls (ctrl+c) (in design view/mode) from one VS to another

not perferct solution but helps a lot

like image 142
pburczyn Avatar answered Sep 28 '22 09:09

pburczyn


The problem is every time the code gen engine may generate code in different order!!! which makes merging a pain.

WinForm (.NET) designer, Swing (Java) designer rely on the code gen engine.

ASP.NET's designer.cs only contains backing field, which less likely to suffer.

WPF's backing field is generated in obj/*.g.cs, which is not required to keep in source control, so no merging problem.

like image 43
linquize Avatar answered Sep 28 '22 09:09

linquize