Add doc comments for `public` attributes

- #4641
This commit is contained in:
Doug Bunting 2016-06-09 15:02:24 -07:00
parent a2feeab545
commit 1f6bbf9967
21 changed files with 115 additions and 7 deletions

View File

@ -5,14 +5,24 @@ using System;
namespace Microsoft.AspNetCore.Mvc
{
/// <summary>
/// Specifies the name of an action.
/// </summary>
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
public sealed class ActionNameAttribute : Attribute
{
/// <summary>
/// Initializes a new <see cref="ActionNameAttribute"/> instance.
/// </summary>
/// <param name="name">The name of the action.</param>
public ActionNameAttribute(string name)
{
Name = name;
}
/// <summary>
/// Gets the name of the action.
/// </summary>
public string Name { get; private set; }
}
}

View File

@ -6,9 +6,16 @@ using Microsoft.AspNetCore.Mvc.Routing;
namespace Microsoft.AspNetCore.Mvc
{
/// <summary>
/// Specifies the area containing a controller or action.
/// </summary>
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
public class AreaAttribute : RouteValueAttribute
{
/// <summary>
/// Initializes a new <see cref="AreaAttribute"/> instance.
/// </summary>
/// <param name="areaName">The area containing the controller or action.</param>
public AreaAttribute(string areaName)
: base("area", areaName)
{

View File

@ -12,7 +12,7 @@ namespace Microsoft.AspNetCore.Mvc
/// <example>
/// 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.
///
/// <code>
/// [HttpGet]
@ -21,7 +21,7 @@ namespace Microsoft.AspNetCore.Mvc
/// return productModelReqest.Value;
/// }
/// </code>
/// </example>
/// </example>
[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = true)]
public class FromServicesAttribute : Attribute, IBindingSourceMetadata
{

View File

@ -5,9 +5,15 @@ using System;
namespace Microsoft.AspNetCore.Mvc.ModelBinding
{
/// <summary>
/// Indicates that the property should be excluded from model binding.
/// </summary>
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
public sealed class BindNeverAttribute : BindingBehaviorAttribute
{
/// <summary>
/// Initializes a new <see cref="BindNeverAttribute"/> instance.
/// </summary>
public BindNeverAttribute()
: base(BindingBehavior.Never)
{

View File

@ -5,9 +5,15 @@ using System;
namespace Microsoft.AspNetCore.Mvc.ModelBinding
{
/// <summary>
/// Indicates that the property is required for model binding.
/// </summary>
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
public sealed class BindRequiredAttribute : BindingBehaviorAttribute
{
/// <summary>
/// Initializes a new <see cref="BindRequiredAttribute"/> instance.
/// </summary>
public BindRequiredAttribute()
: base(BindingBehavior.Required)
{

View File

@ -3,10 +3,24 @@
namespace Microsoft.AspNetCore.Mvc.ModelBinding
{
/// <summary>
/// Enumerates behavior options of the model binding system.
/// </summary>
public enum BindingBehavior
{
/// <summary>
/// The property should be model bound if a value is available from the value provider.
/// </summary>
Optional = 0,
/// <summary>
/// The property should be excluded from model binding.
/// </summary>
Never,
/// <summary>
/// The property is required for model binding.
/// </summary>
Required
}
}

View File

@ -5,14 +5,24 @@ using System;
namespace Microsoft.AspNetCore.Mvc.ModelBinding
{
/// <summary>
/// Specifies the <see cref="BindingBehavior"/> that should be applied.
/// </summary>
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
public class BindingBehaviorAttribute : Attribute
{
/// <summary>
/// Initializes a new <see cref="BindingBehaviorAttribute"/> instance.
/// </summary>
/// <param name="behavior">The <see cref="BindingBehavior"/> to apply.</param>
public BindingBehaviorAttribute(BindingBehavior behavior)
{
Behavior = behavior;
}
/// <summary>
/// Gets the <see cref="BindingBehavior"/> to apply.
/// </summary>
public BindingBehavior Behavior { get; private set; }
}
}

View File

@ -5,6 +5,9 @@ using System;
namespace Microsoft.AspNetCore.Mvc
{
/// <summary>
/// Indicates that a controller method is not an action method.
/// </summary>
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
public sealed class NonActionAttribute : Attribute
{

View File

@ -6,14 +6,18 @@ using System;
namespace Microsoft.AspNetCore.Mvc.Routing
{
/// <summary>
/// <para>
/// An attribute which specifies a required route value for an action or controller.
///
/// </para>
/// <para>
/// 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 <see cref="IRouteValueProvider"/> for
/// the expectations that must be satisfied by the route data.
///
/// </para>
/// <para>
/// When placed on a controller, unless overridden by the action, the constraint applies to all
/// actions defined by the controller.
/// </para>
/// </summary>
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
public abstract class RouteValueAttribute : Attribute, IRouteValueProvider

View File

@ -5,9 +5,15 @@ using System;
namespace Microsoft.AspNetCore.Mvc
{
/// <summary>
/// Indicates the class is a view component and optionally specifies the component's name.
/// </summary>
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)]
public class ViewComponentAttribute : Attribute
{
/// <summary>
/// Gets or sets the name of the view component.
/// </summary>
public string Name { get; set; }
}
}

View File

@ -3,6 +3,9 @@
namespace Microsoft.AspNetCore.Mvc.WebApiCompatShim
{
/// <summary>
/// Indicates actions without attribute routes in a controller use WebAPI routing conventions.
/// </summary>
public interface IUseWebApiActionConventions
{
}

View File

@ -3,6 +3,10 @@
namespace Microsoft.AspNetCore.Mvc.WebApiCompatShim
{
/// <summary>
/// Indicates actions in a controller should be selected only if all non-optional parameters are satisfied. Applies
/// the <see cref="OverloadActionConstraint"/> to all actions in the controller.
/// </summary>
public interface IUseWebApiOverloading
{
}

View File

@ -3,6 +3,10 @@
namespace Microsoft.AspNetCore.Mvc.WebApiCompatShim
{
/// <summary>
/// Indicates the model binding system should use WebAPI conventions for parameters of a controller's actions. For
/// example, bind simple types from the URI.
/// </summary>
public interface IUseWebApiParameterConventions
{
}

View File

@ -3,6 +3,9 @@
namespace Microsoft.AspNetCore.Mvc.WebApiCompatShim
{
/// <summary>
/// Indicates the controller is in the "api" area.
/// </summary>
public interface IUseWebApiRoutes
{
}

View File

@ -5,6 +5,9 @@ using System;
namespace Microsoft.AspNetCore.Mvc.WebApiCompatShim
{
/// <summary>
/// Indicates actions without attribute routes in a controller use WebAPI routing conventions. w
/// </summary>
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)]
public class UseWebApiActionConventionsAttribute : Attribute, IUseWebApiActionConventions
{

View File

@ -5,6 +5,10 @@ using System;
namespace Microsoft.AspNetCore.Mvc.WebApiCompatShim
{
/// <summary>
/// Indicates actions in a controller should be selected only if all non-optional parameters are satisfied. Applies
/// the <see cref="OverloadActionConstraint"/> to all actions in the controller.
/// </summary>
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)]
public class UseWebApiOverloadingAttribute : Attribute, IUseWebApiOverloading
{

View File

@ -5,6 +5,10 @@ using System;
namespace Microsoft.AspNetCore.Mvc.WebApiCompatShim
{
/// <summary>
/// Indicates the model binding system should use WebAPI conventions for parameters of a controller's actions. For
/// example, bind simple types from the URI.
/// </summary>
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)]
public class UseWebApiParameterConventionsAttribute : Attribute, IUseWebApiParameterConventions
{

View File

@ -5,6 +5,9 @@ using System;
namespace Microsoft.AspNetCore.Mvc.WebApiCompatShim
{
/// <summary>
/// Indicates the controller is in the "api" area.
/// </summary>
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)]
public class UseWebApiRoutesAttribute : Attribute, IUseWebApiRoutes
{

View File

@ -14,10 +14,16 @@ using Microsoft.AspNetCore.Routing;
namespace Microsoft.AspNetCore.Mvc.WebApiCompatShim
{
/// <summary>
/// An <see cref="IActionConstraint"/> limiting candidate actions to those for which the request satisfies all
/// non-optional parameters.
/// </summary>
public class OverloadActionConstraint : IActionConstraint
{
/// <inheritdoc />
public int Order { get; } = int.MaxValue;
/// <inheritdoc />
public bool Accept(ActionConstraintContext context)
{
var candidates = context.Candidates.Select(c => new

View File

@ -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);
/// <inheritdoc />
public BindingSource BindingSource { get { return FromUriSource; } }
/// <inheritdoc />
public bool IsOptional { get; set; }
/// <inheritdoc />

View File

@ -4,14 +4,21 @@
namespace Microsoft.AspNetCore.Mvc.ModelBinding
{
/// <summary>
/// <para>
/// 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.
///
/// </para>
/// <para>
/// This has no impact when used without WebAPI action overloading.
/// </para>
/// </summary>
public interface IOptionalBinderMetadata
{
/// <summary>
/// Gets a value indicating whether the parameter participates in WebAPI action overloading. If <c>true</c>,
/// the parameter does not participate in overloading. Otherwise, it does.
/// </summary>
bool IsOptional { get; }
}
}