1

When searching the vast internet, I find many people complaining about the many potential merge-conflicts that can appear in a WinForms auto-generated (through the UI Designer) code in the [...].Designer.cs files.

I had searched for a Visual Studio extension that might help to reduce the level of occurrence of such designer-conflicts, when multiple people have performed changes simultaneously, but I have had no luck in finding any such extension. Now, I am thinking that I'd like to write my own extension instead.

Inspired by the "ResXManager" extension, which - if all developers in a collaborative team install it - reduces merge-conflicts' occurrence in Resource-files in Visual Studio, by always sorting the contents by the created keys, instead of always placing new content at the bottom of the resource file.

I want to apply the same concept to WinForms Designer-files, ideally as a Visual Studio extension.

How can I accomplish this? Ideally, I would want to be able to listen to any change of any ".Designer.cs" file in the solution, and perform the relevant sorting of its contents. How can I add a listener to such an event and then perform the necessary modifications to the contents of the Designer-files?

Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92
KRU
  • 19
  • 2
  • I've edited your question a bit to make it more obvious that you want to make your own extension and you're not looking for plugins. As an aside, see [this answer](https://stackoverflow.com/a/3786591/1364007). – Wai Ha Lee Feb 27 '19 at 11:03
  • Thank you, I understand the confusion. Regarding the link, I find this matter to be vastly different, as I am not trying to perform manual edits in a Designer-file, but to re-arrange its contents whenever it gets re-generated via the UI Designer window. – KRU Feb 27 '19 at 11:08
  • How do you define _sorted_ for a WinForm designer file? A strict alphabetical sort of the InitializeComponent method's statements would likely yield non-functional code. – TnTinMn Feb 27 '19 at 22:02
  • Indeed, a strict line-by-line sorting would not work. I would have to analyze the code, e.g. by using multi-line regex (of sorts) to find groups of code-pieces, and then order those alphabetically by their keys. For instance, the autogenerated comments with empty comment lines above and below them could be detected, and then re-arranging each such block. The idea is that if my collaborator adds a "lblRating" and I add a "lblAdditionalInformation", and something goes alphabetically in-between, then no conflict should occur due to the enforced ordering of each sensible group of code. – KRU Feb 28 '19 at 12:21

0 Answers0