What is the best way to deal with giant source code files in Visual Studio

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

Separating them into partial classes / separate files is not an option in the near future, although this may be later.

Are there any smart IDE tricks to solve this problem?

EDIT: So people immediately say (very reasonably) โ€œdon't have a large fileโ€ and suggest ways to split it into smaller files.

This is great, but I am in the task of taking into account the time, considering and deciding what to optimize. My problem is very specific: "How to view an insanely large file in the IDE without pain" and not "how to reorganize the project." For the purpose of the question, please imagine that the file is read-only. :)

+4
source share
8 answers

This R # tool (is it Resharper?) Seems to be a problem. Can you turn it off? Otherwise, changing the file type for the generated code may make sense - apparently, you are not going to do large editing in these files, so the loss of syntax coloring and other functions related to the source files will not be a problem.

+2
source

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

+4
source

WOW!

250,000 lines of code?

you must not think in a machine point of view, but in a human point of view. Say you want to pass this code to someone else, can you see the time to see what the code is doing?

Design patterns were developed to deal with this material, try to start small, reorganize it, then go deeper and start applying more DP

you will have fewer and fewer lines of code, and yes, one of the best tricks is to split it into several files at its suggestion.

+2
source

Assuming you are not editing your generated code manually. (= BAD IDEA !!)

You can put the generated files in a separate solution that you compile from the command line, and then reference these DLLs from the project in which you are working.

+2
source

Is there a problem opening a file for editing in Visual Studio? I noticed that the VS editor can be quite slow and inefficient for large files. In addition, you can try to disable certain parameters, for example. Word-wrapping is killing my machine for some reason.

Otherwise, you can use something else, such as Textpad with syntax highlighting set to edit the problematic large source file ... not so good, of course.

+1
source

Do not use visual studio. In VS, too much is happening.

Since the file is read-only, you will not use any IDE features (Intellisense tools, refactoring, formatting).

You will probably get better performance using a simpler application like notepad ++ for easy viewing of a file. Notepad ++ will make standard language highlighting if you like color.

+1
source

Can't you split files and use a preprocessor to return them together at compile time?

0
source

It should be possible to somehow group large pieces of these files into separate libraries. Then you divide them into several projects. Have you tried this? What is the current structure of the source code / project?

0
source

Source: https://habr.com/ru/post/1277787/


All Articles