I am using T4 templates and the T4 Toolbox to generate text.
I would like to do partial updates based on regions. For instance, on the first pass everything would be generated, but if the file was updated again, only the code blocks in the $regions would be updated. Each of the $regions would have a distinct name.
I am looking for suggestions on how this could be implemented.
One way would be using a a custom pre-processor that strips out everything but the generated code regions. Another may be to flush out the T4 processor's buffer when a generated code region is found, then when the end of the region is found, replace the text in the generated file's region that corresponds to the one the T4 processor has parsed.
Assumptions
- Generated code regions would not contain blocks that should be parsed
- Each generated text region has a distinct name
Simplistic Example
<person>
<firstname>
$region FirstName generated
<#="//T4 Template stuff here" #>
$endregion
</firstname>
<lastname>
$region LastName generated
<#="//T4 Template stuff here" #>
$endregion
</lastname>
</person>
NOTE: I realize this question is similar to this question, but a suitable answer was never provided. I am looking for a viable solution instead of "it cant be done".