Table of Contents

Class TypeSystemAstBuilder

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

Converts from type system to the C# AST.

public class TypeSystemAstBuilder
Inheritance
TypeSystemAstBuilder
Inherited Members

Constructors

TypeSystemAstBuilder()

Creates a new TypeSystemAstBuilder.

public TypeSystemAstBuilder()

TypeSystemAstBuilder(CSharpResolver)

Creates a new TypeSystemAstBuilder.

public TypeSystemAstBuilder(CSharpResolver resolver)

Parameters

resolver CSharpResolver

A resolver initialized for the position where the type will be inserted.

Properties

AddResolveResultAnnotations

Specifies whether the ast builder should add ResolveResult annotations to AST nodes. The default value is false.

public bool AddResolveResultAnnotations { get; set; }

Property Value

bool

AddTypeReferenceAnnotations

Specifies whether the ast builder should add annotations to type references. The default value is false.

public bool AddTypeReferenceAnnotations { get; set; }

Property Value

bool

AlwaysUseGlobal

Controls whether all fully qualified type names should be prefixed with "global::".

public bool AlwaysUseGlobal { get; set; }

Property Value

bool

AlwaysUseShortTypeNames

Controls whether to use fully-qualified type names or short type names. The default value is false.

public bool AlwaysUseShortTypeNames { get; set; }

Property Value

bool

ConvertUnboundTypeArguments

Controls whether unbound type argument names are inserted in the ast or not. The default value is false.

public bool ConvertUnboundTypeArguments { get; set; }

Property Value

bool

GenerateBody

Controls whether to generate a body that throws a System.NotImplementedException. The default value is false.

public bool GenerateBody { get; set; }

Property Value

bool

NameLookupMode

Determines the name lookup mode for converting a type name.

The default value is NameLookupMode.Expression, which means the name is disambiguated for use in expression context.

public NameLookupMode NameLookupMode { get; set; }

Property Value

NameLookupMode

PrintIntegralValuesAsHex

Controls whether integral constants should be printed in hexadecimal format. The default value is false.

public bool PrintIntegralValuesAsHex { get; set; }

Property Value

bool

ShowAccessibility

Controls the accessibility modifiers are shown. The default value is true.

public bool ShowAccessibility { get; set; }

Property Value

bool

ShowAttributes

Controls whether to show attributes. The default value is false.

public bool ShowAttributes { get; set; }

Property Value

bool

ShowBaseTypes

Controls whether base type references are shown. The default value is true.

public bool ShowBaseTypes { get; set; }

Property Value

bool

ShowConstantValues

Controls whether to show default values of optional parameters, and the values of constant fields. The default value is true.

public bool ShowConstantValues { get; set; }

Property Value

bool

ShowModifiers

Controls the non-accessibility modifiers are shown. The default value is true.

public bool ShowModifiers { get; set; }

Property Value

bool

ShowParameterNames

Controls whether the names of parameters are shown. The default value is true.

public bool ShowParameterNames { get; set; }

Property Value

bool

ShowTypeParameterConstraints

Controls whether constraints on type parameter declarations are shown. Has no effect if ShowTypeParameters is false. The default value is true.

public bool ShowTypeParameterConstraints { get; set; }

Property Value

bool

ShowTypeParameters

Controls whether type parameter declarations are shown. The default value is true.

public bool ShowTypeParameters { get; set; }

Property Value

bool

ShowTypeParametersForUnboundTypes

Controls whether type parameter names are shown for unbound types. The default value is false.

public bool ShowTypeParametersForUnboundTypes { get; set; }

Property Value

bool

SupportInitAccessors

Controls whether C# 9 "init;" accessors are supported. If disabled, emits "set /init/;" instead.

public bool SupportInitAccessors { get; set; }

Property Value

bool

SupportOperatorChecked

Controls whether C# 11 "operator checked" is supported.

public bool SupportOperatorChecked { get; set; }

Property Value

bool

SupportRecordClasses

Controls whether C# 9 "record" class types are supported.

public bool SupportRecordClasses { get; set; }

Property Value

bool

SupportRecordStructs

Controls whether C# 10 "record" struct types are supported.

public bool SupportRecordStructs { get; set; }

Property Value

bool

SupportUnsignedRightShift

Controls whether C# 11 "operator >>>" is supported.

public bool SupportUnsignedRightShift { get; set; }

Property Value

bool

UseAliases

Controls whether aliases should be used inside the type name or not. The default value is true.

public bool UseAliases { get; set; }

Property Value

bool

UseCustomEvents

Controls whether to generate custom events. The default value is false.

public bool UseCustomEvents { get; set; }

Property Value

bool

UseKeywordsForBuiltinTypes

Controls whether to use keywords for builtin types. The default value is true.

public bool UseKeywordsForBuiltinTypes { get; set; }

Property Value

bool

UseNullableSpecifierForValueTypes

Controls whether to use T? or Nullable<T> for nullable value types. The default value is true.

public bool UseNullableSpecifierForValueTypes { get; set; }

Property Value

bool

UseSpecialConstants

Controls whether constants like int.MaxValue are converted to a MemberReferenceExpression or PrimitiveExpression. The default value is true.

public bool UseSpecialConstants { get; set; }

Property Value

bool

Methods

ConvertAttribute(IAttribute)

public Attribute ConvertAttribute(IAttribute attribute)

Parameters

attribute IAttribute

Returns

Attribute

ConvertAttributeType(IType)

public AstType ConvertAttributeType(IType type)

Parameters

type IType

Returns

AstType

ConvertConstantValue(ResolveResult)

Creates an Expression for the given constant value.

Note: the returned expression is not necessarily of the desired type. However, the returned expression will always be implicitly convertible to rr.Type, and will have the correct value when being converted in this way.

public Expression ConvertConstantValue(ResolveResult rr)

Parameters

rr ResolveResult

Returns

Expression

ConvertConstantValue(IType, IType, object)

Creates an Expression for the given constant value.

public Expression ConvertConstantValue(IType expectedType, IType type, object constantValue)

Parameters

expectedType IType
type IType
constantValue object

Returns

Expression

ConvertConstantValue(IType, object)

Creates an Expression for the given constant value.

Note: the returned expression is not necessarily of the specified type: For example, ConvertConstantValue(typeof(string), null) results in a null literal, without a cast to string. Similarly, ConvertConstantValue(typeof(short), 1) results in the literal 1, which is of type int. However, the returned expression will always be implicitly convertible to type.

public Expression ConvertConstantValue(IType type, object constantValue)

Parameters

type IType
constantValue object

Returns

Expression

ConvertEntity(IEntity)

public EntityDeclaration ConvertEntity(IEntity entity)

Parameters

entity IEntity

Returns

EntityDeclaration

ConvertNamespace(string, out NamespaceResolveResult)

public AstType ConvertNamespace(string namespaceName, out NamespaceResolveResult nrr)

Parameters

namespaceName string
nrr NamespaceResolveResult

Returns

AstType

ConvertParameter(IParameter)

public ParameterDeclaration ConvertParameter(IParameter parameter)

Parameters

parameter IParameter

Returns

ParameterDeclaration

ConvertSymbol(ISymbol)

public AstNode ConvertSymbol(ISymbol symbol)

Parameters

symbol ISymbol

Returns

AstNode

ConvertType(FullTypeName)

public AstType ConvertType(FullTypeName fullTypeName)

Parameters

fullTypeName FullTypeName

Returns

AstType

ConvertType(IType)

public AstType ConvertType(IType type)

Parameters

type IType

Returns

AstType

ConvertVariable(IVariable)

public VariableDeclarationStatement ConvertVariable(IVariable v)

Parameters

v IVariable

Returns

VariableDeclarationStatement

ModifierFromAccessibility(Accessibility)

public static Modifiers ModifierFromAccessibility(Accessibility accessibility)

Parameters

accessibility Accessibility

Returns

Modifiers