Open sandboxFocus

Method ToMethodInfo

ToMethodInfo()

Gets a MethodInfo that represents the current method at run time.

Declaration
MethodInfo ToMethodInfo()
Returns
Type Description
MethodInfo

A MethodInfo that can be used only in run-time code.

Remarks

This method generates run-time code that retrieves the MethodInfo object for the current method. While Metalama is designed to eliminate the need for reflection in most scenarios, this method is useful when you need to pass method metadata to APIs that require MethodInfo objects.

Warning: The code generated by this method relies on method names and signatures, and may break if your project is obfuscated. Consider using method invokers (such as Invoke(params dynamic?[])) when possible, as this approach is obfuscation-safe.

See Also