diff --git a/src/Microsoft.AspNetCore.Mvc.Abstractions/Authorization/IAllowAnonymousFilter.cs b/src/Microsoft.AspNetCore.Mvc.Abstractions/Authorization/IAllowAnonymousFilter.cs index 0509ec1988..a015f05967 100644 --- a/src/Microsoft.AspNetCore.Mvc.Abstractions/Authorization/IAllowAnonymousFilter.cs +++ b/src/Microsoft.AspNetCore.Mvc.Abstractions/Authorization/IAllowAnonymousFilter.cs @@ -5,6 +5,9 @@ using Microsoft.AspNetCore.Mvc.Filters; namespace Microsoft.AspNetCore.Mvc.Authorization { + /// + /// A filter that allows anonymous requests, disabling some s. + /// public interface IAllowAnonymousFilter : IFilterMetadata { } diff --git a/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/ActionExecutedContext.cs b/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/ActionExecutedContext.cs index b3d15f6666..68e0343f04 100644 --- a/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/ActionExecutedContext.cs +++ b/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/ActionExecutedContext.cs @@ -7,11 +7,20 @@ using System.Runtime.ExceptionServices; namespace Microsoft.AspNetCore.Mvc.Filters { + /// + /// A context for action filters, specifically calls. + /// public class ActionExecutedContext : FilterContext { private Exception _exception; private ExceptionDispatchInfo _exceptionDispatchInfo; + /// + /// Instantiates a new instance. + /// + /// The . + /// All applicable implementations. + /// The controller instance containing the action. public ActionExecutedContext( ActionContext actionContext, IList filters, @@ -21,10 +30,20 @@ namespace Microsoft.AspNetCore.Mvc.Filters Controller = controller; } + /// + /// Gets or sets an indication that an action filter short-circuited the action and the action filter pipeline. + /// public virtual bool Canceled { get; set; } + /// + /// Gets the controller instance containing the action. + /// public virtual object Controller { get; } + /// + /// Gets or sets the caught while executing the action or action filters, if + /// any. + /// public virtual Exception Exception { get @@ -46,6 +65,10 @@ namespace Microsoft.AspNetCore.Mvc.Filters } } + /// + /// Gets or sets the for the + /// , if an was caught and this information captured. + /// public virtual ExceptionDispatchInfo ExceptionDispatchInfo { get @@ -60,8 +83,14 @@ namespace Microsoft.AspNetCore.Mvc.Filters } } + /// + /// Gets or sets an indication that the has been handled. + /// public virtual bool ExceptionHandled { get; set; } + /// + /// Gets or sets the . + /// public virtual IActionResult Result { get; set; } } } diff --git a/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/ActionExecutingContext.cs b/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/ActionExecutingContext.cs index b07e59c3d7..65ade1e1c5 100644 --- a/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/ActionExecutingContext.cs +++ b/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/ActionExecutingContext.cs @@ -6,8 +6,21 @@ using System.Collections.Generic; namespace Microsoft.AspNetCore.Mvc.Filters { + /// + /// A context for action filters, specifically and + /// calls. + /// public class ActionExecutingContext : FilterContext { + /// + /// Instantiates a new instance. + /// + /// The . + /// All applicable implementations. + /// + /// The arguments to pass when invoking the action. Keys are parameter names. + /// + /// The controller instance containing the action. public ActionExecutingContext( ActionContext actionContext, IList filters, @@ -24,10 +37,20 @@ namespace Microsoft.AspNetCore.Mvc.Filters Controller = controller; } + /// + /// Gets or sets the to execute. Setting to a non-null + /// value inside an action filter will short-circuit the action and any remaining action filters. + /// public virtual IActionResult Result { get; set; } + /// + /// Gets the arguments to pass when invoking the action. Keys are parameter names. + /// public virtual IDictionary ActionArguments { get; } + /// + /// Gets the controller instance containing the action. + /// public virtual object Controller { get; } } } diff --git a/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/ActionExecutionDelegate.cs b/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/ActionExecutionDelegate.cs index 802ffdace1..0ee53b4493 100644 --- a/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/ActionExecutionDelegate.cs +++ b/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/ActionExecutionDelegate.cs @@ -5,5 +5,12 @@ using System.Threading.Tasks; namespace Microsoft.AspNetCore.Mvc.Filters { + /// + /// A delegate that asynchronously returns an indicating the action or the next + /// action filter has executed. + /// + /// + /// A that on completion returns an . + /// public delegate Task ActionExecutionDelegate(); } diff --git a/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/AuthorizationFilterContext.cs b/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/AuthorizationFilterContext.cs index 19354819bd..a344d55432 100644 --- a/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/AuthorizationFilterContext.cs +++ b/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/AuthorizationFilterContext.cs @@ -1,13 +1,21 @@ // 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 System; using System.Collections.Generic; namespace Microsoft.AspNetCore.Mvc.Filters { + /// + /// A context for authorization filters i.e. and + /// implementations. + /// public class AuthorizationFilterContext : FilterContext { + /// + /// Instantiates a new instance. + /// + /// The . + /// All applicable implementations. public AuthorizationFilterContext( ActionContext actionContext, IList filters) @@ -15,6 +23,10 @@ namespace Microsoft.AspNetCore.Mvc.Filters { } + /// + /// Gets or sets the result of the request. Setting to a non-null value inside + /// an authorization filter will short-circuit the remainder of the filter pipeline. + /// public virtual IActionResult Result { get; set; } } } diff --git a/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/ExceptionContext.cs b/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/ExceptionContext.cs index a204f5bf73..d0c0b4dcc0 100644 --- a/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/ExceptionContext.cs +++ b/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/ExceptionContext.cs @@ -7,16 +7,28 @@ using System.Runtime.ExceptionServices; namespace Microsoft.AspNetCore.Mvc.Filters { + /// + /// A context for exception filters i.e. and + /// implementations. + /// public class ExceptionContext : FilterContext { private Exception _exception; private ExceptionDispatchInfo _exceptionDispatchInfo; + /// + /// Instantiates a new instance. + /// + /// The . + /// All applicable implementations. public ExceptionContext(ActionContext actionContext, IList filters) : base(actionContext, filters) { } + /// + /// Gets or sets the caught while executing the action. + /// public virtual Exception Exception { get @@ -38,6 +50,10 @@ namespace Microsoft.AspNetCore.Mvc.Filters } } + /// + /// Gets or sets the for the + /// , if this information was captured. + /// public virtual ExceptionDispatchInfo ExceptionDispatchInfo { get @@ -52,6 +68,9 @@ namespace Microsoft.AspNetCore.Mvc.Filters } } + /// + /// Gets or sets the . + /// public virtual IActionResult Result { get; set; } } } diff --git a/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/FilterContext.cs b/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/FilterContext.cs index 175d2777bd..f74e7c7404 100644 --- a/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/FilterContext.cs +++ b/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/FilterContext.cs @@ -6,8 +6,16 @@ using System.Collections.Generic; namespace Microsoft.AspNetCore.Mvc.Filters { + /// + /// An abstract context for filters. + /// public abstract class FilterContext : ActionContext { + /// + /// Instantiates a new instance. + /// + /// The . + /// All applicable implementations. public FilterContext( ActionContext actionContext, IList filters) @@ -21,6 +29,9 @@ namespace Microsoft.AspNetCore.Mvc.Filters Filters = filters; } + /// + /// Gets all applicable implementations. + /// public virtual IList Filters { get; } } } diff --git a/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/FilterProviderContext.cs b/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/FilterProviderContext.cs index 00463764bb..057654eaa4 100644 --- a/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/FilterProviderContext.cs +++ b/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/FilterProviderContext.cs @@ -6,8 +6,18 @@ using System.Collections.Generic; namespace Microsoft.AspNetCore.Mvc.Filters { + /// + /// A context for filter providers i.e. implementations. + /// public class FilterProviderContext { + /// + /// Instantiates a new instance. + /// + /// The . + /// + /// The s, initially created from s or a cache entry. + /// public FilterProviderContext(ActionContext actionContext, IList items) { if (actionContext == null) @@ -24,10 +34,16 @@ namespace Microsoft.AspNetCore.Mvc.Filters Results = items; } - // Input + /// + /// Gets or sets the . + /// public ActionContext ActionContext { get; set; } - // Results + /// + /// Gets or sets the s, initially created from s or a + /// cache entry. s should set on existing items or + /// add new s to make executable filters available. + /// public IList Results { get; set; } } } diff --git a/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/IActionFilter.cs b/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/IActionFilter.cs index 56dc1f5126..cb37ded4c7 100644 --- a/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/IActionFilter.cs +++ b/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/IActionFilter.cs @@ -3,10 +3,21 @@ namespace Microsoft.AspNetCore.Mvc.Filters { + /// + /// A filter that surrounds execution of the action. + /// public interface IActionFilter : IFilterMetadata { + /// + /// Called before the action executes, after model binding is complete. + /// + /// The . void OnActionExecuting(ActionExecutingContext context); + /// + /// Called after the action executes, before the action result. + /// + /// The . void OnActionExecuted(ActionExecutedContext context); } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/IAsyncActionFilter.cs b/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/IAsyncActionFilter.cs index 01e4d9ef25..3342e2b1ff 100644 --- a/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/IAsyncActionFilter.cs +++ b/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/IAsyncActionFilter.cs @@ -5,8 +5,19 @@ using System.Threading.Tasks; namespace Microsoft.AspNetCore.Mvc.Filters { + /// + /// A filter that asynchronously surrounds execution of the action, after model binding is complete. + /// public interface IAsyncActionFilter : IFilterMetadata { + /// + /// Called asynchronously before the action, after model binding is complete. + /// + /// The . + /// + /// The . Invoked to execute the next action filter or the action itself. + /// + /// A that on completion indicates the filter has executed. Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next); } } diff --git a/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/IAsyncAuthorizationFilter.cs b/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/IAsyncAuthorizationFilter.cs index 734dcedeb4..dd1a797e13 100644 --- a/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/IAsyncAuthorizationFilter.cs +++ b/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/IAsyncAuthorizationFilter.cs @@ -5,8 +5,18 @@ using System.Threading.Tasks; namespace Microsoft.AspNetCore.Mvc.Filters { + /// + /// A filter that asynchronously confirms request authorization. + /// public interface IAsyncAuthorizationFilter : IFilterMetadata { + /// + /// Called early in the filter pipeline to confirm request is authorized. + /// + /// The . + /// + /// A that on completion indicates the filter has executed. + /// Task OnAuthorizationAsync(AuthorizationFilterContext context); } } diff --git a/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/IAsyncExceptionFilter.cs b/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/IAsyncExceptionFilter.cs index 90e58c232f..ce3343b463 100644 --- a/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/IAsyncExceptionFilter.cs +++ b/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/IAsyncExceptionFilter.cs @@ -5,8 +5,16 @@ using System.Threading.Tasks; namespace Microsoft.AspNetCore.Mvc.Filters { + /// + /// A filter that runs asynchronously after an action has thrown an . + /// public interface IAsyncExceptionFilter : IFilterMetadata { + /// + /// Called after an action has thrown an . + /// + /// The . + /// A that on completion indicates the filter has executed. Task OnExceptionAsync(ExceptionContext context); } } diff --git a/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/IAsyncResourceFilter.cs b/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/IAsyncResourceFilter.cs index d48f46ca0f..6b4eb7ba9e 100644 --- a/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/IAsyncResourceFilter.cs +++ b/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/IAsyncResourceFilter.cs @@ -6,18 +6,18 @@ using System.Threading.Tasks; namespace Microsoft.AspNetCore.Mvc.Filters { /// - /// A filter which surrounds execution of model binding, the action (and filters) and the action result - /// (and filters). + /// A filter that asynchronously surrounds execution of model binding, the action (and filters) and the action + /// result (and filters). /// public interface IAsyncResourceFilter : IFilterMetadata { /// - /// Executes the resource filter. + /// Called asynchronously before the rest of the pipeline. /// /// The . /// - /// The . Invoked to execute the next - /// resource filter, or the remainder of the pipeline. + /// The . Invoked to execute the next resource filter or the remainder + /// of the pipeline. /// /// /// A which will complete when the remainder of the pipeline completes. diff --git a/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/IAsyncResultFilter.cs b/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/IAsyncResultFilter.cs index ce970bc1d6..64be384a8f 100644 --- a/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/IAsyncResultFilter.cs +++ b/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/IAsyncResultFilter.cs @@ -5,8 +5,19 @@ using System.Threading.Tasks; namespace Microsoft.AspNetCore.Mvc.Filters { + /// + /// A filter that asynchronously surrounds execution of the action result. + /// public interface IAsyncResultFilter : IFilterMetadata { + /// + /// Called asynchronously before the action result. + /// + /// The . + /// + /// The . Invoked to execute the next result filter or the result itself. + /// + /// A that on completion indicates the filter has executed. Task OnResultExecutionAsync(ResultExecutingContext context, ResultExecutionDelegate next); } } diff --git a/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/IAuthorizationFilter.cs b/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/IAuthorizationFilter.cs index d2f3a9cfb1..3dbc4159a0 100644 --- a/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/IAuthorizationFilter.cs +++ b/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/IAuthorizationFilter.cs @@ -3,8 +3,15 @@ namespace Microsoft.AspNetCore.Mvc.Filters { + /// + /// A filter that confirms request authorization. + /// public interface IAuthorizationFilter : IFilterMetadata { + /// + /// Called early in the filter pipeline to confirm request is authorized. + /// + /// The . void OnAuthorization(AuthorizationFilterContext context); } } diff --git a/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/IExceptionFilter.cs b/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/IExceptionFilter.cs index 7140aaf499..5908c2aac9 100644 --- a/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/IExceptionFilter.cs +++ b/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/IExceptionFilter.cs @@ -3,8 +3,15 @@ namespace Microsoft.AspNetCore.Mvc.Filters { + /// + /// A filter that runs after an action has thrown an . + /// public interface IExceptionFilter : IFilterMetadata { + /// + /// Called after an action has thrown an . + /// + /// The . void OnException(ExceptionContext context); } } diff --git a/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/IFilterContainer.cs b/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/IFilterContainer.cs index e7b319460f..26199e6dcf 100644 --- a/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/IFilterContainer.cs +++ b/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/IFilterContainer.cs @@ -3,8 +3,14 @@ namespace Microsoft.AspNetCore.Mvc.Filters { + /// + /// A filter that requires a reference back to the that created it. + /// public interface IFilterContainer { + /// + /// The that created this filter instance. + /// IFilterMetadata FilterDefinition { get; set; } } } diff --git a/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/IFilterFactory.cs b/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/IFilterFactory.cs index 69731b3aad..e0e844a790 100644 --- a/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/IFilterFactory.cs +++ b/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/IFilterFactory.cs @@ -6,7 +6,7 @@ using System; namespace Microsoft.AspNetCore.Mvc.Filters { /// - /// An interface for for filter metadata which can create an instance of an executable filter. + /// An interface for filter metadata which can create an instance of an executable filter. /// public interface IFilterFactory : IFilterMetadata { diff --git a/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/IFilterMetadata.cs b/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/IFilterMetadata.cs index ce02746186..458bfdc35c 100644 --- a/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/IFilterMetadata.cs +++ b/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/IFilterMetadata.cs @@ -3,6 +3,9 @@ namespace Microsoft.AspNetCore.Mvc.Filters { + /// + /// Marker interface for filters handled in the MVC request pipeline. + /// public interface IFilterMetadata { } diff --git a/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/IFilterProvider.cs b/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/IFilterProvider.cs index b3fadad47a..46f121b4e8 100644 --- a/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/IFilterProvider.cs +++ b/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/IFilterProvider.cs @@ -3,6 +3,10 @@ namespace Microsoft.AspNetCore.Mvc.Filters { + /// + /// A provider. Implementations should update + /// to make executable filters available. + /// public interface IFilterProvider { /// @@ -26,8 +30,16 @@ namespace Microsoft.AspNetCore.Mvc.Filters /// int Order { get; } + /// + /// Called in increasing . + /// + /// The . void OnProvidersExecuting(FilterProviderContext context); + /// + /// Called in decreasing , after all s have executed once. + /// + /// The . void OnProvidersExecuted(FilterProviderContext context); } } diff --git a/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/IOrderedFilter.cs b/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/IOrderedFilter.cs index 452cb70d63..36876091ce 100644 --- a/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/IOrderedFilter.cs +++ b/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/IOrderedFilter.cs @@ -3,6 +3,9 @@ namespace Microsoft.AspNetCore.Mvc.Filters { + /// + /// A filter that specifies the relative order it should run. + /// public interface IOrderedFilter : IFilterMetadata { /// @@ -23,7 +26,7 @@ namespace Microsoft.AspNetCore.Mvc.Filters /// Synchronous filters, such as , have a before-method, such as /// , and an after-method, such as /// . A synchronous filter with a lower numeric - /// value will have its before-method executed before that of a filter with a higher value of + /// value will have its before-method executed before that of a filter with a higher value of /// . During the after-stage of the filter, a synchronous filter with a lower /// numeric value will have its after-method executed after that of a filter with a higher /// value of . diff --git a/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/IResourceFilter.cs b/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/IResourceFilter.cs index d16404a4c1..410a03c939 100644 --- a/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/IResourceFilter.cs +++ b/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/IResourceFilter.cs @@ -4,7 +4,7 @@ namespace Microsoft.AspNetCore.Mvc.Filters { /// - /// A filter which surrounds execution of model binding, the action (and filters) and the action result + /// A filter that surrounds execution of model binding, the action (and filters) and the action result /// (and filters). /// public interface IResourceFilter : IFilterMetadata diff --git a/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/IResultFilter.cs b/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/IResultFilter.cs index 25748b05d9..151d2d2022 100644 --- a/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/IResultFilter.cs +++ b/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/IResultFilter.cs @@ -3,10 +3,21 @@ namespace Microsoft.AspNetCore.Mvc.Filters { + /// + /// A filter that surrounds execution of the action result. + /// public interface IResultFilter : IFilterMetadata { + /// + /// Called before the action result executes. + /// + /// The . void OnResultExecuting(ResultExecutingContext context); + /// + /// Called after the action result executes. + /// + /// The . void OnResultExecuted(ResultExecutedContext context); } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/ResourceExecutedContext.cs b/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/ResourceExecutedContext.cs index ab0fec1ebc..bc8eb9f5c3 100644 --- a/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/ResourceExecutedContext.cs +++ b/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/ResourceExecutedContext.cs @@ -8,7 +8,7 @@ using System.Runtime.ExceptionServices; namespace Microsoft.AspNetCore.Mvc.Filters { /// - /// A context for resource filters. + /// A context for resource filters, specifically calls. /// public class ResourceExecutedContext : FilterContext { @@ -36,10 +36,13 @@ namespace Microsoft.AspNetCore.Mvc.Filters /// Gets or set the current . /// /// + /// /// Setting or to null will treat /// the exception as handled, and it will not be rethrown by the runtime. - /// + /// + /// /// Setting to true will also mark the exception as handled. + /// /// public virtual Exception Exception { @@ -66,10 +69,13 @@ namespace Microsoft.AspNetCore.Mvc.Filters /// Gets or set the current . /// /// + /// /// Setting or to null will treat /// the exception as handled, and it will not be rethrown by the runtime. - /// + /// + /// /// Setting to true will also mark the exception as handled. + /// /// public virtual ExceptionDispatchInfo ExceptionDispatchInfo { @@ -86,10 +92,13 @@ namespace Microsoft.AspNetCore.Mvc.Filters } /// + /// /// Gets or sets a value indicating whether or not the current has been handled. - /// + /// + /// /// If false the will be rethrown by the runtime after resource filters /// have executed. + /// /// public virtual bool ExceptionHandled { get; set; } @@ -97,11 +106,14 @@ namespace Microsoft.AspNetCore.Mvc.Filters /// Gets or sets the result. /// /// + /// /// The may be provided by execution of the action itself or by another - /// filter. - /// + /// filter. + /// + /// /// The has already been written to the response before being made available /// to resource filters. + /// /// public virtual IActionResult Result { get; set; } } diff --git a/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/ResourceExecutingContext.cs b/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/ResourceExecutingContext.cs index 770acb2bd2..e0007a4006 100644 --- a/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/ResourceExecutingContext.cs +++ b/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/ResourceExecutingContext.cs @@ -6,7 +6,8 @@ using System.Collections.Generic; namespace Microsoft.AspNetCore.Mvc.Filters { /// - /// A context for resource filters. + /// A context for resource filters, specifically and + /// calls. /// public class ResourceExecutingContext : FilterContext { @@ -19,7 +20,7 @@ namespace Microsoft.AspNetCore.Mvc.Filters : base(actionContext, filters) { } - + /// /// Gets or sets the result of the action to be executed. /// diff --git a/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/ResourceExecutionDelegate.cs b/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/ResourceExecutionDelegate.cs index 8be5d56eec..ef3531d208 100644 --- a/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/ResourceExecutionDelegate.cs +++ b/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/ResourceExecutionDelegate.cs @@ -6,8 +6,9 @@ using System.Threading.Tasks; namespace Microsoft.AspNetCore.Mvc.Filters { /// - /// A delegate which asyncronously returns a . + /// A delegate that asynchronously returns a indicating model binding, the + /// action, the action's result, result filters, and exception filters have executed. /// - /// A . + /// A that on completion returns a . public delegate Task ResourceExecutionDelegate(); } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/ResultExecutedContext.cs b/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/ResultExecutedContext.cs index 39f235a505..ae4947d8bf 100644 --- a/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/ResultExecutedContext.cs +++ b/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/ResultExecutedContext.cs @@ -7,11 +7,23 @@ using System.Runtime.ExceptionServices; namespace Microsoft.AspNetCore.Mvc.Filters { + /// + /// A context for result filters, specifically calls. + /// public class ResultExecutedContext : FilterContext { private Exception _exception; private ExceptionDispatchInfo _exceptionDispatchInfo; + /// + /// Instantiates a new instance. + /// + /// The . + /// All applicable implementations. + /// + /// The copied from . + /// + /// The controller instance containing the action. public ResultExecutedContext( ActionContext actionContext, IList filters, @@ -28,10 +40,21 @@ namespace Microsoft.AspNetCore.Mvc.Filters Controller = controller; } + /// + /// Gets or sets an indication that a result filter set to + /// true and short-circuited the filter pipeline. + /// public virtual bool Canceled { get; set; } + /// + /// Gets the controller instance containing the action. + /// public virtual object Controller { get; } + /// + /// Gets or sets the caught while executing the result or result filters, if + /// any. + /// public virtual Exception Exception { get @@ -53,6 +76,10 @@ namespace Microsoft.AspNetCore.Mvc.Filters } } + /// + /// Gets or sets the for the + /// , if an was caught and this information captured. + /// public virtual ExceptionDispatchInfo ExceptionDispatchInfo { get @@ -67,8 +94,14 @@ namespace Microsoft.AspNetCore.Mvc.Filters } } + /// + /// Gets or sets an indication that the has been handled. + /// public virtual bool ExceptionHandled { get; set; } - public virtual IActionResult Result { get; private set; } + /// + /// Gets the copied from . + /// + public virtual IActionResult Result { get; } } } diff --git a/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/ResultExecutingContext.cs b/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/ResultExecutingContext.cs index f298c466f7..cd4e8775ac 100644 --- a/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/ResultExecutingContext.cs +++ b/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/ResultExecutingContext.cs @@ -5,8 +5,19 @@ using System.Collections.Generic; namespace Microsoft.AspNetCore.Mvc.Filters { + /// + /// A context for result filters, specifically and + /// calls. + /// public class ResultExecutingContext : FilterContext { + /// + /// Instantiates a new instance. + /// + /// The . + /// All applicable implementations. + /// The of the action and action filters. + /// The controller instance containing the action. public ResultExecutingContext( ActionContext actionContext, IList filters, @@ -18,10 +29,20 @@ namespace Microsoft.AspNetCore.Mvc.Filters Controller = controller; } + /// + /// Gets the controller instance containing the action. + /// public virtual object Controller { get; } + /// + /// Gets or sets the to execute. Setting to a non-null + /// value inside a result filter will short-circuit the result and any remaining result filters. + /// public virtual IActionResult Result { get; set; } + /// + /// Gets or sets an indication the result filter pipeline should be short-circuited. + /// public virtual bool Cancel { get; set; } } } diff --git a/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/ResultExecutionDelegate.cs b/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/ResultExecutionDelegate.cs index 9f709a437e..d0ecea6914 100644 --- a/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/ResultExecutionDelegate.cs +++ b/src/Microsoft.AspNetCore.Mvc.Abstractions/Filters/ResultExecutionDelegate.cs @@ -5,5 +5,10 @@ using System.Threading.Tasks; namespace Microsoft.AspNetCore.Mvc.Filters { + /// + /// A delegate that asynchronously returns an indicating the action result or + /// the next result filter has executed. + /// + /// A that on completion returns an . public delegate Task ResultExecutionDelegate(); } diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Authorization/AuthorizeFilter.cs b/src/Microsoft.AspNetCore.Mvc.Core/Authorization/AuthorizeFilter.cs index 8052193d8d..b5542e5838 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/Authorization/AuthorizeFilter.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/Authorization/AuthorizeFilter.cs @@ -13,12 +13,14 @@ using Microsoft.Extensions.Internal; namespace Microsoft.AspNetCore.Mvc.Authorization { /// - /// An implementation of + /// An implementation of which applies a specific + /// . MVC recognizes the and adds an instance of + /// this filter to the associated action or controller. /// public class AuthorizeFilter : IAsyncAuthorizationFilter { /// - /// Authorize filter for a specific policy. + /// Initialize a new instance. /// /// Authorization policy to be used. public AuthorizeFilter(AuthorizationPolicy policy) @@ -32,9 +34,9 @@ namespace Microsoft.AspNetCore.Mvc.Authorization } /// - /// Authorization policy to be used. + /// Gets the authorization policy to be used. /// - public AuthorizationPolicy Policy { get; private set; } + public AuthorizationPolicy Policy { get; } /// public virtual async Task OnAuthorizationAsync(Filters.AuthorizationFilterContext context) diff --git a/src/Microsoft.AspNetCore.Mvc.Core/ConsumesAttribute.cs b/src/Microsoft.AspNetCore.Mvc.Core/ConsumesAttribute.cs index b9f2208c5c..eaf3403a36 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/ConsumesAttribute.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/ConsumesAttribute.cs @@ -16,7 +16,8 @@ using Microsoft.Net.Http.Headers; namespace Microsoft.AspNetCore.Mvc { /// - /// Specifies the allowed content types which can be used to select the action based on request's content-type. + /// A filter that specifies the supported request content types. is used to select an + /// action when there would otherwise be multiple matches. /// [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)] public class ConsumesAttribute : @@ -54,7 +55,10 @@ namespace Microsoft.AspNetCore.Mvc /// int IActionConstraint.Order { get; } = ConsumesActionConstraintOrder; - /// + /// + /// Gets or sets the supported request content types. Used to select an action when there would otherwise be + /// multiple matches. + /// public MediaTypeCollection ContentTypes { get; set; } /// @@ -103,6 +107,7 @@ namespace Microsoft.AspNetCore.Mvc } } + /// public bool Accept(ActionConstraintContext context) { // If this constraint is not closest to the action, it will be skipped. diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Filters/ActionFilterAttribute.cs b/src/Microsoft.AspNetCore.Mvc.Core/Filters/ActionFilterAttribute.cs index 4720dfd1d2..efb06d56ce 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/Filters/ActionFilterAttribute.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/Filters/ActionFilterAttribute.cs @@ -6,20 +6,31 @@ using System.Threading.Tasks; namespace Microsoft.AspNetCore.Mvc.Filters { + /// + /// An abstract filter that asynchronously surrounds execution of the action and the action result. Subclasses + /// should override , or + /// but not and either of the other two. + /// Similarly subclasses should override , or + /// but not and either of the other two. + /// [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)] public abstract class ActionFilterAttribute : Attribute, IActionFilter, IAsyncActionFilter, IResultFilter, IAsyncResultFilter, IOrderedFilter { + /// public int Order { get; set; } + /// public virtual void OnActionExecuting(ActionExecutingContext context) { } + /// public virtual void OnActionExecuted(ActionExecutedContext context) { } + /// public virtual async Task OnActionExecutionAsync( ActionExecutingContext context, ActionExecutionDelegate next) @@ -41,14 +52,17 @@ namespace Microsoft.AspNetCore.Mvc.Filters } } + /// public virtual void OnResultExecuting(ResultExecutingContext context) { } + /// public virtual void OnResultExecuted(ResultExecutedContext context) { } + /// public virtual async Task OnResultExecutionAsync( ResultExecutingContext context, ResultExecutionDelegate next) diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Filters/ExceptionFilterAttribute.cs b/src/Microsoft.AspNetCore.Mvc.Core/Filters/ExceptionFilterAttribute.cs index c394ececf2..f5cface3e4 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/Filters/ExceptionFilterAttribute.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/Filters/ExceptionFilterAttribute.cs @@ -7,11 +7,17 @@ using Microsoft.AspNetCore.Mvc.Internal; namespace Microsoft.AspNetCore.Mvc.Filters { + /// + /// An abstract filter that runs asynchronously after an action has thrown an . Subclasses + /// must override or but not both. + /// [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)] public abstract class ExceptionFilterAttribute : Attribute, IAsyncExceptionFilter, IExceptionFilter, IOrderedFilter { + /// public int Order { get; set; } + /// public virtual Task OnExceptionAsync(ExceptionContext context) { if (context == null) @@ -23,6 +29,7 @@ namespace Microsoft.AspNetCore.Mvc.Filters return TaskCache.CompletedTask; } + /// public virtual void OnException(ExceptionContext context) { } diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Filters/FilterScope.cs b/src/Microsoft.AspNetCore.Mvc.Core/Filters/FilterScope.cs index c3ded5c798..e687d3975c 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/Filters/FilterScope.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/Filters/FilterScope.cs @@ -4,10 +4,13 @@ namespace Microsoft.AspNetCore.Mvc.Filters { /// + /// /// Contains constant values for known filter scopes. - /// + /// + /// /// Scope defines the ordering of filters that have the same order. Scope is by-default /// defined by how a filter is registered. + /// /// public static class FilterScope { diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Filters/ResultFilterAttribute.cs b/src/Microsoft.AspNetCore.Mvc.Core/Filters/ResultFilterAttribute.cs index 04b26d0939..b7ff680661 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/Filters/ResultFilterAttribute.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/Filters/ResultFilterAttribute.cs @@ -6,19 +6,28 @@ using System.Threading.Tasks; namespace Microsoft.AspNetCore.Mvc.Filters { + /// + /// An abstract filter that asynchronously surrounds execution of the action result. Subclasses + /// must override , or + /// but not and either of the other two. + /// [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)] public abstract class ResultFilterAttribute : Attribute, IResultFilter, IAsyncResultFilter, IOrderedFilter { + /// public int Order { get; set; } + /// public virtual void OnResultExecuting(ResultExecutingContext context) { } + /// public virtual void OnResultExecuted(ResultExecutedContext context) { } + /// public virtual async Task OnResultExecutionAsync( ResultExecutingContext context, ResultExecutionDelegate next) diff --git a/src/Microsoft.AspNetCore.Mvc.Core/FormatFilterAttribute.cs b/src/Microsoft.AspNetCore.Mvc.Core/FormatFilterAttribute.cs index bde65f7c06..dab307f89d 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/FormatFilterAttribute.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/FormatFilterAttribute.cs @@ -9,7 +9,7 @@ using Microsoft.Extensions.DependencyInjection; namespace Microsoft.AspNetCore.Mvc { /// - /// A filter which will use the format value in the route data or query string to set the content type on an + /// A filter that will use the format value in the route data or query string to set the content type on an /// returned from an action. /// [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)] diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Formatters/FormatFilter.cs b/src/Microsoft.AspNetCore.Mvc.Core/Formatters/FormatFilter.cs index b9f7903df2..03c25c4c0c 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/Formatters/FormatFilter.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/Formatters/FormatFilter.cs @@ -11,8 +11,8 @@ using Microsoft.Extensions.Options; namespace Microsoft.AspNetCore.Mvc.Formatters { /// - /// A filter which will use the format value in the route data or query string to set the content type on an - /// returned from an action. + /// A filter that will use the format value in the route data or query string to set the content type on an + /// returned from an action. /// public class FormatFilter : IFormatFilter, IResourceFilter, IResultFilter { diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Internal/IFormatFilter.cs b/src/Microsoft.AspNetCore.Mvc.Core/Internal/IFormatFilter.cs index 0a769561fc..911ca2d247 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/Internal/IFormatFilter.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/Internal/IFormatFilter.cs @@ -6,12 +6,12 @@ using Microsoft.AspNetCore.Mvc.Filters; namespace Microsoft.AspNetCore.Mvc.Formatters.Internal { /// - /// A filter which produces a desired content type for the current request. + /// A filter that produces the desired content type for the request. /// public interface IFormatFilter : IFilterMetadata { /// - /// Gets the format value for the request associated with the provided . + /// Gets the format value for the request associated with the provided . /// /// The associated with the current request. /// A format value, or null if a format cannot be determined for the request. diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Internal/ResponseCacheFilter.cs b/src/Microsoft.AspNetCore.Mvc.Core/Internal/ResponseCacheFilter.cs index 0c08580a35..b27ec02e93 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/Internal/ResponseCacheFilter.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/Internal/ResponseCacheFilter.cs @@ -73,7 +73,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal set { _cacheVaryByHeader = value; } } - // + /// public void OnActionExecuting(ActionExecutingContext context) { if (context == null) @@ -152,7 +152,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal } } - // + /// public void OnActionExecuted(ActionExecutedContext context) { } diff --git a/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/UnsupportedContentTypeFilter.cs b/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/UnsupportedContentTypeFilter.cs index 35e30a119c..0c134d7dc9 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/UnsupportedContentTypeFilter.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/UnsupportedContentTypeFilter.cs @@ -1,15 +1,13 @@ // 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.Http; using Microsoft.AspNetCore.Mvc.Filters; -using Microsoft.Net.Http.Headers; namespace Microsoft.AspNetCore.Mvc.ModelBinding { /// /// A filter that scans for in the - /// and shortcircuits the pipeline + /// and short-circuits the pipeline /// with an Unsupported Media Type (415) response. /// public class UnsupportedContentTypeFilter : IActionFilter diff --git a/src/Microsoft.AspNetCore.Mvc.Core/ProducesAttribute.cs b/src/Microsoft.AspNetCore.Mvc.Core/ProducesAttribute.cs index 08c156d6e4..854171dad5 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/ProducesAttribute.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/ProducesAttribute.cs @@ -15,8 +15,9 @@ using Microsoft.Net.Http.Headers; namespace Microsoft.AspNetCore.Mvc { /// - /// Specifies the allowed content types and the type of the value returned by the action - /// which can be used to select a formatter while executing . + /// A filter that specifies the expected the action will return and the supported + /// response content types. The value is used to set + /// . /// [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)] public class ProducesAttribute : ResultFilterAttribute, IApiResponseMetadataProvider @@ -60,12 +61,18 @@ namespace Microsoft.AspNetCore.Mvc ContentTypes = GetContentTypes(contentType, additionalContentTypes); } + /// public Type Type { get; set; } + /// + /// Gets or sets the supported response content types. Used to set . + /// public MediaTypeCollection ContentTypes { get; set; } + /// public int StatusCode => StatusCodes.Status200OK; + /// public override void OnResultExecuting(ResultExecutingContext context) { if (context == null) @@ -109,6 +116,7 @@ namespace Microsoft.AspNetCore.Mvc return contentTypes; } + /// public void SetContentTypes(MediaTypeCollection contentTypes) { contentTypes.Clear(); diff --git a/src/Microsoft.AspNetCore.Mvc.Core/ProducesResponseTypeAttribute.cs b/src/Microsoft.AspNetCore.Mvc.Core/ProducesResponseTypeAttribute.cs index da2a7ca33a..c8a3eace66 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/ProducesResponseTypeAttribute.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/ProducesResponseTypeAttribute.cs @@ -9,7 +9,7 @@ using Microsoft.AspNetCore.Mvc.Formatters; namespace Microsoft.AspNetCore.Mvc { /// - /// Specifies the type of the value and status code returned by the action. + /// A filter that specifies the type of the value and status code returned by the action. /// [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)] public class ProducesResponseTypeAttribute : Attribute, IApiResponseMetadataProvider, IFilterMetadata @@ -18,7 +18,7 @@ namespace Microsoft.AspNetCore.Mvc /// Initializes an instance of . /// /// The of object that is going to be written in the response. - /// HTTP response status code + /// The HTTP response status code. public ProducesResponseTypeAttribute(Type type, int statusCode) { if (type == null) diff --git a/src/Microsoft.AspNetCore.Mvc.Core/RequireHttpsAttribute.cs b/src/Microsoft.AspNetCore.Mvc.Core/RequireHttpsAttribute.cs index 0cd41aae71..bcfa5673a9 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/RequireHttpsAttribute.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/RequireHttpsAttribute.cs @@ -9,11 +9,23 @@ using Microsoft.Extensions.Options; namespace Microsoft.AspNetCore.Mvc { + /// + /// An authorization filter that confirms requests are received over HTTPS. + /// [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = false)] public class RequireHttpsAttribute : Attribute, IAuthorizationFilter, IOrderedFilter { + /// public int Order { get; set; } + /// + /// Called early in the filter pipeline to confirm request is authorized. Confirms requests are received over + /// HTTPS. Takes no action for HTTPS requests. Otherwise if it was a GET request, sets + /// to a result which will redirect the client to the HTTPS + /// version of the request URI. Otherwise, sets to a result + /// which will set the status code to 403 (Forbidden). + /// + /// public virtual void OnAuthorization(AuthorizationFilterContext filterContext) { if (filterContext == null) @@ -27,6 +39,17 @@ namespace Microsoft.AspNetCore.Mvc } } + /// + /// Called from if the request is not received over HTTPS. Expectation is + /// will not be null after this method returns. + /// + /// The to update. + /// + /// If it was a GET request, default implementation sets to a + /// result which will redirect the client to the HTTPS version of the request URI. Otherwise, default + /// implementation sets to a result which will set the status + /// code to 403 (Forbidden). + /// protected virtual void HandleNonHttpsRequest(AuthorizationFilterContext filterContext) { // only redirect for GET requests, otherwise the browser might not propagate the verb and request @@ -52,7 +75,7 @@ namespace Microsoft.AspNetCore.Mvc // clear the port host = new HostString(host.Host); } - + var newUrl = string.Concat( "https://", host.ToUriComponent(), diff --git a/src/Microsoft.AspNetCore.Mvc.Core/ResponseCacheAttribute.cs b/src/Microsoft.AspNetCore.Mvc.Core/ResponseCacheAttribute.cs index 06d47de57e..9bddb6a66b 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/ResponseCacheAttribute.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/ResponseCacheAttribute.cs @@ -88,6 +88,7 @@ namespace Microsoft.AspNetCore.Mvc /// public bool IsReusable => true; + /// public IFilterMetadata CreateInstance(IServiceProvider serviceProvider) { if (serviceProvider == null) diff --git a/src/Microsoft.AspNetCore.Mvc.Core/ServiceFilterAttribute.cs b/src/Microsoft.AspNetCore.Mvc.Core/ServiceFilterAttribute.cs index 0d78bf4628..525d1a82bb 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/ServiceFilterAttribute.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/ServiceFilterAttribute.cs @@ -9,10 +9,26 @@ using Microsoft.Extensions.DependencyInjection; namespace Microsoft.AspNetCore.Mvc { + /// + /// A filter that finds another filter in an . + /// + /// + /// + /// Primarily used in calls. + /// + /// + /// Similar to the in that both use constructor injection. Use + /// instead if the filter is not itself a service. + /// + /// [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)] [DebuggerDisplay("ServiceFilter: Type={ServiceType} Order={Order}")] public class ServiceFilterAttribute : Attribute, IFilterFactory, IOrderedFilter { + /// + /// Instantiates a new instance. + /// + /// The of filter to find. public ServiceFilterAttribute(Type type) { if (type == null) @@ -26,11 +42,15 @@ namespace Microsoft.AspNetCore.Mvc /// public int Order { get; set; } - public Type ServiceType { get; private set; } + /// + /// Gets the of filter to find. + /// + public Type ServiceType { get; } /// public bool IsReusable { get; set; } + /// public IFilterMetadata CreateInstance(IServiceProvider serviceProvider) { if (serviceProvider == null) diff --git a/src/Microsoft.AspNetCore.Mvc.Core/TypeFilterAttribute.cs b/src/Microsoft.AspNetCore.Mvc.Core/TypeFilterAttribute.cs index 41e34593a0..bc5c19802f 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/TypeFilterAttribute.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/TypeFilterAttribute.cs @@ -9,12 +9,29 @@ using Microsoft.Extensions.DependencyInjection; namespace Microsoft.AspNetCore.Mvc { + /// + /// A filter that creates another filter of type , retrieving missing constructor + /// arguments from dependency injection if available there. + /// + /// + /// + /// Primarily used in calls. + /// + /// + /// Similar to the in that both use constructor injection. Use + /// instead if the filter is itself a service. + /// + /// [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)] [DebuggerDisplay("TypeFilter: Type={ImplementationType} Order={Order}")] public class TypeFilterAttribute : Attribute, IFilterFactory, IOrderedFilter { private ObjectFactory _factory; + /// + /// Instantiates a new instance. + /// + /// The of filter to create. public TypeFilterAttribute(Type type) { if (type == null) @@ -25,9 +42,19 @@ namespace Microsoft.AspNetCore.Mvc ImplementationType = type; } + /// + /// Gets or sets the non-service arguments to pass to the constructor. + /// + /// + /// Service arguments are found in the dependency injection container i.e. this filter supports constructor + /// injection in addition to passing the given . + /// public object[] Arguments { get; set; } - public Type ImplementationType { get; private set; } + /// + /// Gets the of filter to create. + /// + public Type ImplementationType { get; } /// public int Order { get; set; } @@ -35,6 +62,7 @@ namespace Microsoft.AspNetCore.Mvc /// public bool IsReusable { get; set; } + /// public IFilterMetadata CreateInstance(IServiceProvider serviceProvider) { if (serviceProvider == null) diff --git a/src/Microsoft.AspNetCore.Mvc.Cors/CorsAuthorizationFilter.cs b/src/Microsoft.AspNetCore.Mvc.Cors/CorsAuthorizationFilter.cs index 62b7b24de0..793e9945d6 100644 --- a/src/Microsoft.AspNetCore.Mvc.Cors/CorsAuthorizationFilter.cs +++ b/src/Microsoft.AspNetCore.Mvc.Cors/CorsAuthorizationFilter.cs @@ -14,7 +14,7 @@ using Microsoft.Extensions.Primitives; namespace Microsoft.AspNetCore.Mvc.Cors { /// - /// A filter which applies the given and adds appropriate response headers. + /// A filter that applies the given and adds appropriate response headers. /// public class CorsAuthorizationFilter : ICorsAuthorizationFilter { @@ -90,7 +90,7 @@ namespace Microsoft.AspNetCore.Mvc.Cors private bool IsClosestToAction(IEnumerable filters) { - // If there are multiple ICorsAuthorizationFilter which are defined at the class and + // If there are multiple ICorsAuthorizationFilter that are defined at the class and // at the action level, the one closest to the action overrides the others. // Since filterdescriptor collection is ordered (the last filter is the one closest to the action), // we apply this constraint only if there is no ICorsAuthorizationFilter after this. diff --git a/src/Microsoft.AspNetCore.Mvc.Cors/Internal/CorsAuthorizationFilterFactory.cs b/src/Microsoft.AspNetCore.Mvc.Cors/Internal/CorsAuthorizationFilterFactory.cs index 0a7061f60d..b2557fe667 100644 --- a/src/Microsoft.AspNetCore.Mvc.Cors/Internal/CorsAuthorizationFilterFactory.cs +++ b/src/Microsoft.AspNetCore.Mvc.Cors/Internal/CorsAuthorizationFilterFactory.cs @@ -37,6 +37,7 @@ namespace Microsoft.AspNetCore.Mvc.Cors.Internal /// public bool IsReusable => true; + /// public IFilterMetadata CreateInstance(IServiceProvider serviceProvider) { if (serviceProvider == null) diff --git a/src/Microsoft.AspNetCore.Mvc.Cors/Internal/ICorsAuthorizationFilter.cs b/src/Microsoft.AspNetCore.Mvc.Cors/Internal/ICorsAuthorizationFilter.cs index a35d974d7e..6989ffd421 100644 --- a/src/Microsoft.AspNetCore.Mvc.Cors/Internal/ICorsAuthorizationFilter.cs +++ b/src/Microsoft.AspNetCore.Mvc.Cors/Internal/ICorsAuthorizationFilter.cs @@ -6,7 +6,7 @@ using Microsoft.AspNetCore.Mvc.Filters; namespace Microsoft.AspNetCore.Mvc.Cors.Internal { /// - /// A filter which can be used to enable/disable cors support for a resource. + /// A filter that can be used to enable/disable CORS support for a resource. /// public interface ICorsAuthorizationFilter : IAsyncAuthorizationFilter, IOrderedFilter { diff --git a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/IgnoreAntiforgeryTokenAttribute.cs b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/IgnoreAntiforgeryTokenAttribute.cs index 96cec9eb5b..f44cd1127b 100644 --- a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/IgnoreAntiforgeryTokenAttribute.cs +++ b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/IgnoreAntiforgeryTokenAttribute.cs @@ -8,7 +8,7 @@ using Microsoft.AspNetCore.Mvc.ViewFeatures; namespace Microsoft.AspNetCore.Mvc { /// - /// An attribute which skips antiforgery token validation. + /// An filter that skips antiforgery token validation. /// [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)] public class IgnoreAntiforgeryTokenAttribute : Attribute, IAntiforgeryPolicy, IOrderedFilter diff --git a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Internal/SaveTempDataFilter.cs b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Internal/SaveTempDataFilter.cs index 1ee9539bff..282976777e 100644 --- a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Internal/SaveTempDataFilter.cs +++ b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Internal/SaveTempDataFilter.cs @@ -6,7 +6,7 @@ using Microsoft.AspNetCore.Mvc.Filters; namespace Microsoft.AspNetCore.Mvc.ViewFeatures.Internal { /// - /// A filter which saves temp data. + /// A filter that saves temp data. /// public class SaveTempDataFilter : IResourceFilter, IResultFilter { diff --git a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/SkipStatusCodePagesAttribute.cs b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/SkipStatusCodePagesAttribute.cs index 5c10404666..bfc644764f 100644 --- a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/SkipStatusCodePagesAttribute.cs +++ b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/SkipStatusCodePagesAttribute.cs @@ -3,13 +3,12 @@ using System; using Microsoft.AspNetCore.Diagnostics; -using Microsoft.AspNetCore.Http.Features; using Microsoft.AspNetCore.Mvc.Filters; namespace Microsoft.AspNetCore.Mvc { /// - /// Filter to prevent StatusCodePages middleware to handle responses. + /// A filter that prevents execution of the StatusCodePages middleware. /// [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)] public class SkipStatusCodePagesAttribute : Attribute, IResourceFilter diff --git a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ValidateAntiForgeryTokenAttribute.cs b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ValidateAntiForgeryTokenAttribute.cs index 65d722eeff..938f9c160d 100644 --- a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ValidateAntiForgeryTokenAttribute.cs +++ b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ValidateAntiForgeryTokenAttribute.cs @@ -14,7 +14,8 @@ namespace Microsoft.AspNetCore.Mvc /// and the action method will not execute. /// /// - /// This attribute helps defend against cross-site request forgery. It won't prevent other forgery or tampering attacks. + /// This attribute helps defend against cross-site request forgery. It won't prevent other forgery or tampering + /// attacks. /// [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)] public class ValidateAntiForgeryTokenAttribute : Attribute, IFilterFactory, IOrderedFilter @@ -25,6 +26,7 @@ namespace Microsoft.AspNetCore.Mvc /// public bool IsReusable => true; + /// public IFilterMetadata CreateInstance(IServiceProvider serviceProvider) { return serviceProvider.GetRequiredService(); diff --git a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewFeatures/SaveTempDataAttribute.cs b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewFeatures/SaveTempDataAttribute.cs index b2769c44dc..a9c2b53ec7 100644 --- a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewFeatures/SaveTempDataAttribute.cs +++ b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewFeatures/SaveTempDataAttribute.cs @@ -9,7 +9,7 @@ using Microsoft.Extensions.DependencyInjection; namespace Microsoft.AspNetCore.Mvc.ViewFeatures { /// - /// Adds a filter which will save the for a request. + /// A filter that saves the for a request. /// [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)] public class SaveTempDataAttribute : Attribute, IFilterFactory, IOrderedFilter diff --git a/src/Microsoft.AspNetCore.Mvc.WebApiCompatShim/HttpResponseExceptionActionFilter.cs b/src/Microsoft.AspNetCore.Mvc.WebApiCompatShim/HttpResponseExceptionActionFilter.cs index bf166d6e9a..d214ee63b0 100644 --- a/src/Microsoft.AspNetCore.Mvc.WebApiCompatShim/HttpResponseExceptionActionFilter.cs +++ b/src/Microsoft.AspNetCore.Mvc.WebApiCompatShim/HttpResponseExceptionActionFilter.cs @@ -9,19 +9,22 @@ using Microsoft.AspNetCore.Mvc.Filters; namespace Microsoft.AspNetCore.Mvc.WebApiCompatShim { /// - /// An action filter which sets to an + /// An action filter that sets to an /// if the exception type is . /// This filter runs immediately after the action. /// public class HttpResponseExceptionActionFilter : IActionFilter, IOrderedFilter { + /// // Return a high number by default so that it runs closest to the action. public int Order { get; set; } = int.MaxValue - 10; + /// public void OnActionExecuting(ActionExecutingContext context) { } + /// public void OnActionExecuted(ActionExecutedContext context) { if (context == null)