本文介绍了为什么C#设计器生成的code(如Form1.designer.cs)严重破坏颠覆?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的工作室最近改用颠覆从SourceSafe,从自动锁释放我们。这导致了形式并发编辑,这是美妙的。但是,当多个开发人员提交他们的变化,由设计师创建的code文件会导致冲突(全名为 TheFormName.designer.cs 中的文件),这是非常难以解决

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.

据我所知,这是因为由设计器生成的code在很大程度上重新安排每当用户修改它,不管多么小的实际变化真的做到了。

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.


  • 如何使这些冲突更容易解决?

  • 是否有某种方式来告诉设计师修改code少了?

  • 你怎么了,有经验的C#团队,处理一个表格并发修改?

推荐答案

我不熟悉C#或Windows窗体设计器,但看一些 designer.cs 文件我可以在网上找到他们没有一个特别复杂的结构。

I'm not familiar with C# or the Windows Form Designer, but looking at some designer.cs files I could find online they don't have a particularly complicated structure.

什么它的部分被重新安排?我想这是大部分是的混乱呢?在的InitializeComponent()法属性的顺序

What parts of it are being re-arranged? I guess it's mostly the order of the properties in the InitializeComponent() method that's jumbled up?

如果是这样的话,你也许可以写一个简单的脚本,重新排序这些行按字母顺序,说(特别是如果你从来没有手动反正编辑这些文件),并使用它作为一个的的颠覆

If that's the case, you might be able to write a simple script that re-orders those lines alphabetically, say (especially if you never edit these files manually anyway), and use that as a pre-commit hook script in Subversion.

嗯,对的...从头开始。在该部分的底部的大红色框说你不应该修改钩子脚本交易。但是,你可能能够找到另一种方式来某处 designer.cs 文件之间运行该脚本被改变,它被提交。

Um, right... scratch that. The big red box at the bottom of that section says you're not supposed to modify transactions in hook scripts. But you might be able to find another way to run that script somewhere between the designer.cs file being changed and it being committed.

其实,在此给出scraimer的评论:

Actually, given scraimer's comment on this:

总劈,但在最坏的情况下,仅仅是合并之前,我可以两个文件进行排序,使合并只是一个行由行的事......

你能不能让颠覆设置一个外部合并程序?我一直在使用,从而可以的的,所以你可以自动化的过程。

Can't you let Subversion set an external merge program? I've been using KDiff3, which can run a preprocessor command before doing diffs or merges, so you could automate that process.

这篇关于为什么C#设计器生成的code(如Form1.designer.cs)严重破坏颠覆?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-07 01:58