C# Class Microsoft.Cci.MutableContracts.GenericMethodParameterMapper

If the original method that contained the anonymous delegate is generic, then the code generated by the compiler, the "closure method", is also generic. If the anonymous delegate didn't capture any locals or parameters, then a (generic) static method was generated to implement the lambda. If it did capture things, then the closure method is a non-generic instance method in a generic class. In either case, any references to those generic parameters need to be mapped back to become references to the original method's generic parameters. Create an instance of this class for each anonymous delegate using the appropriate constructor. This is known from whether the closure method is (static and generic) or (instance and not-generic, but whose containing type is generic). Those are the only two patterns created by the compiler.
Inheritance: Microsoft.Cci.MutableCodeModel.Contracts.CodeAndContractRewriter
显示文件 Open project: visualmutator/visualmutator Class Usage Examples

Public Methods

Method Description
GenericMethodParameterMapper ( IMetadataHost host, IMethodDefinition targetMethod, IMethodDefinition sourceMethod ) : System

Use this constructor when the anonymous delegate did not capture any locals or parameters and so was implemented as a static, generic closure method.

GenericMethodParameterMapper ( IMetadataHost host, IMethodDefinition targetMethod, INestedTypeReference sourceType ) : System

Use this constructor when the anonymous delegate did capture a local or parameter and so was implemented as an instance, non-generic closure method within a generic class.

Rewrite ( IGenericMethodParameterReference genericMethodParameterReference ) : ITypeReference
Rewrite ( IGenericTypeParameterReference genericTypeParameterReference ) : ITypeReference
RewriteReference ( ILocalDefinition localDefinition ) : object

This is necessary only because the base rewriter for things like TargetExpression call this method and its definition in the base rewriter is to not visit it, but to just return it.

Private Methods

Method Description
GenericMethodParameterMapper ( IMetadataHost host, IMethodDefinition targetMethod ) : System

Method Details

GenericMethodParameterMapper() public method

Use this constructor when the anonymous delegate did not capture any locals or parameters and so was implemented as a static, generic closure method.
public GenericMethodParameterMapper ( IMetadataHost host, IMethodDefinition targetMethod, IMethodDefinition sourceMethod ) : System
host IMetadataHost
targetMethod IMethodDefinition
sourceMethod IMethodDefinition
return System

GenericMethodParameterMapper() public method

Use this constructor when the anonymous delegate did capture a local or parameter and so was implemented as an instance, non-generic closure method within a generic class.
public GenericMethodParameterMapper ( IMetadataHost host, IMethodDefinition targetMethod, INestedTypeReference sourceType ) : System
host IMetadataHost
targetMethod IMethodDefinition
sourceType INestedTypeReference
return System

Rewrite() public method

public Rewrite ( IGenericMethodParameterReference genericMethodParameterReference ) : ITypeReference
genericMethodParameterReference IGenericMethodParameterReference
return ITypeReference

Rewrite() public method

public Rewrite ( IGenericTypeParameterReference genericTypeParameterReference ) : ITypeReference
genericTypeParameterReference IGenericTypeParameterReference
return ITypeReference

RewriteReference() public method

This is necessary only because the base rewriter for things like TargetExpression call this method and its definition in the base rewriter is to not visit it, but to just return it.
public RewriteReference ( ILocalDefinition localDefinition ) : object
localDefinition ILocalDefinition
return object