Skip to content
This repository was archived by the owner on Dec 14, 2018. It is now read-only.

Adding support for inheriting chunks from _ViewStarts as part of host parsing #946

Closed
wants to merge 5 commits into from

Conversation

pranavkm
Copy link
Contributor

@pranavkm pranavkm commented Aug 6, 2014

Fixes #881

@pranavkm
Copy link
Contributor Author

@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)
Copy link
Contributor

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

@pranavkm
Copy link
Contributor Author

Updated

@pranavkm
Copy link
Contributor Author

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)
Copy link
Contributor

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);
Copy link
Member

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?

Copy link
Contributor

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"?

Copy link
Contributor Author

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

@pranavkm
Copy link
Contributor Author

Rebased and updated

@NTaylorMullen
Copy link
Contributor

:shipit:

/// <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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix indent

@dougbu
Copy link
Member

dougbu commented Aug 20, 2014

⌚ waiting

@pranavkm
Copy link
Contributor Author

Updated. Haven't made any changes with respect to the C# 6.0 features.

@yishaigalatzer
Copy link
Contributor

:shipit: when the last comments are addressed and everyone else is happy

@dougbu
Copy link
Member

dougbu commented Aug 22, 2014

let's talk tomorrow about line 33 in MvcCSharpCodeBuilder

@dougbu
Copy link
Member

dougbu commented Aug 22, 2014

:shipit:

@pranavkm pranavkm closed this Aug 22, 2014
@pranavkm pranavkm deleted the Host-ViewStart branch August 22, 2014 18:05
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants