Table of Contents

Class LambdaResolveResult

Namespace
ICSharpCode.Decompiler.CSharp.Resolver
Assembly
ICSharpCode.Decompiler.dll

Represents an anonymous method or lambda expression. Note: the lambda has no type. To retrieve the delegate type, look at the anonymous function conversion.

public abstract class LambdaResolveResult : ResolveResult
Inheritance
LambdaResolveResult
Inherited Members
Extension Methods

Constructors

LambdaResolveResult()

protected LambdaResolveResult()

Properties

Body

Gets the resolve result for the lambda body. Returns a resolve result for 'void' for statement lambdas.

public abstract ResolveResult Body { get; }

Property Value

ResolveResult

HasParameterList

Gets whether there is a parameter list. This property always returns true for C# 3.0-lambdas, but may return false for C# 2.0 anonymous methods.

public abstract bool HasParameterList { get; }

Property Value

bool

IsAnonymousMethod

Gets whether this lambda is using the C# 2.0 anonymous method syntax.

public abstract bool IsAnonymousMethod { get; }

Property Value

bool

IsAsync

Gets whether the lambda is async.

public abstract bool IsAsync { get; }

Property Value

bool

IsImplicitlyTyped

Gets whether the lambda parameters are implicitly typed.

public abstract bool IsImplicitlyTyped { get; }

Property Value

bool

Remarks

This property returns false for anonymous methods without parameter list.

Parameters

Gets the list of parameters.

public abstract IReadOnlyList<IParameter> Parameters { get; }

Property Value

IReadOnlyList<IParameter>

ReturnType

Gets the return type of the lambda.

If the lambda is async, the return type includes

Task<T>
public abstract IType ReturnType { get; }

Property Value

IType

Methods

GetChildResults()

public override IEnumerable<ResolveResult> GetChildResults()

Returns

IEnumerable<ResolveResult>

GetInferredReturnType(IType[])

Gets the return type inferred when the parameter types are inferred to be parameterTypes

public abstract IType GetInferredReturnType(IType[] parameterTypes)

Parameters

parameterTypes IType[]

Returns

IType

Remarks

This method determines the return type inferred from the lambda body, which is used as part of C# type inference. Use the ReturnType property to retrieve the actual return type as determined by the target delegate type.

IsValid(IType[], IType, CSharpConversions)

Gets whether the lambda body is valid for the given parameter types and return type.

public abstract Conversion IsValid(IType[] parameterTypes, IType returnType, CSharpConversions conversions)

Parameters

parameterTypes IType[]
returnType IType
conversions CSharpConversions

Returns

Conversion

Produces a conversion with IsAnonymousFunctionConversion=true if the lambda is valid; otherwise returns None.