namespace Sandbox; /// /// Provides data about a wrapped method in a callback. /// public readonly ref struct WrappedMethod { /// /// Invoke the original method. /// public Action Resume { get; init; } /// /// The object whose method is being wrapped. This will be null if we're wrapping a static method. /// public object Object { get; init; } /// /// Is this a static method? /// public bool IsStatic { get; init; } /// /// The name of the type that the method belongs to. /// public string TypeName { get; init; } /// /// The name of the original method. /// public string MethodName { get; init; } /// /// The Identity of the original method. This is an integer that each MethodDescription has to distinguish itself from other methods of the same class. /// public int MethodIdentity { get; init; } /// /// An array of all attributes decorated with on the original method. /// public Attribute[] Attributes { get; init; } /// /// Get the attribute of type, or null if it doesn't exist /// public U GetAttribute() where U : System.Attribute { for ( int i = 0; i < Attributes.Length; i++ ) { if ( Attributes[i] is U t ) return t; } return default; } } /// /// Provides data about a wrapped method in a callback. /// /// The expected return type for the wrapped method. public readonly struct WrappedMethod { /// /// Invoke the original method. /// public Func Resume { get; init; } /// /// The object whose method is being wrapped. This will be null if we're wrapping a static method. /// public object Object { get; init; } /// /// Is this a static method? /// public bool IsStatic { get; init; } /// /// The name of the type that the method belongs to. /// public string TypeName { get; init; } /// /// The name of the original method. If static, will return the full name including the type. /// public string MethodName { get; init; } /// /// The Identity of the original method. This is an integer that each MethodDescription has to distinguish itself from other methods of the same class. /// public int MethodIdentity { get; init; } /// /// An array of all attributes decorated with on the original method. /// public Attribute[] Attributes { get; init; } /// /// Get the attribute of type, or null if it doesn't exist /// public U GetAttribute() where U : System.Attribute { for ( int i = 0; i < Attributes.Length; i++ ) { if ( Attributes[i] is U t ) return t; } return default; } }