Skip to content
Permalink
Browse files

Fix #1744: C# decompilation does not show System.Enum derives from Sy…

…stem.ValueTuple
  • Loading branch information...
siegfriedpammer committed Oct 9, 2019
1 parent b1352aa commit 8ec9bcb1a68292856c85bad61dee200f83ab9b7b
Showing with 12 additions and 6 deletions.
  1. +12 −6 ICSharpCode.Decompiler/CSharp/Syntax/TypeSystemAstBuilder.cs
@@ -1408,13 +1408,19 @@ EntityDeclaration ConvertTypeDefinition(ITypeDefinition typeDefinition)

if (this.ShowBaseTypes) {
foreach (IType baseType in typeDefinition.DirectBaseTypes) {
if (baseType.IsKnownType (KnownTypeCode.Enum)) {
if (!typeDefinition.EnumUnderlyingType.IsKnownType (KnownTypeCode.Int32)) {
decl.BaseTypes.Add (ConvertType (typeDefinition.EnumUnderlyingType));
// if the declared type is an enum, replace all references to System.Enum with the enum-underlying type
if (typeDefinition.Kind == TypeKind.Enum && baseType.IsKnownType(KnownTypeCode.Enum)) {
if (!typeDefinition.EnumUnderlyingType.IsKnownType(KnownTypeCode.Int32)) {
decl.BaseTypes.Add(ConvertType(typeDefinition.EnumUnderlyingType));
}
} else if (!baseType.IsKnownType (KnownTypeCode.Object) &&
!baseType.IsKnownType (KnownTypeCode.ValueType)) {
decl.BaseTypes.Add (ConvertType (baseType));
// if the declared type is a struct, ignore System.ValueType
} else if (typeDefinition.Kind == TypeKind.Struct && baseType.IsKnownType(KnownTypeCode.ValueType)) {
continue;
// always ignore System.Object
} else if (baseType.IsKnownType(KnownTypeCode.Object)) {
continue;
} else {
decl.BaseTypes.Add(ConvertType(baseType));
}
}
}

0 comments on commit 8ec9bcb

Please sign in to comment.
You can’t perform that action at this time.