Skip to content

Class HookAttribute

Namespace: DotBoxD.Abstractions
Assembly: DotBoxD.Abstractions.dll

Associates a hook context type with a stable hook name and exactly one result type, so context.Server.Hooks.On<TContext>() can resolve the result type from the context alone (rather than requiring a second generic argument at the call site). The analyzer reads this attribute to validate that a .Register(…) / .RegisterLocal(…) terminal produces DotBoxD.Abstractions.HookAttribute.ResultType, and persists DotBoxD.Abstractions.HookAttribute.Name as the runtime hook-point identity.

The `DotBoxD.Abstractions.HookAttribute.ResultType` must be a readonly partial record struct decorated with `DotBoxD.Abstractions.HookResultAttribute` that declares a bool Success and a string? Reason field (see that attribute for the contract).

[AttributeUsage(AttributeTargets.Class|AttributeTargets.Struct, Inherited = false)]
public sealed class HookAttribute : Attribute

objectAttributeHookAttribute

Attribute.Equals(object?), Attribute.GetCustomAttribute(Assembly, Type), Attribute.GetCustomAttribute(Assembly, Type, bool), Attribute.GetCustomAttribute(MemberInfo, Type), Attribute.GetCustomAttribute(MemberInfo, Type, bool), Attribute.GetCustomAttribute(Module, Type), Attribute.GetCustomAttribute(Module, Type, bool), Attribute.GetCustomAttribute(ParameterInfo, Type), Attribute.GetCustomAttribute(ParameterInfo, Type, bool), Attribute.GetCustomAttributes(Assembly), Attribute.GetCustomAttributes(Assembly, bool), Attribute.GetCustomAttributes(Assembly, Type), Attribute.GetCustomAttributes(Assembly, Type, bool), Attribute.GetCustomAttributes(MemberInfo), Attribute.GetCustomAttributes(MemberInfo, bool), Attribute.GetCustomAttributes(MemberInfo, Type), Attribute.GetCustomAttributes(MemberInfo, Type, bool), Attribute.GetCustomAttributes(Module), Attribute.GetCustomAttributes(Module, bool), Attribute.GetCustomAttributes(Module, Type), Attribute.GetCustomAttributes(Module, Type, bool), Attribute.GetCustomAttributes(ParameterInfo), Attribute.GetCustomAttributes(ParameterInfo, bool), Attribute.GetCustomAttributes(ParameterInfo, Type), Attribute.GetCustomAttributes(ParameterInfo, Type, bool), Attribute.GetHashCode(), Attribute.IsDefaultAttribute(), Attribute.IsDefined(Assembly, Type), Attribute.IsDefined(Assembly, Type, bool), Attribute.IsDefined(MemberInfo, Type), Attribute.IsDefined(MemberInfo, Type, bool), Attribute.IsDefined(Module, Type), Attribute.IsDefined(Module, Type, bool), Attribute.IsDefined(ParameterInfo, Type), Attribute.IsDefined(ParameterInfo, Type, bool), Attribute.Match(object?), Attribute.TypeId, object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.ReferenceEquals(object?, object?), object.ToString()

[Hook("combat.damage", typeof(CombatDamageResult))]
public sealed record CombatDamageContext(Combatant? Attacker, Combatant Victim, int Damage);
public HookAttribute(string name, Type resultType)

name string

resultType Type

The stable hook-point name (e.g. combat.damage) persisted into the manifest.

public string Name { get; }

string

The single result type a hook on this context produces — a DotBoxD.Abstractions.HookResultAttribute DTO.

public Type ResultType { get; }

Type