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

3

14

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.

Deerhound answered 16/3, 2012 at 16:37 Comment(2)
Merging the *.Designer.cs is a pain -- period.Traceytrachea
I was going to ask the same question about web form designer files. I guess it's possible that locking is the best solution, but not a very satisfying solution when what you really want to do is just let everybody work and then merge later.Mazard
H
2

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.

Hoch answered 17/3, 2012 at 6:20 Comment(0)
H
1

Merges of these kind of files are always painfull... This is the reason why some "locking" extensions for Mercurial exists, so you can have the same workflow as with TFS if needed.

For example you can use the Lock extension written by Martin Geisler to lock .Designer files until the next push, doing so you will avoid any concurrent modification thus avoiding the merge also.

Hulbert answered 16/3, 2012 at 17:19 Comment(2)
Still I don't think this solves the problem of merging between branches, even though that's not what the OP is asking.Wulfenite
"Locking" of files is not an appropriate solution (nor practical in a distributed environment). The problem is Microsoft's code generator not taking any care to make the file human-readable (i.e., sorting members, for example). If it would output the code in an ordered way then you wouldn't have to sort through hundreds of hunks for a tiny little one-line property change because only that one line would change. I honestly can't understand how they did implement it for it to be so unpredictable. They must be using a RNG for fun or something...Satiety
O
1

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

Oleaginous answered 12/6, 2019 at 10:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.