热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

如何最好地处理VisualStudio中的巨大源代码文件-HowbesttodealwithgiganticsourcecodefilesinVisualStudio

Imworkingonaprojectwhichmakessubstantialuseofcodegeneration.Someofthefilesitgenera

I'm working on a project which makes substantial use of code generation. Some of the files it generates contain >0.25 million lines of code. VS (2K5) doesn't cope too badly, but R# (4.01) throws an out of memory exception every two minutes or so.

我正在开发一个大量使用代码生成的项目。它生成的一些文件包含> 25万​​行代码。 VS(2K5)不能很好地应对,但R#(4.01)每两分钟左右就会抛出一个内存不足的异常。

Splitting them out into partial classes/separate files isn't an option in the immediate term, though it may be later.

将它们拆分为部分类/单独的文件在短期内不是一种选择,尽管可能会更晚。

Are there any clever IDE tricks to dealing with this?

有没有聪明的IDE技巧来处理这个?

EDIT: so people are immediately saying (very sensibly) 'don't have a file that big' and suggesting ways to break it out into smaller files.

编辑:所以人们立即(非常明智地)说“没有一个大文件”,并建议将其分解为更小的文件。

That's fine, but I'm on a time-boxed task taking a look around and deciding what to optimise. My problem is very specifically 'how to view an insanely big file in an IDE without pain', not 'how to refactor the project'. For purposes of the question please imagine the file is read-only. :)

这很好,但是我正在进行一项时间限制的任务,看看并决定优化什么。我的问题是非常具体的“如何在没有痛苦的情况下查看IDE中的疯狂大文件”,而不是“如何重构项目”。出于问题的目的,请假设该文件是只读的。 :)

8 个解决方案

#1


3  

Seems like this R# tool (is that Resharper?) is the problem. Can you disable it? Otherwise, changing the file type for the generated code might make sense - presumably, you aren't going to be doing major editing on those files, so losing syntax coloring and other features specific to source files wouldn't be an issue.

好像这个R#工具(是Resharper?)是问题所在。你可以禁用它吗?否则,更改生成的代码的文件类型可能有意义 - 可能,您不会对这些文件进行大量编辑,因此丢失语法着色和源文件特有的其他功能不会成为问题。

#2


5  

I would at least change huge files extention to something like .cpp_gen or .cpp_huge to remove syntax highlighting, outlining etc. and then reassign build tool back to C/C++ compiler tool for them.

我至少会将大文件扩展名更改为.cpp_gen或.cpp_huge,以删除语法突出显示,概述等,然后将构建工具重新分配给它们的C / C ++编译器工具。

#3


2  

WOW!

250 000 lines of code?

25万行代码?

you should think not in a machine point of view, but in a human been point of view. Let's say that you want to pass that code to someone else, can you see the time to see what the code does?

你应该从机器的角度思考,而不是从人的角度来看。假设您想将该代码传递给其他人,您能看到时间查看代码的作用吗?

Design Patterns were made to deal with this ind stuff, try to start small, refactoring it, then go deeper and start applying more D.P.

设计模式是为了处理这些内容,尝试从小开始,重构它,然后更深入并开始应用更多D.P.

you will have less and less lines of code, and Yes, one of the best tricks is to separate into several files according to it's propose.

你将拥有越来越少的代码行,是的,最好的技巧之一是根据它的建议分成几个文件。

#4


2  

Assuming you're not hand-editing your generated code. (=BAD IDEA!!)

假设您没有手动编辑生成的代码。 (=不好意思!!)

You could put the generated files in a separate solution that you compile from the command line and then reference those dll's from the project you're working in.

您可以将生成的文件放在从命令行编译的单独解决方案中,然后从您正在使用的项目中引用这些dll。

#5


1  

Is the problem when you open the file for editing in Visual Studio? I've noticed that VS editor can be quite slow and inefficient on large files. Also, you could try turning off certain options, e.g. word-wrapping kills my machine for some reason.

在Visual Studio中打开文件进行编辑时出现问题?我注意到VS编辑器在大文件上可能非常慢且效率低下。此外,您可以尝试关闭某些选项,例如自行换行会因某种原因导致我的机器死机。

Otherwise you could use something else like Textpad with syntax highlighting installed to edit the problematic large source file... not as nice, for sure.

否则你可以使用像Textpad一样的其他东西安装语法高亮来编辑有问题的大型源文件...当然不是很好。

#6


1  

Don't use visual studio. There is too much going on in VS.

不要使用visual studio。 VS中有太多事情发生了。

Since the file is read only, you wont be using any IDE features (Intellisense, Refactoring tools, formatting).

由于该文件是只读的,因此您不会使用任何IDE功能(Intellisense,重构工具,格式化)。

You will probably get better performance using a simpler application, such as notepad++ for simply viewing the file. Notepad++ will do standard language highlighting if you like color.

使用更简单的应用程序可能会获得更好的性能,例如记事本++,只需查看文件即可。如果你喜欢颜色,Notepad ++会做标准语言高亮。

#7


0  

Can't you break up the files and use the preprocessor to bring them back together when you compile?

在编译时,你不能分解文件并使用预处理器将它们重新组合在一起吗?

#8


0  

It must be possible somehow to group large chunks of those files in separate libraries. You'd then separate them into several projects. Tried this? What the is the current structure of your source code/ project?

必须以某种方式将这些文件的大块分组到不同的库中。然后,您将它们分成几个项目。试过这个?您的源代码/项目的当前结构是什么?


推荐阅读
author-avatar
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有