diff --git a/src/Common/TypeExtensions.cs b/src/Common/TypeExtensions.cs index 63ae485b39..10b2777d9d 100644 --- a/src/Common/TypeExtensions.cs +++ b/src/Common/TypeExtensions.cs @@ -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.Reflection; @@ -94,7 +92,7 @@ namespace Microsoft.AspNet.Mvc public static bool HasStringConverter([NotNull] this Type type) { - TypeInfo typeInfo = type.GetTypeInfo(); + var typeInfo = type.GetTypeInfo(); if (typeInfo.IsPrimitive || type == typeof(string)) { return true; @@ -110,13 +108,13 @@ namespace Microsoft.AspNet.Mvc public static Type[] GetTypeArgumentsIfMatch([NotNull] Type closedType, Type matchingOpenType) { - TypeInfo closedTypeInfo = closedType.GetTypeInfo(); + var closedTypeInfo = closedType.GetTypeInfo(); if (!closedTypeInfo.IsGenericType) { return null; } - Type openType = closedType.GetGenericTypeDefinition(); + var openType = closedType.GetGenericTypeDefinition(); return (matchingOpenType == openType) ? closedTypeInfo.GenericTypeArguments : null; } } diff --git a/src/Microsoft.AspNet.Mvc.Rendering/Expressions/ExpressionHelper.cs b/src/Microsoft.AspNet.Mvc.Rendering/Expressions/ExpressionHelper.cs index 87ea03af27..f2e6bc222d 100644 --- a/src/Microsoft.AspNet.Mvc.Rendering/Expressions/ExpressionHelper.cs +++ b/src/Microsoft.AspNet.Mvc.Rendering/Expressions/ExpressionHelper.cs @@ -103,7 +103,7 @@ namespace Microsoft.AspNet.Mvc.Rendering.Expressions { throw new InvalidOperationException( Resources.FormatExpressionHelper_InvalidIndexerExpression(expression, parameters[0].Name), - ex); + ex); } return "[" + Convert.ToString(func(null), CultureInfo.InvariantCulture) + "]"; diff --git a/src/Microsoft.AspNet.Mvc.Rendering/Html/HtmlHelper.cs b/src/Microsoft.AspNet.Mvc.Rendering/Html/HtmlHelper.cs index 5101aace55..fbecf88cde 100644 --- a/src/Microsoft.AspNet.Mvc.Rendering/Html/HtmlHelper.cs +++ b/src/Microsoft.AspNet.Mvc.Rendering/Html/HtmlHelper.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.IO; using System.Net; @@ -77,7 +76,7 @@ namespace Microsoft.AspNet.Mvc.Rendering } /// - /// Creates a dictionary of HTML attributes from the input object, + /// Creates a dictionary of HTML attributes from the input object, /// translating underscores to dashes. /// /// new { data_name="value" } will translate to the entry { "data-name" , "value" } @@ -86,10 +85,10 @@ namespace Microsoft.AspNet.Mvc.Rendering /// /// Anonymous object describing HTML attributes. /// A dictionary that represents HTML attributes. - public static Dictionary AnonymousObjectToHtmlAttributes(object htmlAttributes) + public static IDictionary AnonymousObjectToHtmlAttributes(object htmlAttributes) { Dictionary result; - IDictionary valuesAsDictionary = htmlAttributes as IDictionary; + var valuesAsDictionary = htmlAttributes as IDictionary; if (valuesAsDictionary != null) { result = new Dictionary(valuesAsDictionary, StringComparer.OrdinalIgnoreCase); @@ -102,8 +101,8 @@ namespace Microsoft.AspNet.Mvc.Rendering { foreach (var prop in htmlAttributes.GetType().GetRuntimeProperties()) { - object val = prop.GetValue(htmlAttributes); - result.Add(prop.Name, val); + var value = prop.GetValue(htmlAttributes); + result.Add(prop.Name, value); } } } @@ -116,13 +115,11 @@ namespace Microsoft.AspNet.Mvc.Rendering ViewContext = viewContext; } - [SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Justification = "For consistency, all helpers are instance methods.")] public string Encode(string value) { 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) { return value != null ? WebUtility.HtmlEncode(value.ToString()) : string.Empty; @@ -134,15 +131,14 @@ namespace Microsoft.AspNet.Mvc.Rendering } /// - [SuppressMessage("Microsoft.Naming", "CA1719:ParameterNamesShouldNotMatchMemberNames", - MessageId = "1#", Justification = "This is a shipped API.")] public virtual HtmlString Name(string name) { var fullName = ViewData.TemplateInfo.GetFullHtmlFieldName(name); return new HtmlString(Encode(fullName)); } - public async Task PartialAsync([NotNull] string partialViewName, object model, ViewDataDictionary viewData) + public async Task PartialAsync([NotNull] string partialViewName, object model, + ViewDataDictionary viewData) { using (var writer = new StringWriter(CultureInfo.CurrentCulture)) { @@ -157,10 +153,10 @@ namespace Microsoft.AspNet.Mvc.Rendering return RenderPartialCoreAsync(partialViewName, model, viewData, ViewContext.Writer); } - protected virtual async Task RenderPartialCoreAsync([NotNull] string partialViewName, - object model, - ViewDataDictionary viewData, - TextWriter writer) + protected virtual async Task RenderPartialCoreAsync([NotNull] string partialViewName, + object model, + ViewDataDictionary viewData, + TextWriter writer) { // Determine which ViewData we should use to construct a new 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) { return new HtmlString(value); } - [SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Justification = "For consistency, all helpers are instance methods.")] public HtmlString Raw(object value) { return new HtmlString(value == null ? null : value.ToString()); diff --git a/src/Microsoft.AspNet.Mvc.Rendering/Html/HtmlHelperOfT.cs b/src/Microsoft.AspNet.Mvc.Rendering/Html/HtmlHelperOfT.cs index b2124fa2cc..f87f91a438 100644 --- a/src/Microsoft.AspNet.Mvc.Rendering/Html/HtmlHelperOfT.cs +++ b/src/Microsoft.AspNet.Mvc.Rendering/Html/HtmlHelperOfT.cs @@ -1,5 +1,4 @@ using System; -using System.Diagnostics.CodeAnalysis; using System.Linq.Expressions; using Microsoft.AspNet.Mvc.Rendering.Expressions; @@ -40,10 +39,6 @@ namespace Microsoft.AspNet.Mvc.Rendering } /// - [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([NotNull] Expression> expression) { var expressionName = GetExpressionName(expression); diff --git a/src/Microsoft.AspNet.Mvc.Rendering/Html/Partials/PartialAsyncExtensions.cs b/src/Microsoft.AspNet.Mvc.Rendering/Html/Partials/PartialAsyncExtensions.cs index 05b7bf9797..2183ef6ff0 100644 --- a/src/Microsoft.AspNet.Mvc.Rendering/Html/Partials/PartialAsyncExtensions.cs +++ b/src/Microsoft.AspNet.Mvc.Rendering/Html/Partials/PartialAsyncExtensions.cs @@ -10,7 +10,9 @@ namespace Microsoft.AspNet.Mvc.Rendering /// The of the model. /// The instance that this method extends. /// The name of the partial view to render. - /// A that represents when rendering to the has completed. + /// + /// A that represents when rendering to the has completed. + /// public static Task PartialAsync(this IHtmlHelper htmlHelper, [NotNull] string partialViewName) { return htmlHelper.PartialAsync(partialViewName, htmlHelper.ViewData.Model, viewData: null); @@ -22,9 +24,14 @@ namespace Microsoft.AspNet.Mvc.Rendering /// The of the model. /// The instance that this method extends. /// The name of the partial view to render. - /// The that is provided to the partial view that will be rendered. - /// A that represents when rendering to the has completed. - public static Task PartialAsync(this IHtmlHelper htmlHelper, [NotNull] string partialViewName, ViewDataDictionary viewData) + /// + /// The that is provided to the partial view that will be rendered. + /// + /// + /// A that represents when rendering to the has completed. + /// + public static Task PartialAsync(this IHtmlHelper htmlHelper, [NotNull] string partialViewName, + ViewDataDictionary viewData) { return htmlHelper.PartialAsync(partialViewName, htmlHelper.ViewData.Model, viewData: viewData); } @@ -36,8 +43,11 @@ namespace Microsoft.AspNet.Mvc.Rendering /// The instance that this method extends. /// The name of the partial view to render. /// The model to provide to the partial view that will be rendered. - /// A that represents when rendering to the has completed. - public static Task PartialAsync(this IHtmlHelper htmlHelper, [NotNull] string partialViewName, object model) + /// + /// A that represents when rendering to the has completed. + /// + public static Task PartialAsync(this IHtmlHelper htmlHelper, [NotNull] string partialViewName, + object model) { return htmlHelper.PartialAsync(partialViewName, model, viewData: null); } diff --git a/src/Microsoft.AspNet.Mvc.Rendering/Html/Partials/RenderPartialAsyncExtensions.cs b/src/Microsoft.AspNet.Mvc.Rendering/Html/Partials/RenderPartialAsyncExtensions.cs index 77a44f5619..3b1d31535c 100644 --- a/src/Microsoft.AspNet.Mvc.Rendering/Html/Partials/RenderPartialAsyncExtensions.cs +++ b/src/Microsoft.AspNet.Mvc.Rendering/Html/Partials/RenderPartialAsyncExtensions.cs @@ -14,7 +14,8 @@ namespace Microsoft.AspNet.Mvc.Rendering /// A that represents when rendering has completed. public static Task RenderPartialAsync(this IHtmlHelper htmlHelper, [NotNull] string partialViewName) { - return htmlHelper.RenderPartialAsync(partialViewName, htmlHelper.ViewData.Model, viewData: htmlHelper.ViewData); + return htmlHelper.RenderPartialAsync(partialViewName, htmlHelper.ViewData.Model, + viewData: htmlHelper.ViewData); } /// @@ -23,9 +24,12 @@ namespace Microsoft.AspNet.Mvc.Rendering /// The of the model. /// The instance that this method extends. /// The name of the partial view to render. - /// The that is provided to the partial view that will be rendered. + /// + /// The that is provided to the partial view that will be rendered. + /// /// A that represents when rendering has completed. - public static Task RenderPartialAsync(this IHtmlHelper htmlHelper, [NotNull] string partialViewName, ViewDataDictionary viewData) + public static Task RenderPartialAsync(this IHtmlHelper htmlHelper, [NotNull] string partialViewName, + ViewDataDictionary viewData) { return htmlHelper.RenderPartialAsync(partialViewName, htmlHelper.ViewData.Model, viewData: viewData); } @@ -38,7 +42,8 @@ namespace Microsoft.AspNet.Mvc.Rendering /// The name of the partial view to render. /// The model to provide to the partial view that will be rendered. /// A that represents when rendering has completed. - public static Task RenderPartialAsync(this IHtmlHelper htmlHelper, [NotNull] string partialViewName, object model) + public static Task RenderPartialAsync(this IHtmlHelper htmlHelper, [NotNull] string partialViewName, + object model) { return htmlHelper.RenderPartialAsync(partialViewName, model, htmlHelper.ViewData); } diff --git a/src/Microsoft.AspNet.Mvc.Rendering/Html/TagBuilder.cs b/src/Microsoft.AspNet.Mvc.Rendering/Html/TagBuilder.cs index cb68026678..1b0c8a7ba4 100644 --- a/src/Microsoft.AspNet.Mvc.Rendering/Html/TagBuilder.cs +++ b/src/Microsoft.AspNet.Mvc.Rendering/Html/TagBuilder.cs @@ -14,7 +14,7 @@ namespace Microsoft.AspNet.Mvc.Rendering { if (string.IsNullOrEmpty(tagName)) { - throw new ArgumentException(Resources.FormatArgumentNullOrEmpty("tagName")); + throw new ArgumentException(Resources.ArgumentNullOrEmpty, "tagName"); } TagName = tagName; @@ -113,7 +113,7 @@ namespace Microsoft.AspNet.Mvc.Rendering { if (string.IsNullOrEmpty(key)) { - throw new ArgumentException(Resources.FormatArgumentNullOrEmpty("key")); + throw new ArgumentException(Resources.ArgumentNullOrEmpty, "key"); } if (replaceExisting || !Attributes.ContainsKey(key)) diff --git a/src/Microsoft.AspNet.Mvc.Rendering/Properties/AssemblyInfo.cs b/src/Microsoft.AspNet.Mvc.Rendering/Properties/AssemblyInfo.cs index cbc0e4b45d..f3ed52df40 100644 --- a/src/Microsoft.AspNet.Mvc.Rendering/Properties/AssemblyInfo.cs +++ b/src/Microsoft.AspNet.Mvc.Rendering/Properties/AssemblyInfo.cs @@ -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; -// 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 // associated with an assembly. [assembly: AssemblyTitle("Microsoft.AspNet.Mvc.Rendering")] @@ -15,8 +13,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -// 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 +// 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 // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] @@ -26,11 +24,11 @@ using System.Runtime.InteropServices; // Version information for an assembly consists of the following four values: // // Major Version -// Minor Version +// Minor Version // Build Number // 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: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] diff --git a/src/Microsoft.AspNet.Mvc.Rendering/Properties/Resources.Designer.cs b/src/Microsoft.AspNet.Mvc.Rendering/Properties/Resources.Designer.cs index a35bea7e88..53c98e6693 100644 --- a/src/Microsoft.AspNet.Mvc.Rendering/Properties/Resources.Designer.cs +++ b/src/Microsoft.AspNet.Mvc.Rendering/Properties/Resources.Designer.cs @@ -11,7 +11,7 @@ namespace Microsoft.AspNet.Mvc.Rendering = new ResourceManager("Microsoft.AspNet.Mvc.Rendering.Resources", typeof(Resources).GetTypeInfo().Assembly); /// - /// The argument '{0}' is null or empty. + /// The argument must not be null or empty. /// internal static string ArgumentNullOrEmpty { @@ -19,11 +19,11 @@ namespace Microsoft.AspNet.Mvc.Rendering } /// - /// The argument '{0}' is null or empty. + /// The argument must not be null or empty. /// - internal static string FormatArgumentNullOrEmpty(object p0) + internal static string FormatArgumentNullOrEmpty() { - return string.Format(CultureInfo.CurrentCulture, GetString("ArgumentNullOrEmpty"), p0); + return GetString("ArgumentNullOrEmpty"); } /// diff --git a/src/Microsoft.AspNet.Mvc.Rendering/Properties/Resources.resx b/src/Microsoft.AspNet.Mvc.Rendering/Properties/Resources.resx index bb733023d8..9753e01b0b 100644 --- a/src/Microsoft.AspNet.Mvc.Rendering/Properties/Resources.resx +++ b/src/Microsoft.AspNet.Mvc.Rendering/Properties/Resources.resx @@ -118,7 +118,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - The argument '{0}' is null or empty. + The argument must not be null or empty. Property '{0}' must not be null. diff --git a/src/Microsoft.AspNet.Mvc.Rendering/View/DynamicViewData.cs b/src/Microsoft.AspNet.Mvc.Rendering/View/DynamicViewData.cs index 11f97253ca..eee55e99c0 100644 --- a/src/Microsoft.AspNet.Mvc.Rendering/View/DynamicViewData.cs +++ b/src/Microsoft.AspNet.Mvc.Rendering/View/DynamicViewData.cs @@ -17,7 +17,7 @@ namespace Microsoft.AspNet.Mvc.Rendering { get { - ViewDataDictionary viewData = _viewDataFunc(); + var viewData = _viewDataFunc(); if (viewData == null) { throw new InvalidOperationException(Resources.DynamicViewData_ViewDataNull); diff --git a/src/Microsoft.AspNet.Mvc.Rendering/View/IView.cs b/src/Microsoft.AspNet.Mvc.Rendering/View/IView.cs index 57c6b079d7..7c45b8a3b4 100644 --- a/src/Microsoft.AspNet.Mvc.Rendering/View/IView.cs +++ b/src/Microsoft.AspNet.Mvc.Rendering/View/IView.cs @@ -1,5 +1,4 @@ -using System.IO; -using System.Threading.Tasks; +using System.Threading.Tasks; namespace Microsoft.AspNet.Mvc.Rendering { diff --git a/src/Microsoft.AspNet.Mvc.Rendering/View/ViewDataDictionaryOfT.cs b/src/Microsoft.AspNet.Mvc.Rendering/View/ViewDataDictionaryOfT.cs index 46abcb56ee..fd2ac46f85 100644 --- a/src/Microsoft.AspNet.Mvc.Rendering/View/ViewDataDictionaryOfT.cs +++ b/src/Microsoft.AspNet.Mvc.Rendering/View/ViewDataDictionaryOfT.cs @@ -14,7 +14,7 @@ namespace Microsoft.AspNet.Mvc.Rendering { _defaultModelMetadata = MetadataProvider.GetMetadataForType(null, typeof(TModel)); } - + public ViewDataDictionary([NotNull] IModelMetadataProvider metadataProvider, [NotNull] ModelStateDictionary 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 // TModel is a nullable type. - bool castWillSucceed = typeof(TModel).IsCompatibleWith(value); + var castWillSucceed = typeof(TModel).IsCompatibleWith(value); if (castWillSucceed) { diff --git a/src/Microsoft.AspNet.Mvc.Rendering/View/ViewEngineResult.cs b/src/Microsoft.AspNet.Mvc.Rendering/View/ViewEngineResult.cs index a8316bd513..434e2721d2 100644 --- a/src/Microsoft.AspNet.Mvc.Rendering/View/ViewEngineResult.cs +++ b/src/Microsoft.AspNet.Mvc.Rendering/View/ViewEngineResult.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; namespace Microsoft.AspNet.Mvc.Rendering { @@ -15,9 +14,9 @@ namespace Microsoft.AspNet.Mvc.Rendering public string ViewName { get; private set; } - public bool Success - { - get { return View != null; } + public bool Success + { + get { return View != null; } } public static ViewEngineResult NotFound([NotNull] string viewName, diff --git a/src/Microsoft.AspNet.Mvc.Rendering/ViewComponentContext.cs b/src/Microsoft.AspNet.Mvc.Rendering/ViewComponentContext.cs index 5fcaa1cd67..6281ff94ee 100644 --- a/src/Microsoft.AspNet.Mvc.Rendering/ViewComponentContext.cs +++ b/src/Microsoft.AspNet.Mvc.Rendering/ViewComponentContext.cs @@ -7,7 +7,8 @@ namespace Microsoft.AspNet.Mvc { 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; ViewContext = viewContext; diff --git a/src/Microsoft.AspNet.Mvc.Rendering/ViewComponentHelperExtensions.cs b/src/Microsoft.AspNet.Mvc.Rendering/ViewComponentHelperExtensions.cs index a65ce85cf0..9e93e3c98a 100644 --- a/src/Microsoft.AspNet.Mvc.Rendering/ViewComponentHelperExtensions.cs +++ b/src/Microsoft.AspNet.Mvc.Rendering/ViewComponentHelperExtensions.cs @@ -5,22 +5,26 @@ namespace Microsoft.AspNet.Mvc.Rendering { public static class ViewComponentHelperExtensions { - public static HtmlString Invoke([NotNull] this IViewComponentHelper helper, params object[] args) + public static HtmlString Invoke([NotNull] this IViewComponentHelper helper, + params object[] args) { return helper.Invoke(typeof(TComponent), args); } - public static void RenderInvoke([NotNull] this IViewComponentHelper helper, params object[] args) + public static void RenderInvoke([NotNull] this IViewComponentHelper helper, + params object[] args) { helper.RenderInvoke(typeof(TComponent), args); } - public static async Task InvokeAsync([NotNull] this IViewComponentHelper helper, params object[] args) + public static async Task InvokeAsync([NotNull] this IViewComponentHelper helper, + params object[] args) { return await helper.InvokeAsync(typeof(TComponent), args); } - public static async Task RenderInvokeAsync([NotNull] this IViewComponentHelper helper, params object[] args) + public static async Task RenderInvokeAsync([NotNull] this IViewComponentHelper helper, + params object[] args) { await helper.RenderInvokeAsync(typeof(TComponent), args); }