From 1f6bbf996759c0da0a8efced30e7e341f4e9c0fd Mon Sep 17 00:00:00 2001 From: Doug Bunting Date: Thu, 9 Jun 2016 15:02:24 -0700 Subject: [PATCH] Add doc comments for `public` attributes - #4641 --- .../ActionNameAttribute.cs | 10 ++++++++++ src/Microsoft.AspNetCore.Mvc.Core/AreaAttribute.cs | 7 +++++++ .../FromServicesAttribute.cs | 4 ++-- .../ModelBinding/BindNeverAttribute.cs | 6 ++++++ .../ModelBinding/BindRequiredAttribute.cs | 6 ++++++ .../ModelBinding/BindingBehavior.cs | 14 ++++++++++++++ .../ModelBinding/BindingBehaviorAttribute.cs | 10 ++++++++++ .../NonActionAttribute.cs | 3 +++ .../Routing/RouteValueAttribute.cs | 8 ++++++-- .../ViewComponentAttribute.cs | 6 ++++++ .../Conventions/IUseWebApiActionConventions.cs | 3 +++ .../Conventions/IUseWebApiOverloading.cs | 4 ++++ .../Conventions/IUseWebApiParameterConventions.cs | 4 ++++ .../Conventions/IUseWebApiRoutes.cs | 3 +++ .../UseWebApiActionConventionsAttribute.cs | 3 +++ .../Conventions/UseWebApiOverloadingAttribute.cs | 4 ++++ .../UseWebApiParameterConventionsAttribute.cs | 4 ++++ .../Conventions/UseWebApiRoutesAttribute.cs | 3 +++ .../OverloadActionConstraint.cs | 6 ++++++ .../ParameterBinding/FromUriAttribute.cs | 3 ++- .../ParameterBinding/IOptionalBinderMetadata.cs | 11 +++++++++-- 21 files changed, 115 insertions(+), 7 deletions(-) diff --git a/src/Microsoft.AspNetCore.Mvc.Core/ActionNameAttribute.cs b/src/Microsoft.AspNetCore.Mvc.Core/ActionNameAttribute.cs index 411bbe2e9b..5d8dfa9a76 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/ActionNameAttribute.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/ActionNameAttribute.cs @@ -5,14 +5,24 @@ using System; namespace Microsoft.AspNetCore.Mvc { + /// + /// Specifies the name of an action. + /// [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)] public sealed class ActionNameAttribute : Attribute { + /// + /// Initializes a new instance. + /// + /// The name of the action. public ActionNameAttribute(string name) { Name = name; } + /// + /// Gets the name of the action. + /// public string Name { get; private set; } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Mvc.Core/AreaAttribute.cs b/src/Microsoft.AspNetCore.Mvc.Core/AreaAttribute.cs index 09f860a740..8c1cfe42b2 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/AreaAttribute.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/AreaAttribute.cs @@ -6,9 +6,16 @@ using Microsoft.AspNetCore.Mvc.Routing; namespace Microsoft.AspNetCore.Mvc { + /// + /// Specifies the area containing a controller or action. + /// [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)] public class AreaAttribute : RouteValueAttribute { + /// + /// Initializes a new instance. + /// + /// The area containing the controller or action. public AreaAttribute(string areaName) : base("area", areaName) { diff --git a/src/Microsoft.AspNetCore.Mvc.Core/FromServicesAttribute.cs b/src/Microsoft.AspNetCore.Mvc.Core/FromServicesAttribute.cs index bd2af4a09f..271ae181f2 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/FromServicesAttribute.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/FromServicesAttribute.cs @@ -12,7 +12,7 @@ namespace Microsoft.AspNetCore.Mvc /// /// In this example an implementation of IProductModelRequestService is registered as a service. /// Then in the GetProduct action, the parameter is bound to an instance of IProductModelRequestService - /// which is resolved from the the request services. + /// which is resolved from the request services. /// /// /// [HttpGet] @@ -21,7 +21,7 @@ namespace Microsoft.AspNetCore.Mvc /// return productModelReqest.Value; /// } /// - /// + /// [AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = true)] public class FromServicesAttribute : Attribute, IBindingSourceMetadata { diff --git a/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/BindNeverAttribute.cs b/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/BindNeverAttribute.cs index e054af4295..4d496dc26c 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/BindNeverAttribute.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/BindNeverAttribute.cs @@ -5,9 +5,15 @@ using System; namespace Microsoft.AspNetCore.Mvc.ModelBinding { + /// + /// Indicates that the property should be excluded from model binding. + /// [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property, AllowMultiple = false, Inherited = true)] public sealed class BindNeverAttribute : BindingBehaviorAttribute { + /// + /// Initializes a new instance. + /// public BindNeverAttribute() : base(BindingBehavior.Never) { diff --git a/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/BindRequiredAttribute.cs b/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/BindRequiredAttribute.cs index 3bb5255ae1..f374bb5bc1 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/BindRequiredAttribute.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/BindRequiredAttribute.cs @@ -5,9 +5,15 @@ using System; namespace Microsoft.AspNetCore.Mvc.ModelBinding { + /// + /// Indicates that the property is required for model binding. + /// [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property, AllowMultiple = false, Inherited = true)] public sealed class BindRequiredAttribute : BindingBehaviorAttribute { + /// + /// Initializes a new instance. + /// public BindRequiredAttribute() : base(BindingBehavior.Required) { diff --git a/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/BindingBehavior.cs b/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/BindingBehavior.cs index f97632bed4..1a9bde1fb8 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/BindingBehavior.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/BindingBehavior.cs @@ -3,10 +3,24 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding { + /// + /// Enumerates behavior options of the model binding system. + /// public enum BindingBehavior { + /// + /// The property should be model bound if a value is available from the value provider. + /// Optional = 0, + + /// + /// The property should be excluded from model binding. + /// Never, + + /// + /// The property is required for model binding. + /// Required } } diff --git a/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/BindingBehaviorAttribute.cs b/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/BindingBehaviorAttribute.cs index 3bfeef6884..302d9fe8c8 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/BindingBehaviorAttribute.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/BindingBehaviorAttribute.cs @@ -5,14 +5,24 @@ using System; namespace Microsoft.AspNetCore.Mvc.ModelBinding { + /// + /// Specifies the that should be applied. + /// [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property, AllowMultiple = false, Inherited = true)] public class BindingBehaviorAttribute : Attribute { + /// + /// Initializes a new instance. + /// + /// The to apply. public BindingBehaviorAttribute(BindingBehavior behavior) { Behavior = behavior; } + /// + /// Gets the to apply. + /// public BindingBehavior Behavior { get; private set; } } } diff --git a/src/Microsoft.AspNetCore.Mvc.Core/NonActionAttribute.cs b/src/Microsoft.AspNetCore.Mvc.Core/NonActionAttribute.cs index 8df8a93844..aa2cec5f5b 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/NonActionAttribute.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/NonActionAttribute.cs @@ -5,6 +5,9 @@ using System; namespace Microsoft.AspNetCore.Mvc { + /// + /// Indicates that a controller method is not an action method. + /// [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)] public sealed class NonActionAttribute : Attribute { diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Routing/RouteValueAttribute.cs b/src/Microsoft.AspNetCore.Mvc.Core/Routing/RouteValueAttribute.cs index 5131b3fbf4..8edbdbc5ec 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/Routing/RouteValueAttribute.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/Routing/RouteValueAttribute.cs @@ -6,14 +6,18 @@ using System; namespace Microsoft.AspNetCore.Mvc.Routing { /// + /// /// An attribute which specifies a required route value for an action or controller. - /// + /// + /// /// When placed on an action, the route data of a request must match the expectations of the route /// constraint in order for the action to be selected. See for /// the expectations that must be satisfied by the route data. - /// + /// + /// /// When placed on a controller, unless overridden by the action, the constraint applies to all /// actions defined by the controller. + /// /// [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)] public abstract class RouteValueAttribute : Attribute, IRouteValueProvider diff --git a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewComponentAttribute.cs b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewComponentAttribute.cs index 6d4369f3f1..4711975c88 100644 --- a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewComponentAttribute.cs +++ b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewComponentAttribute.cs @@ -5,9 +5,15 @@ using System; namespace Microsoft.AspNetCore.Mvc { + /// + /// Indicates the class is a view component and optionally specifies the component's name. + /// [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)] public class ViewComponentAttribute : Attribute { + /// + /// Gets or sets the name of the view component. + /// public string Name { get; set; } } } diff --git a/src/Microsoft.AspNetCore.Mvc.WebApiCompatShim/Conventions/IUseWebApiActionConventions.cs b/src/Microsoft.AspNetCore.Mvc.WebApiCompatShim/Conventions/IUseWebApiActionConventions.cs index 2ea02d9d91..ab24396dd1 100644 --- a/src/Microsoft.AspNetCore.Mvc.WebApiCompatShim/Conventions/IUseWebApiActionConventions.cs +++ b/src/Microsoft.AspNetCore.Mvc.WebApiCompatShim/Conventions/IUseWebApiActionConventions.cs @@ -3,6 +3,9 @@ namespace Microsoft.AspNetCore.Mvc.WebApiCompatShim { + /// + /// Indicates actions without attribute routes in a controller use WebAPI routing conventions. + /// public interface IUseWebApiActionConventions { } diff --git a/src/Microsoft.AspNetCore.Mvc.WebApiCompatShim/Conventions/IUseWebApiOverloading.cs b/src/Microsoft.AspNetCore.Mvc.WebApiCompatShim/Conventions/IUseWebApiOverloading.cs index d3006079cd..cb92ea4661 100644 --- a/src/Microsoft.AspNetCore.Mvc.WebApiCompatShim/Conventions/IUseWebApiOverloading.cs +++ b/src/Microsoft.AspNetCore.Mvc.WebApiCompatShim/Conventions/IUseWebApiOverloading.cs @@ -3,6 +3,10 @@ namespace Microsoft.AspNetCore.Mvc.WebApiCompatShim { + /// + /// Indicates actions in a controller should be selected only if all non-optional parameters are satisfied. Applies + /// the to all actions in the controller. + /// public interface IUseWebApiOverloading { } diff --git a/src/Microsoft.AspNetCore.Mvc.WebApiCompatShim/Conventions/IUseWebApiParameterConventions.cs b/src/Microsoft.AspNetCore.Mvc.WebApiCompatShim/Conventions/IUseWebApiParameterConventions.cs index 8aa7be39a1..58e483dea6 100644 --- a/src/Microsoft.AspNetCore.Mvc.WebApiCompatShim/Conventions/IUseWebApiParameterConventions.cs +++ b/src/Microsoft.AspNetCore.Mvc.WebApiCompatShim/Conventions/IUseWebApiParameterConventions.cs @@ -3,6 +3,10 @@ namespace Microsoft.AspNetCore.Mvc.WebApiCompatShim { + /// + /// Indicates the model binding system should use WebAPI conventions for parameters of a controller's actions. For + /// example, bind simple types from the URI. + /// public interface IUseWebApiParameterConventions { } diff --git a/src/Microsoft.AspNetCore.Mvc.WebApiCompatShim/Conventions/IUseWebApiRoutes.cs b/src/Microsoft.AspNetCore.Mvc.WebApiCompatShim/Conventions/IUseWebApiRoutes.cs index 7dbd14cc41..f0efadbd90 100644 --- a/src/Microsoft.AspNetCore.Mvc.WebApiCompatShim/Conventions/IUseWebApiRoutes.cs +++ b/src/Microsoft.AspNetCore.Mvc.WebApiCompatShim/Conventions/IUseWebApiRoutes.cs @@ -3,6 +3,9 @@ namespace Microsoft.AspNetCore.Mvc.WebApiCompatShim { + /// + /// Indicates the controller is in the "api" area. + /// public interface IUseWebApiRoutes { } diff --git a/src/Microsoft.AspNetCore.Mvc.WebApiCompatShim/Conventions/UseWebApiActionConventionsAttribute.cs b/src/Microsoft.AspNetCore.Mvc.WebApiCompatShim/Conventions/UseWebApiActionConventionsAttribute.cs index 2ec6ae6e9a..ef9401f5d4 100644 --- a/src/Microsoft.AspNetCore.Mvc.WebApiCompatShim/Conventions/UseWebApiActionConventionsAttribute.cs +++ b/src/Microsoft.AspNetCore.Mvc.WebApiCompatShim/Conventions/UseWebApiActionConventionsAttribute.cs @@ -5,6 +5,9 @@ using System; namespace Microsoft.AspNetCore.Mvc.WebApiCompatShim { + /// + /// Indicates actions without attribute routes in a controller use WebAPI routing conventions. w + /// [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)] public class UseWebApiActionConventionsAttribute : Attribute, IUseWebApiActionConventions { diff --git a/src/Microsoft.AspNetCore.Mvc.WebApiCompatShim/Conventions/UseWebApiOverloadingAttribute.cs b/src/Microsoft.AspNetCore.Mvc.WebApiCompatShim/Conventions/UseWebApiOverloadingAttribute.cs index 153a772940..f253f0f0bf 100644 --- a/src/Microsoft.AspNetCore.Mvc.WebApiCompatShim/Conventions/UseWebApiOverloadingAttribute.cs +++ b/src/Microsoft.AspNetCore.Mvc.WebApiCompatShim/Conventions/UseWebApiOverloadingAttribute.cs @@ -5,6 +5,10 @@ using System; namespace Microsoft.AspNetCore.Mvc.WebApiCompatShim { + /// + /// Indicates actions in a controller should be selected only if all non-optional parameters are satisfied. Applies + /// the to all actions in the controller. + /// [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)] public class UseWebApiOverloadingAttribute : Attribute, IUseWebApiOverloading { diff --git a/src/Microsoft.AspNetCore.Mvc.WebApiCompatShim/Conventions/UseWebApiParameterConventionsAttribute.cs b/src/Microsoft.AspNetCore.Mvc.WebApiCompatShim/Conventions/UseWebApiParameterConventionsAttribute.cs index c684a0a3b3..f68ae9d002 100644 --- a/src/Microsoft.AspNetCore.Mvc.WebApiCompatShim/Conventions/UseWebApiParameterConventionsAttribute.cs +++ b/src/Microsoft.AspNetCore.Mvc.WebApiCompatShim/Conventions/UseWebApiParameterConventionsAttribute.cs @@ -5,6 +5,10 @@ using System; namespace Microsoft.AspNetCore.Mvc.WebApiCompatShim { + /// + /// Indicates the model binding system should use WebAPI conventions for parameters of a controller's actions. For + /// example, bind simple types from the URI. + /// [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)] public class UseWebApiParameterConventionsAttribute : Attribute, IUseWebApiParameterConventions { diff --git a/src/Microsoft.AspNetCore.Mvc.WebApiCompatShim/Conventions/UseWebApiRoutesAttribute.cs b/src/Microsoft.AspNetCore.Mvc.WebApiCompatShim/Conventions/UseWebApiRoutesAttribute.cs index 684490124f..17d14aba37 100644 --- a/src/Microsoft.AspNetCore.Mvc.WebApiCompatShim/Conventions/UseWebApiRoutesAttribute.cs +++ b/src/Microsoft.AspNetCore.Mvc.WebApiCompatShim/Conventions/UseWebApiRoutesAttribute.cs @@ -5,6 +5,9 @@ using System; namespace Microsoft.AspNetCore.Mvc.WebApiCompatShim { + /// + /// Indicates the controller is in the "api" area. + /// [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)] public class UseWebApiRoutesAttribute : Attribute, IUseWebApiRoutes { diff --git a/src/Microsoft.AspNetCore.Mvc.WebApiCompatShim/OverloadActionConstraint.cs b/src/Microsoft.AspNetCore.Mvc.WebApiCompatShim/OverloadActionConstraint.cs index 6f894cd3da..041090d37a 100644 --- a/src/Microsoft.AspNetCore.Mvc.WebApiCompatShim/OverloadActionConstraint.cs +++ b/src/Microsoft.AspNetCore.Mvc.WebApiCompatShim/OverloadActionConstraint.cs @@ -14,10 +14,16 @@ using Microsoft.AspNetCore.Routing; namespace Microsoft.AspNetCore.Mvc.WebApiCompatShim { + /// + /// An limiting candidate actions to those for which the request satisfies all + /// non-optional parameters. + /// public class OverloadActionConstraint : IActionConstraint { + /// public int Order { get; } = int.MaxValue; + /// public bool Accept(ActionConstraintContext context) { var candidates = context.Candidates.Select(c => new diff --git a/src/Microsoft.AspNetCore.Mvc.WebApiCompatShim/ParameterBinding/FromUriAttribute.cs b/src/Microsoft.AspNetCore.Mvc.WebApiCompatShim/ParameterBinding/FromUriAttribute.cs index eb84b10180..0002337087 100644 --- a/src/Microsoft.AspNetCore.Mvc.WebApiCompatShim/ParameterBinding/FromUriAttribute.cs +++ b/src/Microsoft.AspNetCore.Mvc.WebApiCompatShim/ParameterBinding/FromUriAttribute.cs @@ -1,7 +1,6 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.ModelBinding; using WebApiShimResources = Microsoft.AspNetCore.Mvc.WebApiCompatShim.Resources; @@ -21,8 +20,10 @@ namespace System.Web.Http new BindingSource[] { BindingSource.Path, BindingSource.Query }, WebApiShimResources.BindingSource_URL); + /// public BindingSource BindingSource { get { return FromUriSource; } } + /// public bool IsOptional { get; set; } /// diff --git a/src/Microsoft.AspNetCore.Mvc.WebApiCompatShim/ParameterBinding/IOptionalBinderMetadata.cs b/src/Microsoft.AspNetCore.Mvc.WebApiCompatShim/ParameterBinding/IOptionalBinderMetadata.cs index 16f9abed66..05cfc09d4d 100644 --- a/src/Microsoft.AspNetCore.Mvc.WebApiCompatShim/ParameterBinding/IOptionalBinderMetadata.cs +++ b/src/Microsoft.AspNetCore.Mvc.WebApiCompatShim/ParameterBinding/IOptionalBinderMetadata.cs @@ -4,14 +4,21 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding { /// + /// /// An type that designates an optional parameter for the purposes - /// of WebAPI action overloading. Optional parameters do not participate in overloading, and + /// of WebAPI action overloading. Optional parameters do not participate in overloading, and /// do not have to have a value for the action to be selected. - /// + /// + /// /// This has no impact when used without WebAPI action overloading. + /// /// public interface IOptionalBinderMetadata { + /// + /// Gets a value indicating whether the parameter participates in WebAPI action overloading. If true, + /// the parameter does not participate in overloading. Otherwise, it does. + /// bool IsOptional { get; } } } \ No newline at end of file