Browse Source

Add AlwaysUseBuiltinTypeNames option to TypeSystemAstBuilder

pull/1198/head
Siegfried Pammer 7 years ago
parent
commit
5b4870e588
  1. 11
      ICSharpCode.Decompiler/CSharp/Syntax/TypeSystemAstBuilder.cs

11
ICSharpCode.Decompiler/CSharp/Syntax/TypeSystemAstBuilder.cs

@ -64,6 +64,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
#region Properties #region Properties
void InitProperties() void InitProperties()
{ {
this.AlwaysUseBuiltinTypeNames = true;
this.ShowAccessibility = true; this.ShowAccessibility = true;
this.ShowModifiers = true; this.ShowModifiers = true;
this.ShowBaseTypes = true; this.ShowBaseTypes = true;
@ -142,6 +143,12 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// </summary> /// </summary>
public bool AlwaysUseShortTypeNames { get; set; } public bool AlwaysUseShortTypeNames { get; set; }
/// <summary>
/// Controls whether to use fully-qualified type names or short type names.
/// The default value is <c>true</c>.
/// </summary>
public bool AlwaysUseBuiltinTypeNames { get; set; }
/// <summary> /// <summary>
/// Determines the name lookup mode for converting a type name. /// Determines the name lookup mode for converting a type name.
/// ///
@ -233,7 +240,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
} }
} }
if (type is ParameterizedType pt) { if (type is ParameterizedType pt) {
if (pt.IsKnownType(KnownTypeCode.NullableOfT)) { if (AlwaysUseBuiltinTypeNames && pt.IsKnownType(KnownTypeCode.NullableOfT)) {
return ConvertType(pt.TypeArguments[0]).MakeNullableType(); return ConvertType(pt.TypeArguments[0]).MakeNullableType();
} }
return ConvertTypeHelper(pt.GenericType, pt.TypeArguments); return ConvertTypeHelper(pt.GenericType, pt.TypeArguments);
@ -269,7 +276,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
Debug.Assert(genericType is ITypeDefinition || genericType.Kind == TypeKind.Unknown); Debug.Assert(genericType is ITypeDefinition || genericType.Kind == TypeKind.Unknown);
ITypeDefinition typeDef = genericType as ITypeDefinition; ITypeDefinition typeDef = genericType as ITypeDefinition;
if (typeDef != null) { if (AlwaysUseBuiltinTypeNames && typeDef != null) {
string keyword = KnownTypeReference.GetCSharpNameByTypeCode(typeDef.KnownTypeCode); string keyword = KnownTypeReference.GetCSharpNameByTypeCode(typeDef.KnownTypeCode);
if (keyword != null) if (keyword != null)
return new PrimitiveType(keyword); return new PrimitiveType(keyword);

Loading…
Cancel
Save