热门标签 | 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?

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


推荐阅读
  • Windows服务与数据库交互问题解析
    本文探讨了在Windows 10(64位)环境下开发的Windows服务,旨在定期向本地MS SQL Server (v.11)插入记录。尽管服务已成功安装并运行,但记录并未正确插入。我们将详细分析可能的原因及解决方案。 ... [详细]
  • 本文详细介绍了Akka中的BackoffSupervisor机制,探讨其在处理持久化失败和Actor重启时的应用。通过具体示例,展示了如何配置和使用BackoffSupervisor以实现更细粒度的异常处理。 ... [详细]
  • 本文将介绍如何编写一些有趣的VBScript脚本,这些脚本可以在朋友之间进行无害的恶作剧。通过简单的代码示例,帮助您了解VBScript的基本语法和功能。 ... [详细]
  • 优化ASM字节码操作:简化类转换与移除冗余指令
    本文探讨如何利用ASM框架进行字节码操作,以优化现有类的转换过程,简化复杂的转换逻辑,并移除不必要的加0操作。通过这些技术手段,可以显著提升代码性能和可维护性。 ... [详细]
  • 本文详细介绍了如何在Linux系统上安装和配置Smokeping,以实现对网络链路质量的实时监控。通过详细的步骤和必要的依赖包安装,确保用户能够顺利完成部署并优化其网络性能监控。 ... [详细]
  • 本文详细介绍了Java中org.eclipse.ui.forms.widgets.ExpandableComposite类的addExpansionListener()方法,并提供了多个实际代码示例,帮助开发者更好地理解和使用该方法。这些示例来源于多个知名开源项目,具有很高的参考价值。 ... [详细]
  • 使用 Azure Service Principal 和 Microsoft Graph API 获取 AAD 用户列表
    本文介绍了一段通用代码示例,该代码不仅能够操作 Azure Active Directory (AAD),还可以通过 Azure Service Principal 的授权访问和管理 Azure 订阅资源。Azure 的架构可以分为两个层级:AAD 和 Subscription。 ... [详细]
  • 在前两篇文章中,我们探讨了 ControllerDescriptor 和 ActionDescriptor 这两个描述对象,分别对应控制器和操作方法。本文将基于 MVC3 源码进一步分析 ParameterDescriptor,即用于描述 Action 方法参数的对象,并详细介绍其工作原理。 ... [详细]
  • 使用C#开发SQL Server存储过程的指南
    本文介绍如何利用C#在SQL Server中创建存储过程,涵盖背景、步骤和应用场景,旨在帮助开发者更好地理解和应用这一技术。 ... [详细]
  • Android 渐变圆环加载控件实现
    本文介绍了如何在 Android 中创建一个自定义的渐变圆环加载控件,该控件已在多个知名应用中使用。我们将详细探讨其工作原理和实现方法。 ... [详细]
  • DNN Community 和 Professional 版本的主要差异
    本文详细解析了 DotNetNuke (DNN) 的两种主要版本:Community 和 Professional。通过对比两者的功能和附加组件,帮助用户选择最适合其需求的版本。 ... [详细]
  • XNA 3.0 游戏编程:从 XML 文件加载数据
    本文介绍如何在 XNA 3.0 游戏项目中从 XML 文件加载数据。我们将探讨如何将 XML 数据序列化为二进制文件,并通过内容管道加载到游戏中。此外,还会涉及自定义类型读取器和写入器的实现。 ... [详细]
  • 如何在窗口右下角添加调整大小的手柄
    本文探讨了如何在传统MFC/Win32 API编程中实现类似C# WinForms中的SizeGrip功能,即在窗口的右下角显示一个用于调整窗口大小的手柄。我们将介绍具体的实现方法和相关API。 ... [详细]
  • ImmutableX Poised to Pioneer Web3 Gaming Revolution
    ImmutableX is set to spearhead the evolution of Web3 gaming, with its innovative technologies and strategic partnerships driving significant advancements in the industry. ... [详细]
  • C++构造函数与初始化列表详解
    本文深入探讨了C++中构造函数的初始化列表,包括赋值与初始化的区别、初始化列表的使用规则、静态成员初始化等内容。通过实例和调试证明,详细解释了初始化列表在对象创建时的重要性。 ... [详细]
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社区 版权所有