Class LocalFunctionDecompiler
- Namespace
- ICSharpCode.Decompiler.IL.Transforms
- Assembly
- ICSharpCode.Decompiler.dll
Decompiler step for C# 7.0 local functions
public class LocalFunctionDecompiler : IILTransform
- Inheritance
-
LocalFunctionDecompiler
- Implements
- Inherited Members
Constructors
LocalFunctionDecompiler()
public LocalFunctionDecompiler()
Methods
IsLocalFunctionDisplayClass(PEFile, TypeDefinitionHandle, ILTransformContext)
public static bool IsLocalFunctionDisplayClass(PEFile module, TypeDefinitionHandle typeHandle, ILTransformContext context = null)
Parameters
module
PEFiletypeHandle
TypeDefinitionHandlecontext
ILTransformContext
Returns
IsLocalFunctionMethod(PEFile, MethodDefinitionHandle, ILTransformContext)
public static bool IsLocalFunctionMethod(PEFile module, MethodDefinitionHandle methodHandle, ILTransformContext context = null)
Parameters
module
PEFilemethodHandle
MethodDefinitionHandlecontext
ILTransformContext
Returns
IsLocalFunctionMethod(IMethod, ILTransformContext)
public static bool IsLocalFunctionMethod(IMethod method, ILTransformContext context)
Parameters
method
IMethodcontext
ILTransformContext
Returns
LocalFunctionNeedsAccessibilityChange(PEFile, MethodDefinitionHandle)
public static bool LocalFunctionNeedsAccessibilityChange(PEFile module, MethodDefinitionHandle methodHandle)
Parameters
module
PEFilemethodHandle
MethodDefinitionHandle
Returns
Run(ILFunction, ILTransformContext)
The transform works like this:
local functions can either be used in method calls, i.e., call and callvirt instructions,
or can be used as part of the "delegate construction" pattern, i.e.,
newobj Delegate(<target-expression>, ldftn <method>)
.
LocalFunctionMethod
or a ldftn of the LocalFunctionMethod
.
In a next step we handle all nested local functions.
After all local functions are transformed, we move all local functions that capture
any variables to their respective declaration scope.
public void Run(ILFunction function, ILTransformContext context)
Parameters
function
ILFunctioncontext
ILTransformContext