Table of Contents

Class ServerExtensionAttribute

Namespace
DotBoxD.Abstractions
Assembly
DotBoxD.Abstractions.dll

Marks a class as a server extension: a batch operation the plugin ships as verified IR and the server runs request/response in a single roundtrip, so a loop over many entities executes server-side (calling the host's existing bindings) instead of one network call per entity. The generator lowers the class's single public batch method — its body may use locals, a foreach over a list parameter, host bindings via ctx.Host<T>() or constructor-injected service fields, and may build and return complex objects (records/DTOs) and lists of them. For example:

[ServerExtension("monster-killer", typeof(IMonsterKillerService))]
public sealed partial class MonsterKillerKernel
{
    private readonly IGameWorld _world;
    public MonsterKillerKernel(IGameWorld world) => _world = world;

    public List<KillResult> KillMonsters(List<int> monsterIds, HookContext ctx)
    {
        var results = new List<KillResult>();
        foreach (var id in monsterIds)
            results.Add(new KillResult(id, _world.Kill(id)));
        return results;
    }
}
public readonly record struct KillResult(int MonsterId, bool Success);

The trailing HookContext parameter is the lowering marker for host bindings (as in a kernel's Handle) and is not part of the wire signature. Parameters, return type, and DTO fields must use the supported scalar types, lists, or nested DTOs. Supplying the optional service interface type lets the analyzer emit a source-generated plugin-side client that marshals directly to compact server-extension value bytes instead of using a reflection proxy.

[AttributeUsage(AttributeTargets.Class, Inherited = false)]
public sealed class ServerExtensionAttribute : Attribute
Inheritance
ServerExtensionAttribute
Inherited Members

Constructors

ServerExtensionAttribute(string)

public ServerExtensionAttribute(string id)

Parameters

id string

ServerExtensionAttribute(string, Type)

public ServerExtensionAttribute(string id, Type serviceType)

Parameters

id string
serviceType Type

ServerExtensionAttribute(Type, string?)

public ServerExtensionAttribute(Type grafts, string? id = null)

Parameters

grafts Type
id string

Properties

Grafts

public Type? Grafts { get; }

Property Value

Type

Id

public string? Id { get; }

Property Value

string

ServiceType

public Type? ServiceType { get; }

Property Value

Type