s&box uses C# attributes extensively to declare intent to the engine and editor. Many of these attributes trigger theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Facepunch/sbox-public/llms.txt
Use this file to discover all available pages before exploring further.
Sandbox.Generator Roslyn source generator, which rewrites method and property bodies at compile time to inject networking, console variable, and other cross-cutting behaviours.
Editor attributes
[Property]
Marks a property or field for display and editing in the Inspector panel. The editor reads this attribute to know what to show, serialize, and hot-reload.
PropertyAttribute accepts an internal name (lowercase, no spaces) and a Title for the UI label. If omitted, the editor auto-generates both from the C# identifier.
Additional display attributes that work alongside [Property]:
| Attribute | Purpose |
|---|---|
[KeyProperty] | Marks the single property that represents the whole object in a collapsed row |
[InlineEditor] | Forces the editor to expand the property inline rather than behind a popup |
[Advanced] | Hides the property unless the user enables Advanced mode |
Networking attributes
[Sync]
Automatically synchronises a component property from its owner to all other clients. The code generator wraps the property getter and setter with __sync_GetValue / __sync_SetValue intercepts.
SyncFlags lets you customise the direction and polling behaviour:
[HostSync]
Previously used to replicate a property from the host to all clients. It is now a thin wrapper over SyncAttribute:
RPC attributes
Remote procedure calls (RPCs) let you invoke methods across the network. All RPC variants inherit fromRpcAttribute and use the code generator to intercept calls.
Console attributes
[ConVar]
Exposes a static property as a console variable. The code generator wraps get/set with ConsoleSystem.OnWrappedGet / ConsoleSystem.OnWrappedSet.
ConVarFlags values include Saved, Replicated, Cheat, UserInfo, Hidden, ChangeNotice, Protected, Server, Admin, and GameSetting.
[ConCmd]
Marks a static method as a console command. It inherits from ConVarAttribute and supports the same flags.
Code generation
[CodeGenerator]
CodeGeneratorAttribute is a meta-attribute — you apply it to your own custom Attribute class to tell the source generator what transformation to perform whenever that attribute is used on a method or property.
CodeGeneratorFlags
Writing a custom code-generated attribute
The pattern is: create anAttribute class, decorate it with one or more [CodeGenerator] calls, then apply your attribute to methods or properties.
Sandbox.Generator) processes every syntax tree in your compilation in parallel via Processor.Run, then applies IL hot reload detection through ILHotloadProcessor.
Higher-priority
[CodeGenerator] attributes wrap the target first, so they are the outermost wrapper in the call chain. The default priority is 0.