Skip to content
Zetrith edited this page Aug 12, 2021 · 8 revisions

The mod adds a Hot Swap button to the ingame dev mode. After clicking it, all mod assembly files are searched for types with an attribute [HotSwappable]. The code of the methods within these types is then checked for differences and if needed replaced with the code found on disk.

The attribute is searched by name, so you can just create your own one and not have to add any dependencies. The attribute is searched for every time you perform a hot swap so it can be added during runtime.

Here's the code for the attribute:

[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct)]
public class HotSwappableAttribute : Attribute
{
}

Note that hotswapping generic methods and methods in generic types is not supported as the Harmony library used for code generation currently doesn't fully support generics either.

Also, adding new fields/methods/types is currently not supported though that might change in the future. Lambdas count as methods and adding new ones isn't currently supported (existing ones are editable though, as long as you don't capture any new variables).

Very small methods might not be hotswappable due to inlining.

Clone this wiki locally