0

I'm trying to use Roslyn for modifying serializers code generated by svcutil.exe. basically, it contains several dozens medium classes, and two huge classes (reader and writer) that contains a function for every class in a very large schema, but nothing too crazy like very large strings or variable names. It works great for medium files (7MB), but when trying to parse a very large source file (50MB, ~600K lines), I'm getting an empty 'Members' collection for the CompilationUnitRoot. When turning on 'break on thrown exceptions' I see there's an InsufficientExecutionStackException thrown when loading the file. Is there any way around this?

When I inspect the CompilationUnitRoot, I see that FullSpan property is correctly set, but the Members, Attributes, and Usings collections are empty.

4
  • why don't split the file into smaller files? I guess it's auto-generated? Then simply modify the generator to emit Reader and Writer into separate files Commented Jan 16, 2023 at 15:19
  • I discovered that this was caused by a monstrous (11K lines) if/else statement, so that wouldn't help. Commented Jan 18, 2023 at 18:51
  • it should help if you break the body of the blocks into functions: if some_cond() return; else if (some_other_cond())... Commented Jan 19, 2023 at 0:35
  • There are many possible solutions, the trouble is I can't use Roslyn to make the transformation. Commented Jan 23, 2023 at 13:33

1 Answer 1

0

I discovered that this was caused by some monstrous (11K lines) if/else statement, which are parsed in a recursion. Fortunately, these are all

if (...) return;
else if (...)

So I was able to pre-process the file and remove the 'else' keywords, breaking the recursion into to separate statements

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.