-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Adding support for inheriting chunks from _ViewStarts as part of host parsing #946
Conversation
@yishaigalatzer could you have a look at this when you have time? It's missing unit tests and some of the type names probably need to change, but I was looking at thoughts about the design. |
var mergerMappings = GetMergerMappings(codeTree); | ||
var current = codeTree.Chunks; | ||
|
||
foreach (var chunk in current) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add comments to what each loop does, and what's the purpose
Updated |
I'd appreciate it if we could get more eyes on this. cc @NTaylorMullen / @dougbu |
/// <param name="chunk">The chunk to cast.</param> | ||
/// <returns>The <paramref name="Chunk"/> casted to <typeparamref name="TChunk"/>.</returns> | ||
/// <exception cref="ArgumentException"><paramref name="chunk"/> is not an instance of <typeparamref name="TChunk"/>.</exception> | ||
public static TChunk EnsureChunk<TChunk>(Chunk chunk) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: spacing
IFileInfo fileInfo; | ||
if (fileSystem.TryGetFileInfo(viewStart, out fileInfo)) | ||
{ | ||
var parsedTree = ParseViewFile(templateEngine, fileInfo); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like this will find and parse all _ViewStart files. won't the regular generator just stop once it finds _ViewStart?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't it only find all the viewstart pages that affect the given "pagePath"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah @NTaylorMullen is correct. When executing a page, we run all the _ViewStarts applicable to the current page
i.e /_ViewStart.cshtml, /Views/_ViewStart.cshtml, /Views/Home/_ViewStart.cshtml
The behavior here is to also inherit from all of these
* Addressing PR comments and adding unit tests
50be017
to
d7717b8
Compare
Rebased and updated |
|
/// <param name="chunk">The chunk to cast.</param> | ||
/// <returns>The <paramref name="Chunk"/> cast to <typeparamref name="TChunk"/>.</returns> | ||
/// <exception cref="ArgumentException"><paramref name="chunk"/> is not an instance of <typeparamref name="TChunk"/>.</exception> | ||
public static TChunk EnsureChunk<TChunk>(Chunk chunk) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix indent
⌚ waiting |
Updated. Haven't made any changes with respect to the C# 6.0 features. |
|
let's talk tomorrow about line 33 in |
|
Fixes #881