Class Patcher
- Namespace
- Concord
- Assembly
- Concord.Orchestration.dll
The high-level entry point for applying Concord patches. Wraps the scan + compose + detour-apply pipeline so mod authors apply an assembly's PatchAttribute declarations, or a single explicit patch, with one call and revert by disposing the returned IPatchHandle.
public static class Patcher
- Inheritance
-
Patcher
- Inherited Members
Methods
Apply(Assembly)
Applies every PatchAttribute declaration in assembly, composing each
as a detour and registering each declared field as an attached property. Idempotent: a repeated call
with the same assembly returns the same handle without applying twice.
public static IPatchHandle Apply(Assembly assembly)
Parameters
assemblyAssemblyThe assembly whose declarations are applied.
Returns
- IPatchHandle
A handle that reverts every applied detour when disposed.
For(MethodBase)
Creates a fluent PatchBuilder targeting the given method.
public static PatchBuilder For(MethodBase target)
Parameters
targetMethodBaseThe method to patch.
Returns
- PatchBuilder
A PatchBuilder configured for
target.
For(string, string)
Creates a fluent PatchBuilder targeting a method by name on a type resolved by name.
public static PatchBuilder For(string typeName, string method)
Parameters
typeNamestringThe full name of the type that declares the method.
methodstringThe name of the method to target.
Returns
- PatchBuilder
A PatchBuilder configured for the resolved method.
Exceptions
- ConcordDeclarationException
Thrown when the type or method is not found or is ambiguous.
For(string, string, Type[])
Creates a fluent PatchBuilder targeting a method by name on a type resolved by name, disambiguating by parameter types.
public static PatchBuilder For(string typeName, string method, Type[] parameterTypes)
Parameters
typeNamestringThe full name of the type that declares the method.
methodstringThe name of the method to target.
parameterTypesType[]The parameter types used to select a specific overload.
Returns
- PatchBuilder
A PatchBuilder configured for the resolved method.
Exceptions
- ConcordDeclarationException
Thrown when the type or method is not found.
For(Type, string)
Creates a fluent PatchBuilder targeting a method by name on the given type.
public static PatchBuilder For(Type type, string method)
Parameters
Returns
- PatchBuilder
A PatchBuilder configured for the resolved method.
Exceptions
- ConcordDeclarationException
Thrown when the method is not found or is ambiguous.
For(Type, string, Type[])
Creates a fluent PatchBuilder targeting a method by name on the given type, disambiguating by parameter types.
public static PatchBuilder For(Type type, string method, Type[] parameterTypes)
Parameters
typeTypeThe type that declares the method.
methodstringThe name of the method to target.
parameterTypesType[]The parameter types used to select a specific overload.
Returns
- PatchBuilder
A PatchBuilder configured for the resolved method.
Exceptions
- ConcordDeclarationException
Thrown when the method is not found.
ForConstructor(Type, Type[])
Creates a fluent PatchBuilder targeting a specific instance constructor on
type, selected by parameter types.
public static PatchBuilder ForConstructor(Type type, Type[] parameterTypes)
Parameters
typeTypeThe type that declares the constructor.
parameterTypesType[]The parameter types of the constructor to target. Pass an empty array to select the parameterless constructor. Only instance constructors are supported.
Returns
- PatchBuilder
A PatchBuilder configured for the resolved constructor.
Exceptions
- ConcordDeclarationException
Thrown when no matching instance constructor is found.
ForConstructor<T>(Type[])
Creates a fluent PatchBuilder targeting a specific instance constructor on
T, selected by parameter types.
public static PatchBuilder ForConstructor<T>(Type[] parameterTypes)
Parameters
parameterTypesType[]The parameter types of the constructor to target. Pass an empty array to select the parameterless constructor. Only instance constructors are supported.
Returns
- PatchBuilder
A PatchBuilder configured for the resolved constructor.
Type Parameters
TThe type that declares the constructor.
Exceptions
- ConcordDeclarationException
Thrown when no matching instance constructor is found.
For<T>(string)
Creates a fluent PatchBuilder targeting a method by name on T.
public static PatchBuilder For<T>(string method)
Parameters
methodstringThe name of the method to target.
Returns
- PatchBuilder
A PatchBuilder configured for the resolved method.
Type Parameters
TThe type that declares the method.
Exceptions
- ConcordDeclarationException
Thrown when the method is not found or is ambiguous.
For<T>(string, Type[])
Creates a fluent PatchBuilder targeting a method by name on T,
disambiguating by parameter types.
public static PatchBuilder For<T>(string method, Type[] parameterTypes)
Parameters
methodstringThe name of the method to target.
parameterTypesType[]The parameter types used to select a specific overload.
Returns
- PatchBuilder
A PatchBuilder configured for the resolved method.
Type Parameters
TThe type that declares the method.
Exceptions
- ConcordDeclarationException
Thrown when the method is not found.
Patch(MethodBase, MethodBase, At)
Applies a single explicit patch without scanning for attributes: composes
injectionMethod onto target at the given position
(Head, Return, Tail, Around, Transpiler, or TranspilerFinal).
public static IPatchHandle Patch(MethodBase target, MethodBase injectionMethod, At at)
Parameters
targetMethodBaseThe method to patch.
injectionMethodMethodBaseThe injection method supplying the injected body.
atAtThe injection position where the injection method runs relative to the target. Constant and Argument are not reachable through this method: use InjectAttribute for Constant, or build an Injection with an InjectAt.Invoke shifted Argument and apply it via PatchInjection(MethodBase, Injection) for Argument.
Returns
- IPatchHandle
A handle that reverts the applied detour when disposed.
Remarks
The returned handle is retained in a static registry, so the detour stays applied even when the caller discards the handle. Dispose the handle to revert the detour and release it from the registry.
Exceptions
- ConcordEmitException
Thrown with code
CONC116whenatis Constant or Argument, neither of which this method can express.
PatchInjection(MethodBase, Injection)
Applies a single, already-constructed Injection at any position it can express (Head, Return with a specific index, Tail, Around, or Invoke), composing it directly rather than through the simplified At enum used by Patch(MethodBase, MethodBase, At).
public static IPatchHandle PatchInjection(MethodBase target, Injection injection)
Parameters
targetMethodBaseThe method to patch.
injectionInjectionThe injection to compose onto
target.
Returns
- IPatchHandle
A handle that reverts the applied detour when disposed.
Remarks
The returned handle is retained in a static registry, so the detour stays applied even when the caller discards the handle. Dispose the handle to revert the detour and release it from the registry.