Update templates\samples\tests to use ensure viewstart.cshtml and views directory names are cased appropriately. #1559

This commit is contained in:
ianhong 2014-11-18 10:35:16 -08:00
parent 00ce7dcfcc
commit 5b1eae494e
21 changed files with 334 additions and 47 deletions

View File

@ -30,6 +30,10 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// Example <paramref name="expression"/>s include <c>string.Empty</c> which identifies the current model and /// Example <paramref name="expression"/>s include <c>string.Empty</c> which identifies the current model and
/// <c>"prop"</c> which identifies the current model's "prop" property. /// <c>"prop"</c> which identifies the current model's "prop" property.
/// </para> /// </para>
/// <para>
/// Custom templates are found under a <c>DisplayTemplates</c> folder. The folder name is case-sensitive on
/// case-sensitive file systems.
/// </para>
/// </remarks> /// </remarks>
public static HtmlString Display([NotNull] this IHtmlHelper html, string expression) public static HtmlString Display([NotNull] this IHtmlHelper html, string expression)
{ {
@ -61,6 +65,10 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// Example <paramref name="expression"/>s include <c>string.Empty</c> which identifies the current model and /// Example <paramref name="expression"/>s include <c>string.Empty</c> which identifies the current model and
/// <c>"prop"</c> which identifies the current model's "prop" property. /// <c>"prop"</c> which identifies the current model's "prop" property.
/// </para> /// </para>
/// <para>
/// Custom templates are found under a <c>DisplayTemplates</c> folder. The folder name is case-sensitive on
/// case-sensitive file systems.
/// </para>
/// </remarks> /// </remarks>
public static HtmlString Display( public static HtmlString Display(
[NotNull] this IHtmlHelper html, [NotNull] this IHtmlHelper html,
@ -92,6 +100,10 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// Example <paramref name="expression"/>s include <c>string.Empty</c> which identifies the current model and /// Example <paramref name="expression"/>s include <c>string.Empty</c> which identifies the current model and
/// <c>"prop"</c> which identifies the current model's "prop" property. /// <c>"prop"</c> which identifies the current model's "prop" property.
/// </para> /// </para>
/// <para>
/// Custom templates are found under a <c>DisplayTemplates</c> folder. The folder name is case-sensitive on
/// case-sensitive file systems.
/// </para>
/// </remarks> /// </remarks>
public static HtmlString Display( public static HtmlString Display(
[NotNull] this IHtmlHelper html, [NotNull] this IHtmlHelper html,
@ -127,6 +139,10 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// Example <paramref name="expression"/>s include <c>string.Empty</c> which identifies the current model and /// Example <paramref name="expression"/>s include <c>string.Empty</c> which identifies the current model and
/// <c>"prop"</c> which identifies the current model's "prop" property. /// <c>"prop"</c> which identifies the current model's "prop" property.
/// </para> /// </para>
/// <para>
/// Custom templates are found under a <c>DisplayTemplates</c> folder. The folder name is case-sensitive on
/// case-sensitive file systems.
/// </para>
/// </remarks> /// </remarks>
public static HtmlString Display( public static HtmlString Display(
[NotNull] this IHtmlHelper html, [NotNull] this IHtmlHelper html,
@ -162,6 +178,10 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// Example <paramref name="expression"/>s include <c>string.Empty</c> which identifies the current model and /// Example <paramref name="expression"/>s include <c>string.Empty</c> which identifies the current model and
/// <c>"prop"</c> which identifies the current model's "prop" property. /// <c>"prop"</c> which identifies the current model's "prop" property.
/// </para> /// </para>
/// <para>
/// Custom templates are found under a <c>DisplayTemplates</c> folder. The folder name is case-sensitive on
/// case-sensitive file systems.
/// </para>
/// </remarks> /// </remarks>
public static HtmlString Display( public static HtmlString Display(
[NotNull] this IHtmlHelper html, [NotNull] this IHtmlHelper html,
@ -182,8 +202,14 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// <typeparam name="TValue">The type of the <paramref name="expression"/> result.</typeparam> /// <typeparam name="TValue">The type of the <paramref name="expression"/> result.</typeparam>
/// <returns>A new <see cref="HtmlString"/> containing the created HTML.</returns> /// <returns>A new <see cref="HtmlString"/> containing the created HTML.</returns>
/// <remarks> /// <remarks>
/// <para>
/// For example the default <see cref="object"/> display template includes markup for each property in the /// For example the default <see cref="object"/> display template includes markup for each property in the
/// <paramref name="expression"/> result. /// <paramref name="expression"/> result.
/// </para>
/// <para>
/// Custom templates are found under a <c>DisplayTemplates</c> folder. The folder name is case-sensitive on
/// case-sensitive file systems.
/// </para>
/// </remarks> /// </remarks>
public static HtmlString DisplayFor<TModel, TValue>([NotNull] this IHtmlHelper<TModel> html, public static HtmlString DisplayFor<TModel, TValue>([NotNull] this IHtmlHelper<TModel> html,
[NotNull] Expression<Func<TModel, TValue>> expression) [NotNull] Expression<Func<TModel, TValue>> expression)
@ -208,8 +234,14 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// <typeparam name="TValue">The type of the <paramref name="expression"/> result.</typeparam> /// <typeparam name="TValue">The type of the <paramref name="expression"/> result.</typeparam>
/// <returns>A new <see cref="HtmlString"/> containing the created HTML.</returns> /// <returns>A new <see cref="HtmlString"/> containing the created HTML.</returns>
/// <remarks> /// <remarks>
/// <para>
/// For example the default <see cref="object"/> display template includes markup for each property in the /// For example the default <see cref="object"/> display template includes markup for each property in the
/// <paramref name="expression"/> result. /// <paramref name="expression"/> result.
/// </para>
/// <para>
/// Custom templates are found under a <c>DisplayTemplates</c> folder. The folder name is case-sensitive on
/// case-sensitive file systems.
/// </para>
/// </remarks> /// </remarks>
public static HtmlString DisplayFor<TModel, TValue>([NotNull] this IHtmlHelper<TModel> html, public static HtmlString DisplayFor<TModel, TValue>([NotNull] this IHtmlHelper<TModel> html,
[NotNull] Expression<Func<TModel, TValue>> expression, [NotNull] Expression<Func<TModel, TValue>> expression,
@ -231,8 +263,14 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// <typeparam name="TValue">The type of the <paramref name="expression"/> result.</typeparam> /// <typeparam name="TValue">The type of the <paramref name="expression"/> result.</typeparam>
/// <returns>A new <see cref="HtmlString"/> containing the created HTML.</returns> /// <returns>A new <see cref="HtmlString"/> containing the created HTML.</returns>
/// <remarks> /// <remarks>
/// <para>
/// For example the default <see cref="object"/> display template includes markup for each property in the /// For example the default <see cref="object"/> display template includes markup for each property in the
/// <paramref name="expression"/> result. /// <paramref name="expression"/> result.
/// </para>
/// <para>
/// Custom templates are found under a <c>DisplayTemplates</c> folder. The folder name is case-sensitive on
/// case-sensitive file systems.
/// </para>
/// </remarks> /// </remarks>
public static HtmlString DisplayFor<TModel, TValue>([NotNull] this IHtmlHelper<TModel> html, public static HtmlString DisplayFor<TModel, TValue>([NotNull] this IHtmlHelper<TModel> html,
[NotNull] Expression<Func<TModel, TValue>> expression, [NotNull] Expression<Func<TModel, TValue>> expression,
@ -258,8 +296,14 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// <typeparam name="TValue">The type of the <paramref name="expression"/> result.</typeparam> /// <typeparam name="TValue">The type of the <paramref name="expression"/> result.</typeparam>
/// <returns>A new <see cref="HtmlString"/> containing the created HTML.</returns> /// <returns>A new <see cref="HtmlString"/> containing the created HTML.</returns>
/// <remarks> /// <remarks>
/// <para>
/// For example the default <see cref="object"/> display template includes markup for each property in the /// For example the default <see cref="object"/> display template includes markup for each property in the
/// <paramref name="expression"/> result. /// <paramref name="expression"/> result.
/// </para>
/// <para>
/// Custom templates are found under a <c>DisplayTemplates</c> folder. The folder name is case-sensitive on
/// case-sensitive file systems.
/// </para>
/// </remarks> /// </remarks>
public static HtmlString DisplayFor<TModel, TValue>([NotNull] this IHtmlHelper<TModel> html, public static HtmlString DisplayFor<TModel, TValue>([NotNull] this IHtmlHelper<TModel> html,
[NotNull] Expression<Func<TModel, TValue>> expression, [NotNull] Expression<Func<TModel, TValue>> expression,
@ -286,8 +330,14 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// <typeparam name="TValue">The type of the <paramref name="expression"/> result.</typeparam> /// <typeparam name="TValue">The type of the <paramref name="expression"/> result.</typeparam>
/// <returns>A new <see cref="HtmlString"/> containing the created HTML.</returns> /// <returns>A new <see cref="HtmlString"/> containing the created HTML.</returns>
/// <remarks> /// <remarks>
/// <para>
/// For example the default <see cref="object"/> display template includes markup for each property in the /// For example the default <see cref="object"/> display template includes markup for each property in the
/// <paramref name="expression"/> result. /// <paramref name="expression"/> result.
/// </para>
/// <para>
/// Custom templates are found under a <c>DisplayTemplates</c> folder. The folder name is case-sensitive on
/// case-sensitive file systems.
/// </para>
/// </remarks> /// </remarks>
public static HtmlString DisplayFor<TModel, TValue>([NotNull] this IHtmlHelper<TModel> html, public static HtmlString DisplayFor<TModel, TValue>([NotNull] this IHtmlHelper<TModel> html,
[NotNull] Expression<Func<TModel, TValue>> expression, [NotNull] Expression<Func<TModel, TValue>> expression,
@ -305,8 +355,14 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// <param name="html">The <see cref="IHtmlHelper"/> instance this method extends.</param> /// <param name="html">The <see cref="IHtmlHelper"/> instance this method extends.</param>
/// <returns>A new <see cref="HtmlString"/> containing the created HTML.</returns> /// <returns>A new <see cref="HtmlString"/> containing the created HTML.</returns>
/// <remarks> /// <remarks>
/// <para>
/// For example the default <see cref="object"/> display template includes markup for each property in the /// For example the default <see cref="object"/> display template includes markup for each property in the
/// current model. /// current model.
/// </para>
/// <para>
/// Custom templates are found under a <c>DisplayTemplates</c> folder. The folder name is case-sensitive on
/// case-sensitive file systems.
/// </para>
/// </remarks> /// </remarks>
public static HtmlString DisplayForModel([NotNull] this IHtmlHelper html) public static HtmlString DisplayForModel([NotNull] this IHtmlHelper html)
{ {
@ -325,8 +381,14 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// </param> /// </param>
/// <returns>A new <see cref="HtmlString"/> containing the created HTML.</returns> /// <returns>A new <see cref="HtmlString"/> containing the created HTML.</returns>
/// <remarks> /// <remarks>
/// <para>
/// For example the default <see cref="object"/> display template includes markup for each property in the /// For example the default <see cref="object"/> display template includes markup for each property in the
/// current model. /// current model.
/// </para>
/// <para>
/// Custom templates are found under a <c>DisplayTemplates</c> folder. The folder name is case-sensitive on
/// case-sensitive file systems.
/// </para>
/// </remarks> /// </remarks>
public static HtmlString DisplayForModel([NotNull] this IHtmlHelper html, object additionalViewData) public static HtmlString DisplayForModel([NotNull] this IHtmlHelper html, object additionalViewData)
{ {
@ -342,8 +404,14 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// <param name="templateName">The name of the template used to create the HTML markup.</param> /// <param name="templateName">The name of the template used to create the HTML markup.</param>
/// <returns>A new <see cref="HtmlString"/> containing the created HTML.</returns> /// <returns>A new <see cref="HtmlString"/> containing the created HTML.</returns>
/// <remarks> /// <remarks>
/// <para>
/// For example the default <see cref="object"/> display template includes markup for each property in the /// For example the default <see cref="object"/> display template includes markup for each property in the
/// current model. /// current model.
/// </para>
/// <para>
/// Custom templates are found under a <c>DisplayTemplates</c> folder. The folder name is case-sensitive on
/// case-sensitive file systems.
/// </para>
/// </remarks> /// </remarks>
public static HtmlString DisplayForModel([NotNull] this IHtmlHelper html, string templateName) public static HtmlString DisplayForModel([NotNull] this IHtmlHelper html, string templateName)
{ {
@ -365,8 +433,14 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// </param> /// </param>
/// <returns>A new <see cref="HtmlString"/> containing the created HTML.</returns> /// <returns>A new <see cref="HtmlString"/> containing the created HTML.</returns>
/// <remarks> /// <remarks>
/// <para>
/// For example the default <see cref="object"/> display template includes markup for each property in the /// For example the default <see cref="object"/> display template includes markup for each property in the
/// current model. /// current model.
/// </para>
/// <para>
/// Custom templates are found under a <c>DisplayTemplates</c> folder. The folder name is case-sensitive on
/// case-sensitive file systems.
/// </para>
/// </remarks> /// </remarks>
public static HtmlString DisplayForModel( public static HtmlString DisplayForModel(
[NotNull] this IHtmlHelper html, [NotNull] this IHtmlHelper html,
@ -390,8 +464,14 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// </param> /// </param>
/// <returns>A new <see cref="HtmlString"/> containing the created HTML.</returns> /// <returns>A new <see cref="HtmlString"/> containing the created HTML.</returns>
/// <remarks> /// <remarks>
/// <para>
/// For example the default <see cref="object"/> display template includes markup for each property in the /// For example the default <see cref="object"/> display template includes markup for each property in the
/// current model. /// current model.
/// </para>
/// <para>
/// Custom templates are found under a <c>DisplayTemplates</c> folder. The folder name is case-sensitive on
/// case-sensitive file systems.
/// </para>
/// </remarks> /// </remarks>
public static HtmlString DisplayForModel( public static HtmlString DisplayForModel(
[NotNull] this IHtmlHelper html, [NotNull] this IHtmlHelper html,
@ -420,8 +500,14 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// </param> /// </param>
/// <returns>A new <see cref="HtmlString"/> containing the created HTML.</returns> /// <returns>A new <see cref="HtmlString"/> containing the created HTML.</returns>
/// <remarks> /// <remarks>
/// <para>
/// For example the default <see cref="object"/> display template includes markup for each property in the /// For example the default <see cref="object"/> display template includes markup for each property in the
/// current model. /// current model.
/// </para>
/// <para>
/// Custom templates are found under a <c>DisplayTemplates</c> folder. The folder name is case-sensitive on
/// case-sensitive file systems.
/// </para>
/// </remarks> /// </remarks>
public static HtmlString DisplayForModel( public static HtmlString DisplayForModel(
[NotNull] this IHtmlHelper html, [NotNull] this IHtmlHelper html,

View File

@ -30,6 +30,10 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// Example <paramref name="expression"/>s include <c>string.Empty</c> which identifies the current model and /// Example <paramref name="expression"/>s include <c>string.Empty</c> which identifies the current model and
/// <c>"prop"</c> which identifies the current model's "prop" property. /// <c>"prop"</c> which identifies the current model's "prop" property.
/// </para> /// </para>
/// <para>
/// Custom templates are found under a <c>EditorTemplates</c> folder. The folder name is case-sensitive on
/// case-sensitive file systems.
/// </para>
/// </remarks> /// </remarks>
public static HtmlString Editor([NotNull] this IHtmlHelper html, string expression) public static HtmlString Editor([NotNull] this IHtmlHelper html, string expression)
{ {
@ -61,6 +65,10 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// Example <paramref name="expression"/>s include <c>string.Empty</c> which identifies the current model and /// Example <paramref name="expression"/>s include <c>string.Empty</c> which identifies the current model and
/// <c>"prop"</c> which identifies the current model's "prop" property. /// <c>"prop"</c> which identifies the current model's "prop" property.
/// </para> /// </para>
/// <para>
/// Custom templates are found under a <c>EditorTemplates</c> folder. The folder name is case-sensitive on
/// case-sensitive file systems.
/// </para>
/// </remarks> /// </remarks>
public static HtmlString Editor([NotNull] this IHtmlHelper html, string expression, object additionalViewData) public static HtmlString Editor([NotNull] this IHtmlHelper html, string expression, object additionalViewData)
{ {
@ -89,6 +97,10 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// Example <paramref name="expression"/>s include <c>string.Empty</c> which identifies the current model and /// Example <paramref name="expression"/>s include <c>string.Empty</c> which identifies the current model and
/// <c>"prop"</c> which identifies the current model's "prop" property. /// <c>"prop"</c> which identifies the current model's "prop" property.
/// </para> /// </para>
/// <para>
/// Custom templates are found under a <c>EditorTemplates</c> folder. The folder name is case-sensitive on
/// case-sensitive file systems.
/// </para>
/// </remarks> /// </remarks>
public static HtmlString Editor([NotNull] this IHtmlHelper html, string expression, string templateName) public static HtmlString Editor([NotNull] this IHtmlHelper html, string expression, string templateName)
{ {
@ -121,6 +133,10 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// Example <paramref name="expression"/>s include <c>string.Empty</c> which identifies the current model and /// Example <paramref name="expression"/>s include <c>string.Empty</c> which identifies the current model and
/// <c>"prop"</c> which identifies the current model's "prop" property. /// <c>"prop"</c> which identifies the current model's "prop" property.
/// </para> /// </para>
/// <para>
/// Custom templates are found under a <c>EditorTemplates</c> folder. The folder name is case-sensitive on
/// case-sensitive file systems.
/// </para>
/// </remarks> /// </remarks>
public static HtmlString Editor([NotNull] this IHtmlHelper html, string expression, string templateName, public static HtmlString Editor([NotNull] this IHtmlHelper html, string expression, string templateName,
object additionalViewData) object additionalViewData)
@ -153,6 +169,10 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// Example <paramref name="expression"/>s include <c>string.Empty</c> which identifies the current model and /// Example <paramref name="expression"/>s include <c>string.Empty</c> which identifies the current model and
/// <c>"prop"</c> which identifies the current model's "prop" property. /// <c>"prop"</c> which identifies the current model's "prop" property.
/// </para> /// </para>
/// <para>
/// Custom templates are found under a <c>EditorTemplates</c> folder. The folder name is case-sensitive on
/// case-sensitive file systems.
/// </para>
/// </remarks> /// </remarks>
public static HtmlString Editor([NotNull] this IHtmlHelper html, string expression, string templateName, public static HtmlString Editor([NotNull] this IHtmlHelper html, string expression, string templateName,
string htmlFieldName) string htmlFieldName)
@ -170,8 +190,14 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// <typeparam name="TValue">The type of the <paramref name="expression"/> result.</typeparam> /// <typeparam name="TValue">The type of the <paramref name="expression"/> result.</typeparam>
/// <returns>A new <see cref="HtmlString"/> containing the &lt;input&gt; element(s).</returns> /// <returns>A new <see cref="HtmlString"/> containing the &lt;input&gt; element(s).</returns>
/// <remarks> /// <remarks>
/// <para>
/// For example the default <see cref="object"/> editor template includes &lt;label&gt; and &lt;input&gt; /// For example the default <see cref="object"/> editor template includes &lt;label&gt; and &lt;input&gt;
/// elements for each property in the <paramref name="expression"/> result. /// elements for each property in the <paramref name="expression"/> result.
/// </para>
/// <para>
/// Custom templates are found under a <c>EditorTemplates</c> folder. The folder name is case-sensitive on
/// case-sensitive file systems.
/// </para>
/// </remarks> /// </remarks>
public static HtmlString EditorFor<TModel, TValue>([NotNull] this IHtmlHelper<TModel> html, public static HtmlString EditorFor<TModel, TValue>([NotNull] this IHtmlHelper<TModel> html,
[NotNull] Expression<Func<TModel, TValue>> expression) [NotNull] Expression<Func<TModel, TValue>> expression)
@ -195,8 +221,14 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// <typeparam name="TValue">The type of the <paramref name="expression"/> result.</typeparam> /// <typeparam name="TValue">The type of the <paramref name="expression"/> result.</typeparam>
/// <returns>A new <see cref="HtmlString"/> containing the &lt;input&gt; element(s).</returns> /// <returns>A new <see cref="HtmlString"/> containing the &lt;input&gt; element(s).</returns>
/// <remarks> /// <remarks>
/// <para>
/// For example the default <see cref="object"/> editor template includes &lt;label&gt; and &lt;input&gt; /// For example the default <see cref="object"/> editor template includes &lt;label&gt; and &lt;input&gt;
/// elements for each property in the <paramref name="expression"/> result. /// elements for each property in the <paramref name="expression"/> result.
/// </para>
/// <para>
/// Custom templates are found under a <c>EditorTemplates</c> folder. The folder name is case-sensitive on
/// case-sensitive file systems.
/// </para>
/// </remarks> /// </remarks>
public static HtmlString EditorFor<TModel, TValue>([NotNull] this IHtmlHelper<TModel> html, public static HtmlString EditorFor<TModel, TValue>([NotNull] this IHtmlHelper<TModel> html,
[NotNull] Expression<Func<TModel, TValue>> expression, object additionalViewData) [NotNull] Expression<Func<TModel, TValue>> expression, object additionalViewData)
@ -217,8 +249,14 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// <typeparam name="TValue">The type of the <paramref name="expression"/> result.</typeparam> /// <typeparam name="TValue">The type of the <paramref name="expression"/> result.</typeparam>
/// <returns>A new <see cref="HtmlString"/> containing the &lt;input&gt; element(s).</returns> /// <returns>A new <see cref="HtmlString"/> containing the &lt;input&gt; element(s).</returns>
/// <remarks> /// <remarks>
/// <para>
/// For example the default <see cref="object"/> editor template includes &lt;label&gt; and &lt;input&gt; /// For example the default <see cref="object"/> editor template includes &lt;label&gt; and &lt;input&gt;
/// elements for each property in the <paramref name="expression"/> result. /// elements for each property in the <paramref name="expression"/> result.
/// </para>
/// <para>
/// Custom templates are found under a <c>EditorTemplates</c> folder. The folder name is case-sensitive on
/// case-sensitive file systems.
/// </para>
/// </remarks> /// </remarks>
public static HtmlString EditorFor<TModel, TValue>([NotNull] this IHtmlHelper<TModel> html, public static HtmlString EditorFor<TModel, TValue>([NotNull] this IHtmlHelper<TModel> html,
[NotNull] Expression<Func<TModel, TValue>> expression, string templateName) [NotNull] Expression<Func<TModel, TValue>> expression, string templateName)
@ -243,8 +281,14 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// <typeparam name="TValue">The type of the <paramref name="expression"/> result.</typeparam> /// <typeparam name="TValue">The type of the <paramref name="expression"/> result.</typeparam>
/// <returns>A new <see cref="HtmlString"/> containing the &lt;input&gt; element(s).</returns> /// <returns>A new <see cref="HtmlString"/> containing the &lt;input&gt; element(s).</returns>
/// <remarks> /// <remarks>
/// <para>
/// For example the default <see cref="object"/> editor template includes &lt;label&gt; and &lt;input&gt; /// For example the default <see cref="object"/> editor template includes &lt;label&gt; and &lt;input&gt;
/// elements for each property in the <paramref name="expression"/> result. /// elements for each property in the <paramref name="expression"/> result.
/// </para>
/// <para>
/// Custom templates are found under a <c>EditorTemplates</c> folder. The folder name is case-sensitive on
/// case-sensitive file systems.
/// </para>
/// </remarks> /// </remarks>
public static HtmlString EditorFor<TModel, TValue>([NotNull] this IHtmlHelper<TModel> html, public static HtmlString EditorFor<TModel, TValue>([NotNull] this IHtmlHelper<TModel> html,
[NotNull] Expression<Func<TModel, TValue>> expression, string templateName, object additionalViewData) [NotNull] Expression<Func<TModel, TValue>> expression, string templateName, object additionalViewData)
@ -269,8 +313,14 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// <typeparam name="TValue">The type of the <paramref name="expression"/> result.</typeparam> /// <typeparam name="TValue">The type of the <paramref name="expression"/> result.</typeparam>
/// <returns>A new <see cref="HtmlString"/> containing the &lt;input&gt; element(s).</returns> /// <returns>A new <see cref="HtmlString"/> containing the &lt;input&gt; element(s).</returns>
/// <remarks> /// <remarks>
/// <para>
/// For example the default <see cref="object"/> editor template includes &lt;label&gt; and &lt;input&gt; /// For example the default <see cref="object"/> editor template includes &lt;label&gt; and &lt;input&gt;
/// elements for each property in the <paramref name="expression"/> result. /// elements for each property in the <paramref name="expression"/> result.
/// </para>
/// <para>
/// Custom templates are found under a <c>EditorTemplates</c> folder. The folder name is case-sensitive on
/// case-sensitive file systems.
/// </para>
/// </remarks> /// </remarks>
public static HtmlString EditorFor<TModel, TValue>([NotNull] this IHtmlHelper<TModel> html, public static HtmlString EditorFor<TModel, TValue>([NotNull] this IHtmlHelper<TModel> html,
[NotNull] Expression<Func<TModel, TValue>> expression, string templateName, string htmlFieldName) [NotNull] Expression<Func<TModel, TValue>> expression, string templateName, string htmlFieldName)
@ -285,8 +335,14 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// <param name="html">The <see cref="IHtmlHelper"/> instance this method extends.</param> /// <param name="html">The <see cref="IHtmlHelper"/> instance this method extends.</param>
/// <returns>A new <see cref="HtmlString"/> containing the &lt;input&gt; element(s).</returns> /// <returns>A new <see cref="HtmlString"/> containing the &lt;input&gt; element(s).</returns>
/// <remarks> /// <remarks>
/// <para>
/// For example the default <see cref="object"/> editor template includes &lt;label&gt; and &lt;input&gt; /// For example the default <see cref="object"/> editor template includes &lt;label&gt; and &lt;input&gt;
/// elements for each property in the <paramref name="expression"/> result. /// elements for each property in the <paramref name="expression"/> result.
/// </para>
/// <para>
/// Custom templates are found under a <c>EditorTemplates</c> folder. The folder name is case-sensitive on
/// case-sensitive file systems.
/// </para>
/// </remarks> /// </remarks>
public static HtmlString EditorForModel([NotNull] this IHtmlHelper html) public static HtmlString EditorForModel([NotNull] this IHtmlHelper html)
{ {
@ -305,8 +361,14 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// </param> /// </param>
/// <returns>A new <see cref="HtmlString"/> containing the &lt;input&gt; element(s).</returns> /// <returns>A new <see cref="HtmlString"/> containing the &lt;input&gt; element(s).</returns>
/// <remarks> /// <remarks>
/// <para>
/// For example the default <see cref="object"/> editor template includes &lt;label&gt; and &lt;input&gt; /// For example the default <see cref="object"/> editor template includes &lt;label&gt; and &lt;input&gt;
/// elements for each property in the current model. /// elements for each property in the current model.
/// </para>
/// <para>
/// Custom templates are found under a <c>EditorTemplates</c> folder. The folder name is case-sensitive on
/// case-sensitive file systems.
/// </para>
/// </remarks> /// </remarks>
public static HtmlString EditorForModel([NotNull] this IHtmlHelper html, object additionalViewData) public static HtmlString EditorForModel([NotNull] this IHtmlHelper html, object additionalViewData)
{ {
@ -322,8 +384,14 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// <param name="templateName">The name of the template used to create the HTML markup.</param> /// <param name="templateName">The name of the template used to create the HTML markup.</param>
/// <returns>A new <see cref="HtmlString"/> containing the &lt;input&gt; element(s).</returns> /// <returns>A new <see cref="HtmlString"/> containing the &lt;input&gt; element(s).</returns>
/// <remarks> /// <remarks>
/// <para>
/// For example the default <see cref="object"/> editor template includes &lt;label&gt; and &lt;input&gt; /// For example the default <see cref="object"/> editor template includes &lt;label&gt; and &lt;input&gt;
/// elements for each property in the current model. /// elements for each property in the current model.
/// </para>
/// <para>
/// Custom templates are found under a <c>EditorTemplates</c> folder. The folder name is case-sensitive on
/// case-sensitive file systems.
/// </para>
/// </remarks> /// </remarks>
public static HtmlString EditorForModel([NotNull] this IHtmlHelper html, string templateName) public static HtmlString EditorForModel([NotNull] this IHtmlHelper html, string templateName)
{ {
@ -345,8 +413,14 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// </param> /// </param>
/// <returns>A new <see cref="HtmlString"/> containing the &lt;input&gt; element(s).</returns> /// <returns>A new <see cref="HtmlString"/> containing the &lt;input&gt; element(s).</returns>
/// <remarks> /// <remarks>
/// <para>
/// For example the default <see cref="object"/> editor template includes &lt;label&gt; and &lt;input&gt; /// For example the default <see cref="object"/> editor template includes &lt;label&gt; and &lt;input&gt;
/// elements for each property in the current model. /// elements for each property in the current model.
/// </para>
/// <para>
/// Custom templates are found under a <c>EditorTemplates</c> folder. The folder name is case-sensitive on
/// case-sensitive file systems.
/// </para>
/// </remarks> /// </remarks>
public static HtmlString EditorForModel([NotNull] this IHtmlHelper html, string templateName, public static HtmlString EditorForModel([NotNull] this IHtmlHelper html, string templateName,
object additionalViewData) object additionalViewData)
@ -368,8 +442,14 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// </param> /// </param>
/// <returns>A new <see cref="HtmlString"/> containing the &lt;input&gt; element(s).</returns> /// <returns>A new <see cref="HtmlString"/> containing the &lt;input&gt; element(s).</returns>
/// <remarks> /// <remarks>
/// <para>
/// For example the default <see cref="object"/> editor template includes &lt;label&gt; and &lt;input&gt; /// For example the default <see cref="object"/> editor template includes &lt;label&gt; and &lt;input&gt;
/// elements for each property in the current model. /// elements for each property in the current model.
/// </para>
/// <para>
/// Custom templates are found under a <c>EditorTemplates</c> folder. The folder name is case-sensitive on
/// case-sensitive file systems.
/// </para>
/// </remarks> /// </remarks>
public static HtmlString EditorForModel([NotNull] this IHtmlHelper html, string templateName, public static HtmlString EditorForModel([NotNull] this IHtmlHelper html, string templateName,
string htmlFieldName) string htmlFieldName)
@ -396,8 +476,14 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// </param> /// </param>
/// <returns>A new <see cref="HtmlString"/> containing the &lt;input&gt; element(s).</returns> /// <returns>A new <see cref="HtmlString"/> containing the &lt;input&gt; element(s).</returns>
/// <remarks> /// <remarks>
/// <para>
/// For example the default <see cref="object"/> editor template includes &lt;label&gt; and &lt;input&gt; /// For example the default <see cref="object"/> editor template includes &lt;label&gt; and &lt;input&gt;
/// elements for each property in the current model. /// elements for each property in the current model.
/// </para>
/// <para>
/// Custom templates are found under a <c>EditorTemplates</c> folder. The folder name is case-sensitive on
/// case-sensitive file systems.
/// </para>
/// </remarks> /// </remarks>
public static HtmlString EditorForModel([NotNull] this IHtmlHelper html, string templateName, public static HtmlString EditorForModel([NotNull] this IHtmlHelper html, string templateName,
string htmlFieldName, object additionalViewData) string htmlFieldName, object additionalViewData)

View File

@ -13,7 +13,7 @@ namespace Microsoft.AspNet.Mvc.Razor
{ {
/// <summary> /// <summary>
/// A subtype of <see cref="RazorParser"/> that <see cref="MvcRazorHost"/> uses to support inheritance of tag /// A subtype of <see cref="RazorParser"/> that <see cref="MvcRazorHost"/> uses to support inheritance of tag
/// helpers from _viewstart files. /// helpers from <c>_ViewStart</c> files.
/// </summary> /// </summary>
public class MvcRazorParser : RazorParser public class MvcRazorParser : RazorParser
{ {

View File

@ -8,9 +8,12 @@ using System.Linq;
namespace Microsoft.AspNet.Mvc.Razor namespace Microsoft.AspNet.Mvc.Razor
{ {
/// <summary>
/// Contains the methods to locate <c>_ViewStart.cshtml</c>
/// </summary>
public static class ViewStartUtility public static class ViewStartUtility
{ {
private const string ViewStartFileName = "_viewstart.cshtml"; private const string ViewStartFileName = "_ViewStart.cshtml";
/// <summary> /// <summary>
/// Determines if the given path represents a view start file. /// Determines if the given path represents a view start file.

View File

@ -13,6 +13,10 @@ namespace Microsoft.AspNet.Mvc.Razor
/// <summary> /// <summary>
/// Default implementation of <see cref="IRazorViewEngine"/>. /// Default implementation of <see cref="IRazorViewEngine"/>.
/// </summary> /// </summary>
/// <remarks>
/// For <c>ViewResults</c> returned from controllers, views should be located in <see cref="ViewLocationFormats"/>
/// by default. For the controllers in an area, views should exist in <see cref="AreaViewLocationFormats"/>.
/// </remarks>
public class RazorViewEngine : IRazorViewEngine public class RazorViewEngine : IRazorViewEngine
{ {
private const string ViewExtension = ".cshtml"; private const string ViewExtension = ".cshtml";
@ -55,6 +59,16 @@ namespace Microsoft.AspNet.Mvc.Razor
/// <summary> /// <summary>
/// Gets the locations where this instance of <see cref="RazorViewEngine"/> will search for views. /// Gets the locations where this instance of <see cref="RazorViewEngine"/> will search for views.
/// </summary> /// </summary>
/// <remarks>
/// The locations of the views returned from controllers that do not belong to an area.
/// Locations are composite format strings (see http://msdn.microsoft.com/en-us/library/txafckwd.aspx),
/// which contains following indexes:
/// {0} - Action Name
/// {1} - Controller Name
/// The values for these locations are case-sensitive on case-senstive file systems.
/// For example, the view for the <c>Test</c> action of <c>HomeController</c> should be located at
/// <c>/Views/Home/Test.cshtml</c>. Locations such as <c>/views/home/test.cshtml</c> would not be discovered
/// </remarks>
public virtual IEnumerable<string> ViewLocationFormats public virtual IEnumerable<string> ViewLocationFormats
{ {
get { return _viewLocationFormats; } get { return _viewLocationFormats; }
@ -64,6 +78,17 @@ namespace Microsoft.AspNet.Mvc.Razor
/// Gets the locations where this instance of <see cref="RazorViewEngine"/> will search for views within an /// Gets the locations where this instance of <see cref="RazorViewEngine"/> will search for views within an
/// area. /// area.
/// </summary> /// </summary>
/// <remarks>
/// The locations of the views returned from controllers that belong to an area.
/// Locations are composite format strings (see http://msdn.microsoft.com/en-us/library/txafckwd.aspx),
/// which contains following indexes:
/// {0} - Action Name
/// {1} - Controller Name
/// {2} - Area name
/// The values for these locations are case-sensitive on case-senstive file systems.
/// For example, the view for the <c>Test</c> action of <c>HomeController</c> should be located at
/// <c>/Views/Home/Test.cshtml</c>. Locations such as <c>/views/home/test.cshtml</c> would not be discovered
/// </remarks>
public virtual IEnumerable<string> AreaViewLocationFormats public virtual IEnumerable<string> AreaViewLocationFormats
{ {
get { return _areaViewLocationFormats; } get { return _areaViewLocationFormats; }

View File

@ -291,5 +291,23 @@ namespace Microsoft.AspNet.Mvc.Core
var ex = Assert.Throws<ArgumentException>(() => helper.DisplayFor(m => m.Property1)); var ex = Assert.Throws<ArgumentException>(() => helper.DisplayFor(m => m.Property1));
Assert.Equal(expectedMessage, ex.Message); Assert.Equal(expectedMessage, ex.Message);
} }
[Fact]
public void Display_CallsFindPartialView_WithExpectedPath()
{
// Arrange
var viewEngine = new Mock<ICompositeViewEngine>(MockBehavior.Strict);
viewEngine
.Setup(v => v.FindPartialView(It.IsAny<ActionContext>(),
It.Is<string>(view => view.Equals("DisplayTemplates/String"))))
.Returns(ViewEngineResult.Found(string.Empty, new Mock<IView>().Object))
.Verifiable();
var html = DefaultTemplatesUtilities.GetHtmlHelper(new object(), viewEngine: viewEngine.Object);
// Act & Assert
html.Display(expression: string.Empty, templateName: null, htmlFieldName: null, additionalViewData: null);
viewEngine.Verify();
}
} }
} }

View File

@ -684,6 +684,24 @@ Environment.NewLine;
Assert.Equal(expectedMessage, ex.Message); Assert.Equal(expectedMessage, ex.Message);
} }
[Fact]
public void EditorForModel_CallsFindPartialView_WithExpectedPath()
{
// Arrange
var viewEngine = new Mock<ICompositeViewEngine>(MockBehavior.Strict);
viewEngine
.Setup(v => v.FindPartialView(It.IsAny<ActionContext>(),
It.Is<string>(view => String.Equals(view,
"EditorTemplates/String"))))
.Returns(ViewEngineResult.Found(string.Empty, new Mock<IView>().Object))
.Verifiable();
var html = DefaultTemplatesUtilities.GetHtmlHelper(new object(), viewEngine: viewEngine.Object);
// Act & Assert
html.Editor(expression: string.Empty, templateName: null, htmlFieldName: null, additionalViewData: null);
viewEngine.Verify();
}
private class StubbyHtmlHelper : IHtmlHelper, ICanHasViewContext private class StubbyHtmlHelper : IHtmlHelper, ICanHasViewContext
{ {
private readonly IHtmlHelper _innerHelper; private readonly IHtmlHelper _innerHelper;

View File

@ -159,7 +159,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
var provider = new Mock<IViewEngineProvider>(); var provider = new Mock<IViewEngineProvider>();
var engine = new Mock<IViewEngine>(); var engine = new Mock<IViewEngine>();
engine.Setup(e => e.FindPartialView(It.IsAny<ActionContext>(), It.IsAny<string>())) engine.Setup(e => e.FindPartialView(It.IsAny<ActionContext>(), It.IsAny<string>()))
.Returns(ViewEngineResult.NotFound(viewName, new[] { "shared/partial-view" })); .Returns(ViewEngineResult.NotFound(viewName, new[] { "Shared/partial-view" }));
provider.SetupGet(p => p.ViewEngines) provider.SetupGet(p => p.ViewEngines)
.Returns(new[] { engine.Object }); .Returns(new[] { engine.Object });
var compositeViewEngine = new CompositeViewEngine(provider.Object); var compositeViewEngine = new CompositeViewEngine(provider.Object);
@ -169,7 +169,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
// Assert // Assert
Assert.False(result.Success); Assert.False(result.Success);
Assert.Equal(new[] { "shared/partial-view" }, result.SearchedLocations); Assert.Equal(new[] { "Shared/partial-view" }, result.SearchedLocations);
} }
[Fact] [Fact]

View File

@ -276,6 +276,28 @@ namespace Microsoft.AspNet.Mvc
Assert.Equal(expected, ex.Message); Assert.Equal(expected, ex.Message);
} }
[Fact]
public void Execute_CallsFindPartialView_WithExpectedPath()
{
// Arrange
var viewEngine = new Mock<ICompositeViewEngine>(MockBehavior.Strict);
viewEngine
.Setup(v => v.FindPartialView(It.IsAny<ActionContext>(),
It.Is<string>(view => view.Contains("Components"))))
.Returns(ViewEngineResult.Found(string.Empty, new Mock<IView>().Object))
.Verifiable();
var viewData = new ViewDataDictionary(new EmptyModelMetadataProvider());
var componentContext = GetViewComponentContext(new Mock<IView>().Object, viewData);
var componentResult = new ViewViewComponentResult();
componentResult.ViewEngine = viewEngine.Object;
componentResult.ViewData = viewData;
// Act & Assert
componentResult.Execute(componentContext);
viewEngine.Verify();
}
private static ViewComponentContext GetViewComponentContext(IView view, ViewDataDictionary viewData) private static ViewComponentContext GetViewComponentContext(IView view, ViewDataDictionary viewData)
{ {
var actionContext = new ActionContext(new RouteContext(new DefaultHttpContext()), new ActionDescriptor()); var actionContext = new ActionContext(new RouteContext(new DefaultHttpContext()), new ActionDescriptor());

View File

@ -13,10 +13,10 @@ namespace Microsoft.AspNet.Mvc.Razor.Directives
{ {
// Arrange // Arrange
var fileSystem = new TestFileSystem(); var fileSystem = new TestFileSystem();
fileSystem.AddFile(@"views\accounts\_viewstart.cshtml", "@using AccountModels"); fileSystem.AddFile(@"Views\accounts\_ViewStart.cshtml", "@using AccountModels");
fileSystem.AddFile(@"views\Shared\_viewstart.cshtml", "@inject SharedHelper Shared"); fileSystem.AddFile(@"Views\Shared\_ViewStart.cshtml", "@inject SharedHelper Shared");
fileSystem.AddFile(@"views\home\_viewstart.cshtml", "@using MyNamespace"); fileSystem.AddFile(@"Views\home\_ViewStart.cshtml", "@using MyNamespace");
fileSystem.AddFile(@"views\_viewstart.cshtml", fileSystem.AddFile(@"Views\_ViewStart.cshtml",
@"@inject MyHelper<TModel> Helper @"@inject MyHelper<TModel> Helper
@inherits MyBaseType @inherits MyBaseType
@ -29,7 +29,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Directives
var utility = new ChunkInheritanceUtility(host, fileSystem, new Chunk[0]); var utility = new ChunkInheritanceUtility(host, fileSystem, new Chunk[0]);
// Act // Act
var chunks = utility.GetInheritedChunks(@"views\home\Index.cshtml"); var chunks = utility.GetInheritedChunks(@"Views\home\Index.cshtml");
// Assert // Assert
Assert.Equal(8, chunks.Count); Assert.Equal(8, chunks.Count);
@ -57,14 +57,14 @@ namespace Microsoft.AspNet.Mvc.Razor.Directives
{ {
// Arrange // Arrange
var fileSystem = new TestFileSystem(); var fileSystem = new TestFileSystem();
fileSystem.AddFile(@"_viewstart.cs", string.Empty); fileSystem.AddFile(@"_ViewStart.cs", string.Empty);
fileSystem.AddFile(@"views\_Layout.cshtml", string.Empty); fileSystem.AddFile(@"Views\_Layout.cshtml", string.Empty);
fileSystem.AddFile(@"views\home\_not-viewstart.cshtml", string.Empty); fileSystem.AddFile(@"Views\home\_not-viewstart.cshtml", string.Empty);
var host = new MvcRazorHost(fileSystem); var host = new MvcRazorHost(fileSystem);
var utility = new ChunkInheritanceUtility(host, fileSystem, new Chunk[0]); var utility = new ChunkInheritanceUtility(host, fileSystem, new Chunk[0]);
// Act // Act
var chunks = utility.GetInheritedChunks(@"views\home\Index.cshtml"); var chunks = utility.GetInheritedChunks(@"Views\home\Index.cshtml");
// Assert // Assert
Assert.Empty(chunks); Assert.Empty(chunks);
@ -75,7 +75,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Directives
{ {
// Arrange // Arrange
var fileSystem = new TestFileSystem(); var fileSystem = new TestFileSystem();
fileSystem.AddFile(@"views\_viewstart.cshtml", fileSystem.AddFile(@"Views\_ViewStart.cshtml",
"@inject DifferentHelper<TModel> Html"); "@inject DifferentHelper<TModel> Html");
var host = new MvcRazorHost(fileSystem); var host = new MvcRazorHost(fileSystem);
var defaultChunks = new Chunk[] var defaultChunks = new Chunk[]
@ -86,7 +86,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Directives
var utility = new ChunkInheritanceUtility(host, fileSystem, defaultChunks); var utility = new ChunkInheritanceUtility(host, fileSystem, defaultChunks);
// Act // Act
var chunks = utility.GetInheritedChunks(@"views\Home\Index.cshtml"); var chunks = utility.GetInheritedChunks(@"Views\Home\Index.cshtml");
// Assert // Assert
Assert.Equal(4, chunks.Count); Assert.Equal(4, chunks.Count);

View File

@ -24,17 +24,17 @@ namespace Microsoft.AspNet.Mvc.Razor
} }
[Theory] [Theory]
[InlineData("/views/Home/MyView.cshtml")] [InlineData("/Views/Home/MyView.cshtml")]
[InlineData("~/views/Home/MyView.cshtml")] [InlineData("~/Views/Home/MyView.cshtml")]
[InlineData("views/Home/MyView.cshtml")] [InlineData("Views/Home/MyView.cshtml")]
public void GetViewStartLocations_ReturnsPotentialViewStartLocations_PathStartswithSlash(string inputPath) public void GetViewStartLocations_ReturnsPotentialViewStartLocations_PathStartswithSlash(string inputPath)
{ {
// Arrange // Arrange
var expected = new[] var expected = new[]
{ {
@"views\Home\_viewstart.cshtml", @"Views\Home\_ViewStart.cshtml",
@"views\_viewstart.cshtml", @"Views\_ViewStart.cshtml",
@"_viewstart.cshtml" @"_ViewStart.cshtml"
}; };
// Act // Act
@ -45,16 +45,16 @@ namespace Microsoft.AspNet.Mvc.Razor
} }
[Theory] [Theory]
[InlineData("/views/Home/_ViewStart.cshtml")] [InlineData("/Views/Home/_ViewStart.cshtml")]
[InlineData("~/views/Home/_viewstart.cshtml")] [InlineData("~/Views/Home/_Viewstart.cshtml")]
[InlineData("views/Home/_Viewstart.cshtml")] [InlineData("Views/Home/_Viewstart.cshtml")]
public void GetViewStartLocations_SkipsCurrentPath_IfCurrentIsViewStart(string inputPath) public void GetViewStartLocations_SkipsCurrentPath_IfCurrentIsViewStart(string inputPath)
{ {
// Arrange // Arrange
var expected = new[] var expected = new[]
{ {
@"views\_viewstart.cshtml", @"Views\_ViewStart.cshtml",
@"_viewstart.cshtml" @"_ViewStart.cshtml"
}; };
var fileSystem = new PhysicalFileSystem(GetTestFileSystemBase()); var fileSystem = new PhysicalFileSystem(GetTestFileSystemBase());
@ -73,12 +73,12 @@ namespace Microsoft.AspNet.Mvc.Razor
// Arrange // Arrange
var expected = new[] var expected = new[]
{ {
@"Areas\MyArea\Sub\Views\Admin\_viewstart.cshtml", @"Areas\MyArea\Sub\Views\Admin\_ViewStart.cshtml",
@"Areas\MyArea\Sub\Views\_viewstart.cshtml", @"Areas\MyArea\Sub\Views\_ViewStart.cshtml",
@"Areas\MyArea\Sub\_viewstart.cshtml", @"Areas\MyArea\Sub\_ViewStart.cshtml",
@"Areas\MyArea\_viewstart.cshtml", @"Areas\MyArea\_ViewStart.cshtml",
@"Areas\_viewstart.cshtml", @"Areas\_ViewStart.cshtml",
@"_viewstart.cshtml", @"_ViewStart.cshtml",
}; };
var viewPath = Path.Combine("Areas", "MyArea", "Sub", "Views", "Admin", fileName); var viewPath = Path.Combine("Areas", "MyArea", "Sub", "Views", "Admin", fileName);
@ -97,11 +97,11 @@ namespace Microsoft.AspNet.Mvc.Razor
// Arrange // Arrange
var expected = new[] var expected = new[]
{ {
@"Areas\MyArea\Sub\Views\_viewstart.cshtml", @"Areas\MyArea\Sub\Views\_ViewStart.cshtml",
@"Areas\MyArea\Sub\_viewstart.cshtml", @"Areas\MyArea\Sub\_ViewStart.cshtml",
@"Areas\MyArea\_viewstart.cshtml", @"Areas\MyArea\_ViewStart.cshtml",
@"Areas\_viewstart.cshtml", @"Areas\_ViewStart.cshtml",
@"_viewstart.cshtml", @"_ViewStart.cshtml",
}; };
var viewPath = Path.Combine("Areas", "MyArea", "Sub", "Views", "Admin", fileName); var viewPath = Path.Combine("Areas", "MyArea", "Sub", "Views", "Admin", fileName);
@ -117,7 +117,7 @@ namespace Microsoft.AspNet.Mvc.Razor
{ {
// Arrange // Arrange
var appBase = GetTestFileSystemBase(); var appBase = GetTestFileSystemBase();
var viewPath = "_viewstart.cshtml"; var viewPath = "_ViewStart.cshtml";
// Act // Act
var result = ViewStartUtility.GetViewStartLocations(viewPath); var result = ViewStartUtility.GetViewStartLocations(viewPath);

View File

@ -14,13 +14,13 @@ namespace Microsoft.AspNet.Mvc.Razor.Test
public class RazorCompilationServiceTest public class RazorCompilationServiceTest
{ {
[Theory] [Theory]
[InlineData(@"src\work\myapp", @"src\work\myapp\views\index\home.cshtml")] [InlineData(@"src\work\myapp", @"src\work\myapp\Views\index\home.cshtml")]
[InlineData(@"src\work\myapp\", @"src\work\myapp\views\index\home.cshtml")] [InlineData(@"src\work\myapp\", @"src\work\myapp\Views\index\home.cshtml")]
public void CompileCalculatesRootRelativePath(string appPath, string viewPath) public void CompileCalculatesRootRelativePath(string appPath, string viewPath)
{ {
// Arrange // Arrange
var host = new Mock<IMvcRazorHost>(); var host = new Mock<IMvcRazorHost>();
host.Setup(h => h.GenerateCode(@"views\index\home.cshtml", It.IsAny<Stream>())) host.Setup(h => h.GenerateCode(@"Views\index\home.cshtml", It.IsAny<Stream>()))
.Returns(GetGeneratorResult()) .Returns(GetGeneratorResult())
.Verifiable(); .Verifiable();
@ -37,7 +37,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Test
var relativeFileInfo = new RelativeFileInfo() var relativeFileInfo = new RelativeFileInfo()
{ {
FileInfo = fileInfo.Object, FileInfo = fileInfo.Object,
RelativePath = @"views\index\home.cshtml", RelativePath = @"Views\index\home.cshtml",
}; };
// Act // Act

View File

@ -594,6 +594,38 @@ namespace Microsoft.AspNet.Mvc.Razor.Test
Assert.Equal(expected, result.SearchedLocations); Assert.Equal(expected, result.SearchedLocations);
} }
[Fact]
public void AreaViewLocationFormats_ContainsExpectedLocations()
{
// Arrange
var viewEngine = CreateViewEngine();
var areaViewLocations = new string[]
{
"/Areas/{2}/Views/{1}/{0}.cshtml",
"/Areas/{2}/Views/Shared/{0}.cshtml",
"/Views/Shared/{0}.cshtml"
};
// Act & Assert
Assert.Equal(areaViewLocations, viewEngine.AreaViewLocationFormats);
}
[Fact]
public void ViewLocationFormats_ContainsExpectedLocations()
{
// Arrange
var viewEngine = CreateViewEngine();
var viewLocations = new string[]
{
"/Views/{1}/{0}.cshtml",
"/Views/Shared/{0}.cshtml"
};
// Act & Assert
Assert.Equal(viewLocations, viewEngine.ViewLocationFormats);
}
private RazorViewEngine CreateViewEngine(IRazorPageFactory pageFactory = null, private RazorViewEngine CreateViewEngine(IRazorPageFactory pageFactory = null,
IRazorViewFactory viewFactory = null, IRazorViewFactory viewFactory = null,
IEnumerable<IViewLocationExpander> expanders = null, IEnumerable<IViewLocationExpander> expanders = null,

View File

@ -1,3 +1,3 @@
@{ @{
Layout = "~/Views/NestedViewStarts/NestedViewStarts/Layout.cshtml"; Layout = "~/Views/NestedViewStarts/NestedViewStarts/Layout.cshtml";
} }

View File

@ -0,0 +1 @@
@using ViewComponentWebSite

View File

@ -1 +0,0 @@
@using ViewComponentWebSite