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

Update default Razor search paths to include ~/[PagesRoot]/Shared #6783

Closed
wants to merge 2 commits into from

Conversation

pranavkm
Copy link
Contributor

@pranavkm pranavkm commented Sep 7, 2017

Fixes #6604

options.ViewLocationExpanders.Add(new PageViewLocationExpander());
}

private static string CombinePath(string path1, string path2)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not Path.Combine?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We want to preserve path separators (they are all meant to be forward slashes). Path.Combine canonicalizes paths to use OS dependent path separators.

}

var rootDirectory = _pagesOptions.RootDirectory;
Debug.Assert(!string.IsNullOrEmpty(rootDirectory));
Copy link
Member

Choose a reason for hiding this comment

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

These shouldn't be asserts, they are clearly possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We disallow these in the property setter (https://github.com/aspnet/Mvc/blob/dev/src/Microsoft.AspNetCore.Mvc.RazorPages/RazorPagesOptions.cs#L32), but sure, we can throw for extra goodness.

Copy link
Member

Choose a reason for hiding this comment

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

Oh ok, unimportant then

options.PageViewLocationFormats.Add("/Views/Shared/{0}" + RazorViewEngine.ViewExtension);

options.ViewLocationFormats.Add(pagesSharedDirectory);
options.AreaViewLocationFormats.Add(pagesSharedDirectory);
Copy link
Member

Choose a reason for hiding this comment

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

Wait so we're making pages/shared searchable from views too?

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, that's how @DamianEdwards wants this. The intent is to allow folks to migrate from Views -> Pages while keeping things working.


namespace Microsoft.AspNetCore.Mvc.RazorPages.Internal
{
public class RazorPagesRazorViewEngineOptionsSetupTest
Copy link
Member

Choose a reason for hiding this comment

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

Needs two functional tests. (View -> Pages/Shared), (Page -> Pages/Shared)

I don't think there's anywhere else in the system we unit test options setups 😆

return path1 + path2 + RazorViewEngine.ViewExtension;
}

return path1 + "/" + path2 + RazorViewEngine.ViewExtension;
Copy link
Member

Choose a reason for hiding this comment

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

since path1 is always _pagesOptions.RootDirectory do we guarantee the absence of a trailing slash? or do we allow that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's what the check in line #47 does, no?

@pranavkm
Copy link
Contributor Author

pranavkm commented Sep 8, 2017

🆙 📅

@pranavkm pranavkm closed this Sep 12, 2017
@pranavkm pranavkm deleted the prkrishn/6604 branch September 12, 2017 17:13
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