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
Properties
NodeType
public override NodeType NodeType { get; }
Property Value
Methods
Clone()
public AstType Clone()
Returns
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
GetNameLookupMode()
Gets the name lookup mode from the context (looking at the ancestors of this AstType).
public NameLookupMode GetNameLookupMode()
Returns
IsVar()
Gets whether this type is a SimpleType "var".
public bool IsVar()
Returns
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
MakeNullableType()
Creates a nullable type from this type by nesting it in a ComposedType.
public AstType MakeNullableType()
Returns
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
MakeRefType()
Creates a C# 7 ref type from this type by nesting it in a ComposedType.
public virtual AstType MakeRefType()
Returns
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
Returns
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
stringtypeArguments
IEnumerable<AstType>
Returns
ToTypeReference(NameLookupMode, InterningProvider)
Create an ITypeReference for this AstType.
public abstract ITypeReference ToTypeReference(NameLookupMode lookupMode, InterningProvider interningProvider = null)
Parameters
lookupMode
NameLookupModeinterningProvider
InterningProvider
Returns
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
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