Table of Contents

Class AstType

Namespace
ICSharpCode.Decompiler.CSharp.Syntax
Assembly
ICSharpCode.Decompiler.dll

A type reference in the C# AST.

public abstract class AstType : AstNode, IAnnotatable, IFreezable, INode, ICloneable
Inheritance
AstType
Implements
Derived
Inherited Members
Extension Methods

Constructors

AstType()

protected AstType()

Fields

Null

public static readonly AstType Null

Field Value

AstType

Properties

NodeType

public override NodeType NodeType { get; }

Property Value

NodeType

Methods

Clone()

public AstType Clone()

Returns

AstType

Create(string)

Creates a simple AstType from a dotted name. Does not support generics, arrays, etc. - just simple dotted names, e.g. namespace names.

public static AstType Create(string dottedName)

Parameters

dottedName string

Returns

AstType

GetNameLookupMode()

Gets the name lookup mode from the context (looking at the ancestors of this AstType).

public NameLookupMode GetNameLookupMode()

Returns

NameLookupMode

IsVar()

Gets whether this type is a SimpleType "var".

public bool IsVar()

Returns

bool

MakeArrayType(int)

Creates an array type from this type by nesting it in a ComposedType. If this type already is an array type, the additional rank is prepended to the existing array specifier list. Thus, new SimpleType("T").MakeArrayType(1).MakeArrayType(2) will result in "T[,][]".

public virtual AstType MakeArrayType(int rank = 1)

Parameters

rank int

Returns

AstType

MakeNullableType()

Creates a nullable type from this type by nesting it in a ComposedType.

public AstType MakeNullableType()

Returns

AstType

MakePointerType()

Creates a pointer type from this type by nesting it in a ComposedType. If this type already is a pointer type, this method just increases the PointerRank of the existing pointer type.

public virtual AstType MakePointerType()

Returns

AstType

MakeRefType()

Creates a C# 7 ref type from this type by nesting it in a ComposedType.

public virtual AstType MakeRefType()

Returns

AstType

MemberType(string, params AstType[])

Builds an expression that can be used to access a static member on this type.

public MemberType MemberType(string memberName, params AstType[] typeArguments)

Parameters

memberName string
typeArguments AstType[]

Returns

MemberType

MemberType(string, IEnumerable<AstType>)

Builds an expression that can be used to access a static member on this type.

public MemberType MemberType(string memberName, IEnumerable<AstType> typeArguments)

Parameters

memberName string
typeArguments IEnumerable<AstType>

Returns

MemberType

ToTypeReference(NameLookupMode, InterningProvider)

Create an ITypeReference for this AstType.

public abstract ITypeReference ToTypeReference(NameLookupMode lookupMode, InterningProvider interningProvider = null)

Parameters

lookupMode NameLookupMode
interningProvider InterningProvider

Returns

ITypeReference

Remarks

The resulting type reference will read the context information from the ITypeResolveContext: For resolving type parameters, the CurrentTypeDefinition/CurrentMember is used. For resolving simple names, the current namespace and usings from the CurrentUsingScope (on CSharpTypeResolveContext only) is used.

ToTypeReference(InterningProvider)

Create an ITypeReference for this AstType. Uses the context (ancestors of this node) to determine the correct NameLookupMode.

public ITypeReference ToTypeReference(InterningProvider interningProvider = null)

Parameters

interningProvider InterningProvider

Returns

ITypeReference

Remarks

The resulting type reference will read the context information from the ITypeResolveContext: For resolving type parameters, the CurrentTypeDefinition/CurrentMember is used. For resolving simple names, the current namespace and usings from the CurrentUsingScope (on CSharpTypeResolveContext only) is used.

Operators

implicit operator AstType(Pattern)

public static implicit operator AstType(Pattern pattern)

Parameters

pattern Pattern

Returns

AstType