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
-
objectSymbolExtensions
Methods
GetFieldInfo(LambdaExpression)
Given a lambda expression that accesses a field, returns the field info
public static FieldInfo GetFieldInfo(LambdaExpression expression)
Parameters
expressionLambdaExpressionThe 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
expressionExpression<Func<T>>The lambda expression using the field
Returns
- FieldInfo
The field in the lambda expression
Type Parameters
TThe 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
expressionExpression<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
expressionLambdaExpressionThe 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
expressionExpression<Action<T>>The lambda expression using the method
Returns
- MethodInfo
The method in the lambda expression
Type Parameters
TThe 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
expressionExpression<Func<T, TResult>>The lambda expression using the method
Returns
- MethodInfo
The method in the lambda expression
Type Parameters
TThe generic type
TResultThe generic result type
GetPropertyInfo(LambdaExpression)
Given a lambda expression that reads a property, returns the property info
public static PropertyInfo GetPropertyInfo(LambdaExpression expression)
Parameters
expressionLambdaExpressionThe 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
expressionExpression<Func<T>>The lambda expression reading the property, for example
() => default(MyClass).MyProperty
Returns
- PropertyInfo
The property in the lambda expression
Type Parameters
TThe generic property type
Exceptions
- ArgumentNullException
The expression is null
- ArgumentException
The expression does not read a property. Indexers are not supported.