Sprog

RouteHandlerTypeAttribute Class

Definition

Declares the handler delegate type that a route attribute expects an attributed method to match.

[System.AttributeUsage(System.AttributeTargets.Class, AllowMultiple=true, Inherited=true)]
public sealed class RouteHandlerTypeAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Class, AllowMultiple=true, Inherited=true)>]
type RouteHandlerTypeAttribute = class
    inherit Attribute
Public NotInheritable Class RouteHandlerTypeAttribute
Inherits Attribute
Inheritance
RouteHandlerTypeAttribute
Attributes

Remarks

Apply this attribute to a route attribute class (a class implementing IRouteAttribute) to declare the delegate type (for example RouteHandler, HandoffHandler, or FeedbackLoopHandler) that decorated methods are bound to at runtime.

The handler type is recorded as an attribute argument so that it is preserved in compiled metadata. This allows a Roslyn analyzer running in a consuming project to read the expected handler delegate (which is not possible from a property getter body across an assembly boundary) and validate that the signature of each decorated method matches the delegate's Invoke signature.

The attribute may be applied more than once to declare several acceptable handler delegates; a method is considered valid if it matches any of them. A declared unbound generic delegate (for example typeof(FetchHandler<>)) is not statically validated and is skipped by the analyzer, because the closed type is inferred from the decorated method at runtime.

Constructors

Name Description
RouteHandlerTypeAttribute(Type)

Declares the handler delegate type that a route attribute expects an attributed method to match.

Properties

Name Description
HandlerType

Gets the delegate Type that decorated methods are expected to match.

Applies to