Commented Issue: Recursive partial views causes a stack overflow while compiling. Crashes Visual Studio. [2876]

4 views
Skip to first unread message

sparkviewengine Issue Tracker Rss Feed

unread,
Feb 4, 2010, 8:42:02 PM2/4/10
to spar...@googlegroups.com
The compiler get into a stack overflow when it tries to recursively parse a partial view over and over again. I don't know if this problem can be dealt with (or should be) to allow recursive partial views... but you could probably keep a list of which views are being parsed and throw an exception if a view would be parsed more than once.

This problem can be avoided by using a macro instead of a partial view. However, If you have the Visual Studio integration installed (like myself) then this would crash every time you opened any Spark file that referenced one of those recursive views.

The actual point where the stack eventually overflows is not consistent. It does consistently follow this sort of call pattern, with the specific chunk visitors changing depending on what it is parsing:

--- Example: Call Stack ---

Spark.Compiler..AbstractChunkVisitor.Accept
Spark.Compiler..AbstractChunkVisitor.Accept
Spark.Compiler.CSharp.ChunkVisitors.GeneratedCodeVisitor.Visit
...
Spark.Compiler..AbstractChunkVisitor.Accept
Spark.Compiler..AbstractChunkVisitor.Accept
Spark.Compiler.CSharp.ChunkVisitors.GeneratedCodeVisitor.Visit

--- End Example ---

--- Example: Index.spark ---

<h2>Hello World</h2>
<render partial="Index" />

--- End Example ---

Versions Tested: 1.0.39890.0 & 1.0.39910.0
Comments: ** Comment from web user: xeb **

This may help some people.

In order to circumvent the "Recursive rendering of partial files not possible" exception, I used a code block to call the RenderPartial method in HtmlHelper. This worked fairly well for me & I was able to successfully call a partial recursively.

---- example: _partialItem.spark ----

<for each="var subitem in item.Children">
<!-- do something -->
#{Html.RenderPartial("_partialItem", new { item = subitem });}
</for>

---- end example ---------------

URL: http://sparkviewengine.codeplex.com/WorkItem/View.aspx?WorkItemId=2876

Reply all
Reply to author
Forward
0 new messages