Browse documentation

Class SymbolExtensions

Namespace
HarmonyLib
Assembly
0Harmony.dll

A helper class to retrieve reflection info for non-private methods, fields and properties

public static class SymbolExtensions
Inheritance
object
SymbolExtensions

Methods

GetFieldInfo(LambdaExpression)

Given a lambda expression that accesses a field, returns the field info

public static FieldInfo GetFieldInfo(LambdaExpression expression)

Parameters

expression LambdaExpression

The lambda expression using the field

Returns

FieldInfo

The field in the lambda expression

GetFieldInfo<T>(Expression<Func<T>>)

Given a lambda expression that accesses a field, returns the field info

public static FieldInfo GetFieldInfo<T>(Expression<Func<T>> expression)

Parameters

expression Expression<Func<T>>

The lambda expression using the field

Returns

FieldInfo

The field in the lambda expression

Type Parameters

T

The generic field type

GetMethodInfo(Expression<Action>)

Given a lambda expression that calls a method, returns the method info

public static MethodInfo GetMethodInfo(Expression<Action> expression)

Parameters

expression Expression<Action>

The lambda expression using the method

Returns

MethodInfo

The method in the lambda expression

GetMethodInfo(LambdaExpression)

Given a lambda expression that calls a method, returns the method info

public static MethodInfo GetMethodInfo(LambdaExpression expression)

Parameters

expression LambdaExpression

The lambda expression using the method

Returns

MethodInfo

The method in the lambda expression

GetMethodInfo<T>(Expression<Action<T>>)

Given a lambda expression that calls a method, returns the method info

public static MethodInfo GetMethodInfo<T>(Expression<Action<T>> expression)

Parameters

expression Expression<Action<T>>

The lambda expression using the method

Returns

MethodInfo

The method in the lambda expression

Type Parameters

T

The generic type

GetMethodInfo<T, TResult>(Expression<Func<T, TResult>>)

Given a lambda expression that calls a method, returns the method info

public static MethodInfo GetMethodInfo<T, TResult>(Expression<Func<T, TResult>> expression)

Parameters

expression Expression<Func<T, TResult>>

The lambda expression using the method

Returns

MethodInfo

The method in the lambda expression

Type Parameters

T

The generic type

TResult

The generic result type

GetPropertyInfo(LambdaExpression)

Given a lambda expression that reads a property, returns the property info

public static PropertyInfo GetPropertyInfo(LambdaExpression expression)

Parameters

expression LambdaExpression

The lambda expression reading the property

Returns

PropertyInfo

The property in the lambda expression

Exceptions

ArgumentNullException

The expression is null

ArgumentException

The expression does not read a property. Indexers are not supported.

GetPropertyInfo<T>(Expression<Func<T>>)

Given a lambda expression that reads a property, returns the property info

public static PropertyInfo GetPropertyInfo<T>(Expression<Func<T>> expression)

Parameters

expression Expression<Func<T>>

The lambda expression reading the property, for example () => default(MyClass).MyProperty

Returns

PropertyInfo

The property in the lambda expression

Type Parameters

T

The generic property type

Exceptions

ArgumentNullException

The expression is null

ArgumentException

The expression does not read a property. Indexers are not supported.

Harmony 3

For Harmony 2, read the 2.x documentation.