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
CSharpResolverA 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
AddTypeReferenceAnnotations
Specifies whether the ast builder should add annotations to type references. The default value is false.
public bool AddTypeReferenceAnnotations { get; set; }
Property Value
AlwaysUseGlobal
Controls whether all fully qualified type names should be prefixed with "global::".
public bool AlwaysUseGlobal { get; set; }
Property Value
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
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
GenerateBody
Controls whether to generate a body that throws a System.NotImplementedException
.
The default value is false.
public bool GenerateBody { get; set; }
Property Value
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
PrintIntegralValuesAsHex
Controls whether integral constants should be printed in hexadecimal format. The default value is false.
public bool PrintIntegralValuesAsHex { get; set; }
Property Value
ShowAccessibility
Controls the accessibility modifiers are shown. The default value is true.
public bool ShowAccessibility { get; set; }
Property Value
ShowAttributes
Controls whether to show attributes. The default value is false.
public bool ShowAttributes { get; set; }
Property Value
ShowBaseTypes
Controls whether base type references are shown. The default value is true.
public bool ShowBaseTypes { get; set; }
Property Value
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
ShowModifiers
Controls the non-accessibility modifiers are shown. The default value is true.
public bool ShowModifiers { get; set; }
Property Value
ShowParameterNames
Controls whether the names of parameters are shown. The default value is true.
public bool ShowParameterNames { get; set; }
Property Value
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
ShowTypeParameters
Controls whether type parameter declarations are shown. The default value is true.
public bool ShowTypeParameters { get; set; }
Property Value
ShowTypeParametersForUnboundTypes
Controls whether type parameter names are shown for unbound types. The default value is false.
public bool ShowTypeParametersForUnboundTypes { get; set; }
Property Value
SupportInitAccessors
Controls whether C# 9 "init;" accessors are supported. If disabled, emits "set /init/;" instead.
public bool SupportInitAccessors { get; set; }
Property Value
SupportOperatorChecked
Controls whether C# 11 "operator checked" is supported.
public bool SupportOperatorChecked { get; set; }
Property Value
SupportRecordClasses
Controls whether C# 9 "record" class types are supported.
public bool SupportRecordClasses { get; set; }
Property Value
SupportRecordStructs
Controls whether C# 10 "record" struct types are supported.
public bool SupportRecordStructs { get; set; }
Property Value
SupportUnsignedRightShift
Controls whether C# 11 "operator >>>" is supported.
public bool SupportUnsignedRightShift { get; set; }
Property Value
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
UseCustomEvents
Controls whether to generate custom events. The default value is false.
public bool UseCustomEvents { get; set; }
Property Value
UseKeywordsForBuiltinTypes
Controls whether to use keywords for builtin types. The default value is true.
public bool UseKeywordsForBuiltinTypes { get; set; }
Property Value
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
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
Methods
ConvertAttribute(IAttribute)
public Attribute ConvertAttribute(IAttribute attribute)
Parameters
attribute
IAttribute
Returns
ConvertAttributeType(IType)
public AstType ConvertAttributeType(IType type)
Parameters
type
IType
Returns
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
Returns
ConvertConstantValue(IType, IType, object)
Creates an Expression for the given constant value.
public Expression ConvertConstantValue(IType expectedType, IType type, object constantValue)
Parameters
Returns
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
Returns
ConvertEntity(IEntity)
public EntityDeclaration ConvertEntity(IEntity entity)
Parameters
entity
IEntity
Returns
ConvertNamespace(string, out NamespaceResolveResult)
public AstType ConvertNamespace(string namespaceName, out NamespaceResolveResult nrr)
Parameters
namespaceName
stringnrr
NamespaceResolveResult
Returns
ConvertParameter(IParameter)
public ParameterDeclaration ConvertParameter(IParameter parameter)
Parameters
parameter
IParameter
Returns
ConvertSymbol(ISymbol)
public AstNode ConvertSymbol(ISymbol symbol)
Parameters
symbol
ISymbol
Returns
ConvertType(FullTypeName)
public AstType ConvertType(FullTypeName fullTypeName)
Parameters
fullTypeName
FullTypeName
Returns
ConvertType(IType)
public AstType ConvertType(IType type)
Parameters
type
IType
Returns
ConvertVariable(IVariable)
public VariableDeclarationStatement ConvertVariable(IVariable v)
Parameters
Returns
ModifierFromAccessibility(Accessibility)
public static Modifiers ModifierFromAccessibility(Accessibility accessibility)
Parameters
accessibility
Accessibility