Table of Contents

Class CSharpConversions

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

Contains logic that determines whether an implicit conversion exists between two types.

public sealed class CSharpConversions
Inheritance
CSharpConversions
Inherited Members

Remarks

This class is thread-safe.

Constructors

CSharpConversions(ICompilation)

public CSharpConversions(ICompilation compilation)

Parameters

compilation ICompilation

Methods

BetterConversion(ResolveResult, IType, IType)

Gets the better conversion (C# 4.0 spec, §7.5.3.3)

public int BetterConversion(ResolveResult resolveResult, IType t1, IType t2)

Parameters

resolveResult ResolveResult
t1 IType
t2 IType

Returns

int

0 = neither is better; 1 = t1 is better; 2 = t2 is better

BetterConversion(IType, IType, IType)

Gets the better conversion (C# 4.0 spec, §7.5.3.4)

public int BetterConversion(IType s, IType t1, IType t2)

Parameters

s IType
t1 IType
t2 IType

Returns

int

0 = neither is better; 1 = t1 is better; 2 = t2 is better

ExplicitConversion(ResolveResult, IType)

public Conversion ExplicitConversion(ResolveResult resolveResult, IType toType)

Parameters

resolveResult ResolveResult
toType IType

Returns

Conversion

ExplicitConversion(IType, IType)

public Conversion ExplicitConversion(IType fromType, IType toType)

Parameters

fromType IType
toType IType

Returns

Conversion

Get(ICompilation)

Gets the Conversions instance for the specified ICompilation. This will make use of the context's cache manager to reuse the Conversions instance.

public static CSharpConversions Get(ICompilation compilation)

Parameters

compilation ICompilation

Returns

CSharpConversions

IdentityConversion(IType, IType)

Gets whether there is an identity conversion from fromType to toType

public bool IdentityConversion(IType fromType, IType toType)

Parameters

fromType IType
toType IType

Returns

bool

ImplicitConversion(ResolveResult, IType)

public Conversion ImplicitConversion(ResolveResult resolveResult, IType toType)

Parameters

resolveResult ResolveResult
toType IType

Returns

Conversion

ImplicitConversion(IType, IType)

public Conversion ImplicitConversion(IType fromType, IType toType)

Parameters

fromType IType
toType IType

Returns

Conversion

IsBoxingConversionOrInvolvingTypeParameter(IType, IType)

Gets whether the conversion from fromType to toType is a boxing conversion, or an implicit conversion involving a type parameter that might be a boxing conversion when instantiated with a value type.

public bool IsBoxingConversionOrInvolvingTypeParameter(IType fromType, IType toType)

Parameters

fromType IType
toType IType

Returns

bool

IsConstraintConvertible(IType, IType)

Gets whether the type 'fromType' is convertible to 'toType' using one of the conversions allowed when satisying constraints (§4.4.4)

public bool IsConstraintConvertible(IType fromType, IType toType)

Parameters

fromType IType
toType IType

Returns

bool

IsDelegateCompatible(IMethod, IType)

Gets whether a method is compatible with a delegate type. §15.2 Delegate compatibility

public bool IsDelegateCompatible(IMethod method, IType delegateType)

Parameters

method IMethod

The method to test for compatibility

delegateType IType

The delegate type

Returns

bool

IsImplicitReferenceConversion(IType, IType)

public bool IsImplicitReferenceConversion(IType fromType, IType toType)

Parameters

fromType IType
toType IType

Returns

bool

StandardImplicitConversion(IType, IType)

public Conversion StandardImplicitConversion(IType fromType, IType toType)

Parameters

fromType IType
toType IType

Returns

Conversion