Search code examples
c#visual-studio-2015stack-overflowcsc

Visual Studio 2015 - Compiler giving Stack Overflow on big fluent call


I have a code like this:

SomeObject.MakeFluent()
   .AddProperty(new MyProperty() { ... })
   .AddProperty(new MyProperty() { ... })
   .AddProperty(new MyProperty() { ... })
   .AddProperty(new MyProperty() { ... })
   .AddProperty(new MyProperty() { ... })
   //[+1024 times]
   .AddProperty(new MyProperty() { ... });

On compile, I get a csc.exe error, stack overflow. If I change the chained method call to:

var fluentAux = SomeObject.MakeFluent();
fluentAux.AddProperty(new MyProperty() { ... });
fluentAux.AddProperty(new MyProperty() { ... });
fluentAux.AddProperty(new MyProperty() { ... });

The code above works fine.

Is there a way to configure max stack call on VS2015's C# compiler? I ask because on VS2013, this issue doesn't happen.

Has the VS2015 compiler become less resilient?

Note: The COMPILER is returning 'stack overflow', not my program.


Solution

  • Opened, as suggested by @DaveShaw, an issue on github: https://github.com/dotnet/roslyn/issues/9795