Erdem
Erdem

Reputation: 105

How to modify SpecFlow code generation behaviour

We have a feature file with 15061 lines ( auto-generated through another system ). Specflow (version 3.9.7) manages to generate a cs file through MSbuild task with 39017 lines. However build of the generated feature file fails with Stack overflow error as:

C:\Program Files\dotnet\sdk\6.0.202\Roslyn\Microsoft.CSharp.Core.targets(75,5): error : Stack overflow. [D:\Code\DDS_SpecFlow\DDS_SpecFlow.csproj]
C:\Program Files\dotnet\sdk\6.0.202\Roslyn\Microsoft.CSharp.Core.targets(75,5): error : Repeat 24214 times: [D:\Code\DDS_SpecFlow\DDS_SpecFlow.csproj]
C:\Program Files\dotnet\sdk\6.0.202\Roslyn\Microsoft.CSharp.Core.targets(75,5): error : -------------------------------- [D:\Code\DDS_SpecFlow\DDS_SpecFlow.csproj]
C:\Program Files\dotnet\sdk\6.0.202\Roslyn\Microsoft.CSharp.Core.targets(75,5): error :    at Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.DirectiveStack.CompleteRegion(Roslyn.Utilities.ConsList`1<Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.Directive>) [D:\Code\DDS_SpecFlow\DDS_SpecFlow.csproj]
C:\Program Files\dotnet\sdk\6.0.202\Roslyn\Microsoft.CSharp.Core.targets(75,5): error : -------------------------------- [D:\Code\DDS_SpecFlow\DDS_SpecFlow.csproj]

Seems like the number of #line directives generated in the file is more than the compiler can handle, since the build succeeds once I remove all of the line directives.

So I am looking a way to configure the SpecFlow code generation task and skip line directive generation.

Upvotes: 0

Views: 176

Answers (1)

Andreas Willich
Andreas Willich

Reputation: 5825

Please split your feature files into multiple files. Any file with 15k lines is unreadable and unmaintainable.

Seb Rose wrote a good article on how to organize your feature files at https://cucumber.io/blog/bdd/solving-how-to-organise-feature-files/

Upvotes: 1

Related Questions