Class Extensions
Collection of extensions used by MonoMod and other projects.
public static class Extensions
- Inheritance
-
Extensions
Methods
- AddRange<TKey, TValue>(Dictionary<TKey, TValue>, Dictionary<TKey, TValue>)
- See AddRange(IEnumerable<T>)
- AddRange<TKey, TValue>(IDictionary<TKey, TValue>, IDictionary<TKey, TValue>)
- See AddRange(IEnumerable<T>)
- CastDelegate(Delegate?, Type)
- Cast a delegate from one type to another. Compatible with delegates holding an invocation list (combined delegates).
- CastDelegate<T>(Delegate)
- Cast a delegate from one type to another. Compatible with delegates holding an invocation list (combined delegates).
- Clone(MethodBody?, MethodDefinition)
- Clone the given method body.
- Clone(CustomAttribute)
- Clone the given custom attribute.
- Clone(GenericParameter)
- Clone the given generic parameter.
- Clone(MethodDefinition?, MethodDefinition?)
- Clone the given method definition.
- Clone(ParameterDefinition)
- Clone the given parameter definition.
- CreateDelegate(MethodBase, Type)
- Creates a delegate of the specified type from this method.
- CreateDelegate(MethodBase, Type, object?)
- Creates a delegate of the specified type with the specified target from this method.
- CreateDelegate<T>(MethodBase)
- Creates a delegate of the specified type from this method.
- CreateDelegate<T>(MethodBase, object?)
- Creates a delegate of the specified type with the specified target from this method.
- FindEvent(TypeDefinition, string)
- Find an event for a given name.
- FindEventDeep(TypeDefinition, string)
- Find an event for a given name recursively (including the passed type's base types).
- FindField(TypeDefinition, string)
- Find a field for a given name.
- FindFieldDeep(TypeDefinition, string)
- Find a field for a given name recursively (including the passed type's base types).
- FindMethod(TypeDefinition, string, bool)
- Find a method for a given ID.
- FindMethod(Type, string, bool)
- Find a method for a given ID.
- FindMethodDeep(TypeDefinition, string, bool)
- Find a method for a given ID recursively (including the passed type's base types).
- FindMethodDeep(Type, string, bool)
- Find a method for a given ID recursively (including the passed type's base types).
- FindProperty(TypeDefinition, string)
- Find a property for a given name.
- FindPropertyDeep(TypeDefinition, string)
- Find a property for a given name recursively (including the passed type's base types).
- FixShortLongOps(MethodDefinition)
- Fix (and optimize) any instructions which should use the long / short form opcodes instead.
- GetActualGenericMethodDefinition(MethodInfo)
- Gets the actual generic method definition of a method, as defined on the fully open type.
- GetCustomAttribute(ICustomAttributeProvider, string)
- Get a certain custom attribute from an attribute provider.
- GetID(CallSite)
- Get a reference ID that is similar to the full name, but consistent between System.Reflection and Mono.Cecil.
- GetID(MethodReference, string?, string?, bool, bool)
- Get a reference ID that is similar to the full name, but consistent between System.Reflection and Mono.Cecil.
- GetID(MethodBase, string?, string?, bool, bool, bool)
- Get a reference ID that is similar to the full name, but consistent between System.Reflection and Mono.Cecil.
- GetInt(Instruction)
- Get the integer value pushed onto the stack with this instruction.
- GetIntOrNull(Instruction)
- Get the integer value pushed onto the stack with this instruction.
- GetLdftnPointer(MethodBase)
- Get a native function pointer for a given method. This matches an IL-level ldftn.
- GetManagedSize(Type)
- Get the managed size of a given type. This matches an IL-level sizeof(t), even if it cannot be determined normally in C#.
Note that
sizeof(t) != Marshal.SizeOf(t)
, f.e. when t is char.
- GetPatchFullName(MemberReference)
- Get the "patch name" - the name of the target to patch - for the given member.
- GetPatchName(MemberReference)
- Get the "patch name" - the name of the target to patch - for the given member.
- GetStateMachineTarget(MethodInfo)
- Get the method of interest for a given state machine method.
- GetThisParamType(MethodBase)
- Get a type which matches what the method should receive via ldarg.0
- HasCustomAttribute(ICustomAttributeProvider, string)
- Determine if an attribute provider has got a specific custom attribute.
- InvokePassing<T>(MulticastDelegate, T, params object?[])
- Invokes all delegates in the invocation list, passing on the result to the next.
- InvokeWhileFalse(MulticastDelegate, params object[])
- Invokes all delegates in the invocation list, as long as the previously invoked delegate returns false.
- InvokeWhileNull<T>(MulticastDelegate?, params object[])
- Invokes all delegates in the invocation list, as long as the previously invoked delegate returns null.
- InvokeWhileTrue(MulticastDelegate, params object[])
- Invokes all delegates in the invocation list, as long as the previously invoked delegate returns true.
- Is(MemberReference?, MemberInfo?)
- Check if the signatures of a given System.Reflection and Mono.Cecil member reference match.
- Is(MemberInfo?, MemberReference?)
- Check if the signatures of a given System.Reflection and Mono.Cecil member reference match.
- IsBaseMethodCall(MethodBody, MethodReference?)
- Determine if the method call is a base method call.
- IsCallvirt(MethodReference)
- Determine if the given method can be preferably called using callvirt.
- IsCompatible(Type, Type)
- Determine if two types are compatible with each other (f.e. object with string, or enums with their underlying integer type).
- IsStruct(TypeReference)
- Determine if the given type is a struct (also known as "value type") or struct-alike (f.e. primitive).
- ReadNullTerminatedString(BinaryReader)
- Read the string from the BinaryReader BinaryWriter in a C-friendly format.
- RecalculateILOffsets(MethodDefinition)
- Calculate updated instruction offsets. Required for certain manual fixes.
- Relink(CallSite, Relinker, IGenericParameterProvider)
- Relink the given callsite.
- Relink(CustomAttribute, Relinker, IGenericParameterProvider)
- Relink the given custom attribute.
- Relink(FieldReference, Relinker, IGenericParameterProvider)
- Relink the given field reference.
- Relink(GenericParameter, Relinker, IGenericParameterProvider)
- Relink the given generic parameter reference.
- Relink(GenericParameterConstraint?, Relinker, IGenericParameterProvider)
- Relink the given type reference.
- Relink(IMetadataTokenProvider?, Relinker, IGenericParameterProvider)
- Relink the given member reference (metadata token provider).
- Relink(MethodReference, Relinker, IGenericParameterProvider)
- Relink the given method reference.
- Relink(ParameterDefinition, Relinker, IGenericParameterProvider)
- Relink the given parameter definition.
- Relink(TypeReference?, Relinker, IGenericParameterProvider?)
- Relink the given type reference.
- ResolveGenericParameter(IGenericParameterProvider, GenericParameter)
- Resolve a given generic parameter in another context.
- SafeResolve(FieldReference?)
- Safely resolve a reference, silently discarding any exceptions.
- SafeResolve(MethodReference?)
- Safely resolve a reference, silently discarding any exceptions.
- SafeResolve(PropertyReference?)
- Safely resolve a reference, silently discarding any exceptions.
- SafeResolve(TypeReference?)
- Safely resolve a reference, silently discarding any exceptions.
- SpacedPascalCase(string)
- Split PascalCase words to become Pascal Case instead.
- ToHexadecimalString(byte[])
- Create a hexadecimal string for the given bytes.
- ToLongOp(OpCode)
- Get the long form opcode for any short form opcode.
- ToShortOp(OpCode)
- Get the short form opcode for any long form opcode.
- Update(GenericParameter, int, GenericParameterType)
- Force-update a generic parameter's position and type.
- WriteNullTerminatedString(BinaryWriter, string)
- Write the string to the BinaryWriter in a C-friendly format.