Table of Contents

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 ResultType, and persists Name as the runtime hook-point identity.

The ResultType must be a readonly partial record struct decorated with 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
Inheritance
HookAttribute
Inherited Members

Examples

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

Constructors

HookAttribute(string, Type)

public HookAttribute(string name, Type resultType)

Parameters

name string
resultType Type

Properties

Name

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

public string Name { get; }

Property Value

string

ResultType

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

public Type ResultType { get; }

Property Value

Type