Cleanup pass in Rendering (and Common)

- correct `ArgumentNullOrEmpty` and pass parameter name to
  `ArgumentException` constructor
- remove `[SuppressMessage]` attributes
- `AnonymousObjectToHtmlAttributes` should return an `IDictionary`
- `var`
- remove straggling copyright notices
- wrap long lines (did not reword any comments)
- align a few parameters
This commit is contained in:
dougbu 2014-04-01 22:42:55 -07:00
parent dad87c5239
commit 7a97b13c8c
16 changed files with 72 additions and 69 deletions

View File

@ -1,6 +1,4 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information. using System;
using System;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
@ -94,7 +92,7 @@ namespace Microsoft.AspNet.Mvc
public static bool HasStringConverter([NotNull] this Type type) public static bool HasStringConverter([NotNull] this Type type)
{ {
TypeInfo typeInfo = type.GetTypeInfo(); var typeInfo = type.GetTypeInfo();
if (typeInfo.IsPrimitive || type == typeof(string)) if (typeInfo.IsPrimitive || type == typeof(string))
{ {
return true; return true;
@ -110,13 +108,13 @@ namespace Microsoft.AspNet.Mvc
public static Type[] GetTypeArgumentsIfMatch([NotNull] Type closedType, Type matchingOpenType) public static Type[] GetTypeArgumentsIfMatch([NotNull] Type closedType, Type matchingOpenType)
{ {
TypeInfo closedTypeInfo = closedType.GetTypeInfo(); var closedTypeInfo = closedType.GetTypeInfo();
if (!closedTypeInfo.IsGenericType) if (!closedTypeInfo.IsGenericType)
{ {
return null; return null;
} }
Type openType = closedType.GetGenericTypeDefinition(); var openType = closedType.GetGenericTypeDefinition();
return (matchingOpenType == openType) ? closedTypeInfo.GenericTypeArguments : null; return (matchingOpenType == openType) ? closedTypeInfo.GenericTypeArguments : null;
} }
} }

View File

@ -103,7 +103,7 @@ namespace Microsoft.AspNet.Mvc.Rendering.Expressions
{ {
throw new InvalidOperationException( throw new InvalidOperationException(
Resources.FormatExpressionHelper_InvalidIndexerExpression(expression, parameters[0].Name), Resources.FormatExpressionHelper_InvalidIndexerExpression(expression, parameters[0].Name),
ex); ex);
} }
return "[" + Convert.ToString(func(null), CultureInfo.InvariantCulture) + "]"; return "[" + Convert.ToString(func(null), CultureInfo.InvariantCulture) + "]";

View File

@ -1,6 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Globalization; using System.Globalization;
using System.IO; using System.IO;
using System.Net; using System.Net;
@ -77,7 +76,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
} }
/// <summary> /// <summary>
/// Creates a dictionary of HTML attributes from the input object, /// Creates a dictionary of HTML attributes from the input object,
/// translating underscores to dashes. /// translating underscores to dashes.
/// <example> /// <example>
/// new { data_name="value" } will translate to the entry { "data-name" , "value" } /// new { data_name="value" } will translate to the entry { "data-name" , "value" }
@ -86,10 +85,10 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// </summary> /// </summary>
/// <param name="htmlAttributes">Anonymous object describing HTML attributes.</param> /// <param name="htmlAttributes">Anonymous object describing HTML attributes.</param>
/// <returns>A dictionary that represents HTML attributes.</returns> /// <returns>A dictionary that represents HTML attributes.</returns>
public static Dictionary<string, object> AnonymousObjectToHtmlAttributes(object htmlAttributes) public static IDictionary<string, object> AnonymousObjectToHtmlAttributes(object htmlAttributes)
{ {
Dictionary<string, object> result; Dictionary<string, object> result;
IDictionary<string, object> valuesAsDictionary = htmlAttributes as IDictionary<string, object>; var valuesAsDictionary = htmlAttributes as IDictionary<string, object>;
if (valuesAsDictionary != null) if (valuesAsDictionary != null)
{ {
result = new Dictionary<string, object>(valuesAsDictionary, StringComparer.OrdinalIgnoreCase); result = new Dictionary<string, object>(valuesAsDictionary, StringComparer.OrdinalIgnoreCase);
@ -102,8 +101,8 @@ namespace Microsoft.AspNet.Mvc.Rendering
{ {
foreach (var prop in htmlAttributes.GetType().GetRuntimeProperties()) foreach (var prop in htmlAttributes.GetType().GetRuntimeProperties())
{ {
object val = prop.GetValue(htmlAttributes); var value = prop.GetValue(htmlAttributes);
result.Add(prop.Name, val); result.Add(prop.Name, value);
} }
} }
} }
@ -116,13 +115,11 @@ namespace Microsoft.AspNet.Mvc.Rendering
ViewContext = viewContext; ViewContext = viewContext;
} }
[SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Justification = "For consistency, all helpers are instance methods.")]
public string Encode(string value) public string Encode(string value)
{ {
return (!string.IsNullOrEmpty(value)) ? WebUtility.HtmlEncode(value) : string.Empty; return (!string.IsNullOrEmpty(value)) ? WebUtility.HtmlEncode(value) : string.Empty;
} }
[SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Justification = "For consistency, all helpers are instance methods.")]
public string Encode(object value) public string Encode(object value)
{ {
return value != null ? WebUtility.HtmlEncode(value.ToString()) : string.Empty; return value != null ? WebUtility.HtmlEncode(value.ToString()) : string.Empty;
@ -134,15 +131,14 @@ namespace Microsoft.AspNet.Mvc.Rendering
} }
/// <inheritdoc /> /// <inheritdoc />
[SuppressMessage("Microsoft.Naming", "CA1719:ParameterNamesShouldNotMatchMemberNames",
MessageId = "1#", Justification = "This is a shipped API.")]
public virtual HtmlString Name(string name) public virtual HtmlString Name(string name)
{ {
var fullName = ViewData.TemplateInfo.GetFullHtmlFieldName(name); var fullName = ViewData.TemplateInfo.GetFullHtmlFieldName(name);
return new HtmlString(Encode(fullName)); return new HtmlString(Encode(fullName));
} }
public async Task<HtmlString> PartialAsync([NotNull] string partialViewName, object model, ViewDataDictionary viewData) public async Task<HtmlString> PartialAsync([NotNull] string partialViewName, object model,
ViewDataDictionary viewData)
{ {
using (var writer = new StringWriter(CultureInfo.CurrentCulture)) using (var writer = new StringWriter(CultureInfo.CurrentCulture))
{ {
@ -157,10 +153,10 @@ namespace Microsoft.AspNet.Mvc.Rendering
return RenderPartialCoreAsync(partialViewName, model, viewData, ViewContext.Writer); return RenderPartialCoreAsync(partialViewName, model, viewData, ViewContext.Writer);
} }
protected virtual async Task RenderPartialCoreAsync([NotNull] string partialViewName, protected virtual async Task RenderPartialCoreAsync([NotNull] string partialViewName,
object model, object model,
ViewDataDictionary viewData, ViewDataDictionary viewData,
TextWriter writer) TextWriter writer)
{ {
// Determine which ViewData we should use to construct a new ViewData // Determine which ViewData we should use to construct a new ViewData
var baseViewData = viewData ?? ViewData; var baseViewData = viewData ?? ViewData;
@ -306,13 +302,11 @@ namespace Microsoft.AspNet.Mvc.Rendering
} }
} }
[SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Justification = "For consistency, all helpers are instance methods.")]
public HtmlString Raw(string value) public HtmlString Raw(string value)
{ {
return new HtmlString(value); return new HtmlString(value);
} }
[SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Justification = "For consistency, all helpers are instance methods.")]
public HtmlString Raw(object value) public HtmlString Raw(object value)
{ {
return new HtmlString(value == null ? null : value.ToString()); return new HtmlString(value == null ? null : value.ToString());

View File

@ -1,5 +1,4 @@
using System; using System;
using System.Diagnostics.CodeAnalysis;
using System.Linq.Expressions; using System.Linq.Expressions;
using Microsoft.AspNet.Mvc.Rendering.Expressions; using Microsoft.AspNet.Mvc.Rendering.Expressions;
@ -40,10 +39,6 @@ namespace Microsoft.AspNet.Mvc.Rendering
} }
/// <inheritdoc /> /// <inheritdoc />
[SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures",
Justification = "This is an appropriate nesting of generic types")]
[SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters",
Justification = "Users cannot use anonymous methods with the LambdaExpression type")]
public HtmlString NameFor<TProperty>([NotNull] Expression<Func<TModel, TProperty>> expression) public HtmlString NameFor<TProperty>([NotNull] Expression<Func<TModel, TProperty>> expression)
{ {
var expressionName = GetExpressionName(expression); var expressionName = GetExpressionName(expression);

View File

@ -10,7 +10,9 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// <typeparam name="T">The <see cref="Type"/> of the model.</typeparam> /// <typeparam name="T">The <see cref="Type"/> of the model.</typeparam>
/// <param name="htmlHelper">The <see cref="HtmlHelper"/> instance that this method extends.</param> /// <param name="htmlHelper">The <see cref="HtmlHelper"/> instance that this method extends.</param>
/// <param name="partialViewName">The name of the partial view to render.</param> /// <param name="partialViewName">The name of the partial view to render.</param>
/// <returns>A <see cref="Task{T}"/> that represents when rendering to the <see cref="HtmlString"/> has completed.</returns> /// <returns>
/// A <see cref="Task{T}"/> that represents when rendering to the <see cref="HtmlString"/> has completed.
/// </returns>
public static Task<HtmlString> PartialAsync<T>(this IHtmlHelper<T> htmlHelper, [NotNull] string partialViewName) public static Task<HtmlString> PartialAsync<T>(this IHtmlHelper<T> htmlHelper, [NotNull] string partialViewName)
{ {
return htmlHelper.PartialAsync(partialViewName, htmlHelper.ViewData.Model, viewData: null); return htmlHelper.PartialAsync(partialViewName, htmlHelper.ViewData.Model, viewData: null);
@ -22,9 +24,14 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// <typeparam name="T">The <see cref="Type"/> of the model.</typeparam> /// <typeparam name="T">The <see cref="Type"/> of the model.</typeparam>
/// <param name="htmlHelper">The <see cref="HtmlHelper"/> instance that this method extends.</param> /// <param name="htmlHelper">The <see cref="HtmlHelper"/> instance that this method extends.</param>
/// <param name="partialViewName">The name of the partial view to render.</param> /// <param name="partialViewName">The name of the partial view to render.</param>
/// <param name="viewData">The <see cref="ViewDataDictionary"/> that is provided to the partial view that will be rendered.</param> /// <param name="viewData">
/// <returns>A <see cref="Task{T}"/> that represents when rendering to the <see cref="HtmlString"/> has completed.</returns> /// The <see cref="ViewDataDictionary"/> that is provided to the partial view that will be rendered.
public static Task<HtmlString> PartialAsync<T>(this IHtmlHelper<T> htmlHelper, [NotNull] string partialViewName, ViewDataDictionary viewData) /// </param>
/// <returns>
/// A <see cref="Task{T}"/> that represents when rendering to the <see cref="HtmlString"/> has completed.
/// </returns>
public static Task<HtmlString> PartialAsync<T>(this IHtmlHelper<T> htmlHelper, [NotNull] string partialViewName,
ViewDataDictionary viewData)
{ {
return htmlHelper.PartialAsync(partialViewName, htmlHelper.ViewData.Model, viewData: viewData); return htmlHelper.PartialAsync(partialViewName, htmlHelper.ViewData.Model, viewData: viewData);
} }
@ -36,8 +43,11 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// <param name="htmlHelper">The <see cref="HtmlHelper"/> instance that this method extends.</param> /// <param name="htmlHelper">The <see cref="HtmlHelper"/> instance that this method extends.</param>
/// <param name="partialViewName">The name of the partial view to render.</param> /// <param name="partialViewName">The name of the partial view to render.</param>
/// <param name="model">The model to provide to the partial view that will be rendered.</param> /// <param name="model">The model to provide to the partial view that will be rendered.</param>
/// <returns>A <see cref="Task{T}"/> that represents when rendering to the <see cref="HtmlString"/> has completed.</returns> /// <returns>
public static Task<HtmlString> PartialAsync<T>(this IHtmlHelper<T> htmlHelper, [NotNull] string partialViewName, object model) /// A <see cref="Task{T}"/> that represents when rendering to the <see cref="HtmlString"/> has completed.
/// </returns>
public static Task<HtmlString> PartialAsync<T>(this IHtmlHelper<T> htmlHelper, [NotNull] string partialViewName,
object model)
{ {
return htmlHelper.PartialAsync(partialViewName, model, viewData: null); return htmlHelper.PartialAsync(partialViewName, model, viewData: null);
} }

View File

@ -14,7 +14,8 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// <returns>A <see cref="Task"/> that represents when rendering has completed.</returns> /// <returns>A <see cref="Task"/> that represents when rendering has completed.</returns>
public static Task RenderPartialAsync<T>(this IHtmlHelper<T> htmlHelper, [NotNull] string partialViewName) public static Task RenderPartialAsync<T>(this IHtmlHelper<T> htmlHelper, [NotNull] string partialViewName)
{ {
return htmlHelper.RenderPartialAsync(partialViewName, htmlHelper.ViewData.Model, viewData: htmlHelper.ViewData); return htmlHelper.RenderPartialAsync(partialViewName, htmlHelper.ViewData.Model,
viewData: htmlHelper.ViewData);
} }
/// <summary> /// <summary>
@ -23,9 +24,12 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// <typeparam name="T">The <see cref="Type"/> of the model.</typeparam> /// <typeparam name="T">The <see cref="Type"/> of the model.</typeparam>
/// <param name="htmlHelper">The <see cref="HtmlHelper"/> instance that this method extends.</param> /// <param name="htmlHelper">The <see cref="HtmlHelper"/> instance that this method extends.</param>
/// <param name="partialViewName">The name of the partial view to render.</param> /// <param name="partialViewName">The name of the partial view to render.</param>
/// <param name="viewData">The <see cref="ViewDataDictionary"/> that is provided to the partial view that will be rendered.</param> /// <param name="viewData">
/// The <see cref="ViewDataDictionary"/> that is provided to the partial view that will be rendered.
/// </param>
/// <returns>A <see cref="Task"/> that represents when rendering has completed.</returns> /// <returns>A <see cref="Task"/> that represents when rendering has completed.</returns>
public static Task RenderPartialAsync<T>(this IHtmlHelper<T> htmlHelper, [NotNull] string partialViewName, ViewDataDictionary viewData) public static Task RenderPartialAsync<T>(this IHtmlHelper<T> htmlHelper, [NotNull] string partialViewName,
ViewDataDictionary viewData)
{ {
return htmlHelper.RenderPartialAsync(partialViewName, htmlHelper.ViewData.Model, viewData: viewData); return htmlHelper.RenderPartialAsync(partialViewName, htmlHelper.ViewData.Model, viewData: viewData);
} }
@ -38,7 +42,8 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// <param name="partialViewName">The name of the partial view to render.</param> /// <param name="partialViewName">The name of the partial view to render.</param>
/// <param name="model">The model to provide to the partial view that will be rendered.</param> /// <param name="model">The model to provide to the partial view that will be rendered.</param>
/// <returns>A <see cref="Task"/> that represents when rendering has completed.</returns> /// <returns>A <see cref="Task"/> that represents when rendering has completed.</returns>
public static Task RenderPartialAsync<T>(this IHtmlHelper<T> htmlHelper, [NotNull] string partialViewName, object model) public static Task RenderPartialAsync<T>(this IHtmlHelper<T> htmlHelper, [NotNull] string partialViewName,
object model)
{ {
return htmlHelper.RenderPartialAsync(partialViewName, model, htmlHelper.ViewData); return htmlHelper.RenderPartialAsync(partialViewName, model, htmlHelper.ViewData);
} }

View File

@ -14,7 +14,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
{ {
if (string.IsNullOrEmpty(tagName)) if (string.IsNullOrEmpty(tagName))
{ {
throw new ArgumentException(Resources.FormatArgumentNullOrEmpty("tagName")); throw new ArgumentException(Resources.ArgumentNullOrEmpty, "tagName");
} }
TagName = tagName; TagName = tagName;
@ -113,7 +113,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
{ {
if (string.IsNullOrEmpty(key)) if (string.IsNullOrEmpty(key))
{ {
throw new ArgumentException(Resources.FormatArgumentNullOrEmpty("key")); throw new ArgumentException(Resources.ArgumentNullOrEmpty, "key");
} }
if (replaceExisting || !Attributes.ContainsKey(key)) if (replaceExisting || !Attributes.ContainsKey(key))

View File

@ -1,9 +1,7 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information. using System.Reflection;
using System.Reflection;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information // set of attributes. Change these attribute values to modify the information
// associated with an assembly. // associated with an assembly.
[assembly: AssemblyTitle("Microsoft.AspNet.Mvc.Rendering")] [assembly: AssemblyTitle("Microsoft.AspNet.Mvc.Rendering")]
@ -15,8 +13,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible // Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from // to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type. // COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)] [assembly: ComVisible(false)]
@ -26,11 +24,11 @@ using System.Runtime.InteropServices;
// Version information for an assembly consists of the following four values: // Version information for an assembly consists of the following four values:
// //
// Major Version // Major Version
// Minor Version // Minor Version
// Build Number // Build Number
// Revision // Revision
// //
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyVersion("1.0.0.0")]

View File

@ -11,7 +11,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
= new ResourceManager("Microsoft.AspNet.Mvc.Rendering.Resources", typeof(Resources).GetTypeInfo().Assembly); = new ResourceManager("Microsoft.AspNet.Mvc.Rendering.Resources", typeof(Resources).GetTypeInfo().Assembly);
/// <summary> /// <summary>
/// The argument '{0}' is null or empty. /// The argument must not be null or empty.
/// </summary> /// </summary>
internal static string ArgumentNullOrEmpty internal static string ArgumentNullOrEmpty
{ {
@ -19,11 +19,11 @@ namespace Microsoft.AspNet.Mvc.Rendering
} }
/// <summary> /// <summary>
/// The argument '{0}' is null or empty. /// The argument must not be null or empty.
/// </summary> /// </summary>
internal static string FormatArgumentNullOrEmpty(object p0) internal static string FormatArgumentNullOrEmpty()
{ {
return string.Format(CultureInfo.CurrentCulture, GetString("ArgumentNullOrEmpty"), p0); return GetString("ArgumentNullOrEmpty");
} }
/// <summary> /// <summary>

View File

@ -118,7 +118,7 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<data name="ArgumentNullOrEmpty" xml:space="preserve"> <data name="ArgumentNullOrEmpty" xml:space="preserve">
<value>The argument '{0}' is null or empty.</value> <value>The argument must not be null or empty.</value>
</data> </data>
<data name="ArgumentPropertyNull" xml:space="preserve"> <data name="ArgumentPropertyNull" xml:space="preserve">
<value>Property '{0}' must not be null.</value> <value>Property '{0}' must not be null.</value>

View File

@ -17,7 +17,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
{ {
get get
{ {
ViewDataDictionary viewData = _viewDataFunc(); var viewData = _viewDataFunc();
if (viewData == null) if (viewData == null)
{ {
throw new InvalidOperationException(Resources.DynamicViewData_ViewDataNull); throw new InvalidOperationException(Resources.DynamicViewData_ViewDataNull);

View File

@ -1,5 +1,4 @@
using System.IO; using System.Threading.Tasks;
using System.Threading.Tasks;
namespace Microsoft.AspNet.Mvc.Rendering namespace Microsoft.AspNet.Mvc.Rendering
{ {

View File

@ -14,7 +14,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
{ {
_defaultModelMetadata = MetadataProvider.GetMetadataForType(null, typeof(TModel)); _defaultModelMetadata = MetadataProvider.GetMetadataForType(null, typeof(TModel));
} }
public ViewDataDictionary([NotNull] IModelMetadataProvider metadataProvider, public ViewDataDictionary([NotNull] IModelMetadataProvider metadataProvider,
[NotNull] ModelStateDictionary modelState) [NotNull] ModelStateDictionary modelState)
: base(metadataProvider, modelState) : base(metadataProvider, modelState)
@ -60,7 +60,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
{ {
// IsCompatibleObject verifies if the value is either an instance of TModel or (if value is null) that // IsCompatibleObject verifies if the value is either an instance of TModel or (if value is null) that
// TModel is a nullable type. // TModel is a nullable type.
bool castWillSucceed = typeof(TModel).IsCompatibleWith(value); var castWillSucceed = typeof(TModel).IsCompatibleWith(value);
if (castWillSucceed) if (castWillSucceed)
{ {

View File

@ -1,5 +1,4 @@
using System; using System.Collections.Generic;
using System.Collections.Generic;
namespace Microsoft.AspNet.Mvc.Rendering namespace Microsoft.AspNet.Mvc.Rendering
{ {
@ -15,9 +14,9 @@ namespace Microsoft.AspNet.Mvc.Rendering
public string ViewName { get; private set; } public string ViewName { get; private set; }
public bool Success public bool Success
{ {
get { return View != null; } get { return View != null; }
} }
public static ViewEngineResult NotFound([NotNull] string viewName, public static ViewEngineResult NotFound([NotNull] string viewName,

View File

@ -7,7 +7,8 @@ namespace Microsoft.AspNet.Mvc
{ {
public class ViewComponentContext public class ViewComponentContext
{ {
public ViewComponentContext([NotNull] TypeInfo componentType, [NotNull] ViewContext viewContext, [NotNull] TextWriter writer) public ViewComponentContext([NotNull] TypeInfo componentType, [NotNull] ViewContext viewContext,
[NotNull] TextWriter writer)
{ {
ComponentType = componentType; ComponentType = componentType;
ViewContext = viewContext; ViewContext = viewContext;

View File

@ -5,22 +5,26 @@ namespace Microsoft.AspNet.Mvc.Rendering
{ {
public static class ViewComponentHelperExtensions public static class ViewComponentHelperExtensions
{ {
public static HtmlString Invoke<TComponent>([NotNull] this IViewComponentHelper helper, params object[] args) public static HtmlString Invoke<TComponent>([NotNull] this IViewComponentHelper helper,
params object[] args)
{ {
return helper.Invoke(typeof(TComponent), args); return helper.Invoke(typeof(TComponent), args);
} }
public static void RenderInvoke<TComponent>([NotNull] this IViewComponentHelper helper, params object[] args) public static void RenderInvoke<TComponent>([NotNull] this IViewComponentHelper helper,
params object[] args)
{ {
helper.RenderInvoke(typeof(TComponent), args); helper.RenderInvoke(typeof(TComponent), args);
} }
public static async Task<HtmlString> InvokeAsync<TComponent>([NotNull] this IViewComponentHelper helper, params object[] args) public static async Task<HtmlString> InvokeAsync<TComponent>([NotNull] this IViewComponentHelper helper,
params object[] args)
{ {
return await helper.InvokeAsync(typeof(TComponent), args); return await helper.InvokeAsync(typeof(TComponent), args);
} }
public static async Task RenderInvokeAsync<TComponent>([NotNull] this IViewComponentHelper helper, params object[] args) public static async Task RenderInvokeAsync<TComponent>([NotNull] this IViewComponentHelper helper,
params object[] args)
{ {
await helper.RenderInvokeAsync(typeof(TComponent), args); await helper.RenderInvokeAsync(typeof(TComponent), args);
} }