Skip to content

3. Extensions

Venomaus edited this page Aug 23, 2024 · 7 revisions

Here you will find an overview of all lib extension implementations.

These can all be accessed by including the namespace: SOD.Common.Extensions

EnumerableExtensions

Contains various extension methods for the System.Collections.Generic namespace, few examples are IEnumerable, List, IList, etc..

Methods (normal):

  • ForEach(action): Runs a foreach loop and executes the action on each element
  • ToListIl2Cpp(): Converts to an Il2Cpp list

Methods (il2cpp):

  • Select(lambda): Selects a property from a lambda
  • Where(lambda): Returns elements that match the lambda criteria
  • Any(lambda): Returns true/false if any of the elements match with the lambda criteria
  • All(lambda): Returns true/false if all of the elements match with the lambda criteria
  • ForEach(action): Runs a foreach loop and executes the action on each element
  • ToList(): Converts to a normal list

LogExtensions

Contains various extension methods for the BepinEx ManualLogSource (accessed through Plugin.Log)

Methods:

  • LogMethodEntry(classType, methodName): Prints info 'Method entry "className_methodName".'
  • LogMethodExit(classType, methodName): Prints info 'Method exit "className_methodName".'

TypeExtensions

Contains various extension methods for types, il2cpp types etc..

Methods:

  • IsAssignableFrom(Il2CppSystem.Object object, Type type): Returns true if the type is in the base types of the il2cpp object
  • GetFnvHashCode(string value): Returns a deterministic hashcode using FNV hashing.
  • TryCast: An extension on object type, attempts to try cast an object to something for il2cpp.

BepInExExtensions

Contains helper methods that interact with bepinex objects.

Methods:

  • Bind(object defaultValue, string section, string key, string description): A non generic bind function.
Clone this wiki locally