将自动生成的代码文件拆分为单独的类文件
我有一个由 XSD.exe 生成的大型代码文件,它生成了一个 40k 的文件,其中有数百个类定义。这是因为大约有 30 个 Root XSD 和一些常见的 XSD,它们都需要捆绑在一起才能导入。
我想将它们分成单独的类文件,以便可以轻松管理它们。有没有简单的方法可以做到这一点,或者我是否必须求助于某种正则表达式巫毒?
干杯
特里斯坦
I have a large code file generated by XSD.exe, which has generated a 40k file, with many hundreds of class definitions in it. This is because there are about 30 Root XSD's and a few common ones, and they all need to be bundled together to import.
I'd like to split them into seperate classe files so they can be managed easily. Is there any easy way to do this, or am I going to have to resort so some kind of Regex Voodoo?
Cheers
Tristan
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 ReSharper 来执行此操作:
右键单击生成的文件
-->重构
-->将类型移动到匹配文件中
如果您没有 ReSharper,您可以在 http://www.jetbrains 中检索评估副本。 com/resharper/
问候,
克里斯
You could use ReSharper to do this:
Right-Click on the generated File
--> Refactor
--> Move Types into matching Files
If you dont have ReSharper, you could retrieve an evaluation copy at http://www.jetbrains.com/resharper/
regards,
Chris
如果它们生成为
公共分部类ClassName
,您可以在任何您想要添加其他成员的地方创建另一个公共分部类ClassName
。对于大多数自动生成类工具,它们将它们全部转储到一个文件中,因为您通常不想编辑这些类,因为如果再次运行该工具,它将覆盖您的更改。
如果您可以使用该工具生成部分类,那么您应该可以开始了。
If they're generated as
public partial class ClassName
you can create anotherpublic partial class ClassName
wherever you like to add additional members.With most of these autogenerating-class-tools they dump them all in one file because you typically don't want to edit these classes since if the tool is ran again it will overwrite your changes.
If you can generate partial classes with the tool then you should be good to go.