views:

381

answers:

8

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.

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?

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. :)

A: 

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

1800 INFORMATION
The files are generated, so anything manual is overwritten unless I change the generator or write some sort of script to break this up. But I don't have time to do this right now and I am looking for an immediate term, not even a short term solution.
alexis.kennedy
+2  A: 

WOW!

250 000 lines of code?

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.

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.

balexandre
As above, it's machine-generated code. Breaking it out into separate files may be possible later, but I'm wondering if there's something to ease my pain while I take an initial look around.
alexis.kennedy
I think there's something to be said for trying to figure out if those 250,000 lines of code are actually necessary. Once you solve the immediate problem, it might be worthwhile to dig into the code generator a bit.
Mark Bessey
+2  A: 

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.

Mendelt
Good solution. You won't have to compile the separate solution from command-line though. Maybe putting the code into a separate project and then unloading the project (after it has been compiled) may be a good solution, this way VS handles the dependencies better.
OregonGhost
I don't know how bad the resharper problem is. If it hangs too much compiling the offending code from the command line might be a solution. If it's not that bad then you're right. A separate project is enough separation. It also depends on how often the generated code has to be changed.
Mendelt
A: 

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?

moogs
+4  A: 

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.

eugensk00
+1  A: 

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.

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

RickL
+1  A: 

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.

Mark Bessey
+1  A: 

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

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

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.

discomurray