Why does C# designer-generated code (like Form1.designer.cs) play havoc with Subversion?

Shalom Craimer picture Shalom Craimer · Jan 28, 2009 · Viewed 7.5k times · Source

My workshop has recently switched to Subversion from SourceSafe, freeing us from automatic locks. This led to concurrent editing of the Forms, which is wonderful. But when multiple developers commit their changes, the code files created by the designer (all the files named TheFormName.designer.cs) cause conflicts which are very difficult to resolve.

As far as I can tell, this is because the code generated by the designer is heavily re-arranged whenever the user modifies it, no matter how little the actual change really did.

  • How do I make these conflicts easier to resolve?
  • Is there some way to tell the designer to modify the code less?
  • How do you, the experienced C# teams, deal with concurrent modification of a Form?

Answer

Andrew Peters picture Andrew Peters · Jan 28, 2009

Here are some things to try:

  • Make things more modular. Use components like User Controls etc. to split forms into multiple, smaller physical files.
  • Use presentation layer design patterns like MVP to move code out of views and into standard POCO classes.
  • Recent versions of SVN allow you to take hard locks - use this to avoid complex merge scenarios.

Hope that helps.