|
|
|
@ -123,7 +123,7 @@ namespace ICSharpCode.Decompiler.Ast
@@ -123,7 +123,7 @@ namespace ICSharpCode.Decompiler.Ast
|
|
|
|
|
|
|
|
|
|
public void AddType(TypeDefinition typeDef) |
|
|
|
|
{ |
|
|
|
|
TypeDeclaration astType = CreateType(typeDef); |
|
|
|
|
var astType = CreateType(typeDef); |
|
|
|
|
NamespaceDeclaration astNS = GetCodeNamespace(typeDef.Namespace); |
|
|
|
|
if (astNS != null) { |
|
|
|
|
astNS.AddChild(astType, NamespaceDeclaration.MemberRole); |
|
|
|
@ -153,7 +153,12 @@ namespace ICSharpCode.Decompiler.Ast
@@ -153,7 +153,12 @@ namespace ICSharpCode.Decompiler.Ast
|
|
|
|
|
astCompileUnit.AddChild(CreateEvent(ev), CompilationUnit.MemberRole); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public TypeDeclaration CreateType(TypeDefinition typeDef) |
|
|
|
|
/// <summary>
|
|
|
|
|
/// Creates the AST for a type definition.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="typeDef"></param>
|
|
|
|
|
/// <returns>TypeDeclaration or DelegateDeclaration.</returns>
|
|
|
|
|
public AttributedNode CreateType(TypeDefinition typeDef) |
|
|
|
|
{ |
|
|
|
|
TypeDefinition oldCurrentType = context.CurrentType; |
|
|
|
|
context.CurrentType = typeDef; |
|
|
|
@ -183,13 +188,13 @@ namespace ICSharpCode.Decompiler.Ast
@@ -183,13 +188,13 @@ namespace ICSharpCode.Decompiler.Ast
|
|
|
|
|
astType.Constraints.AddRange(MakeConstraints(genericParameters)); |
|
|
|
|
|
|
|
|
|
// Nested types
|
|
|
|
|
foreach(TypeDefinition nestedTypeDef in typeDef.NestedTypes) { |
|
|
|
|
foreach (TypeDefinition nestedTypeDef in typeDef.NestedTypes) { |
|
|
|
|
if (MemberIsHidden(nestedTypeDef, context.Settings)) |
|
|
|
|
continue; |
|
|
|
|
astType.AddChild(CreateType(nestedTypeDef), TypeDeclaration.MemberRole); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AttributedNode result = astType; |
|
|
|
|
if (typeDef.IsEnum) { |
|
|
|
|
long expectedEnumMemberValue = 0; |
|
|
|
|
bool forcePrintingInitializers = IsFlagsEnum(typeDef); |
|
|
|
@ -210,6 +215,21 @@ namespace ICSharpCode.Decompiler.Ast
@@ -210,6 +215,21 @@ namespace ICSharpCode.Decompiler.Ast
|
|
|
|
|
astType.AddChild(enumMember, TypeDeclaration.MemberRole); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else if (typeDef.BaseType != null && typeDef.BaseType.FullName == "System.MulticastDelegate") { |
|
|
|
|
DelegateDeclaration dd = new DelegateDeclaration(); |
|
|
|
|
dd.Modifiers = astType.Modifiers & ~Modifiers.Sealed; |
|
|
|
|
dd.Name = astType.Name; |
|
|
|
|
dd.AddAnnotation(typeDef); |
|
|
|
|
astType.Attributes.MoveTo(dd.Attributes); |
|
|
|
|
astType.TypeParameters.MoveTo(dd.TypeParameters); |
|
|
|
|
astType.Constraints.MoveTo(dd.Constraints); |
|
|
|
|
foreach (var m in typeDef.Methods) { |
|
|
|
|
if (m.Name == "Invoke") { |
|
|
|
|
dd.ReturnType = ConvertType(m.ReturnType, m.MethodReturnType); |
|
|
|
|
dd.Parameters.AddRange(MakeParameters(m.Parameters)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
result = dd; |
|
|
|
|
} else { |
|
|
|
|
// Base type
|
|
|
|
|
if (typeDef.BaseType != null && !typeDef.IsValueType && typeDef.BaseType.FullName != "System.Object") { |
|
|
|
@ -223,7 +243,7 @@ namespace ICSharpCode.Decompiler.Ast
@@ -223,7 +243,7 @@ namespace ICSharpCode.Decompiler.Ast
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
context.CurrentType = oldCurrentType; |
|
|
|
|
return astType; |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void Transform(IAstTransform transform) |
|
|
|
@ -704,6 +724,7 @@ namespace ICSharpCode.Decompiler.Ast
@@ -704,6 +724,7 @@ namespace ICSharpCode.Decompiler.Ast
|
|
|
|
|
CustomEventDeclaration CreateEvent(EventDefinition eventDef) |
|
|
|
|
{ |
|
|
|
|
CustomEventDeclaration astEvent = new CustomEventDeclaration(); |
|
|
|
|
ConvertCustomAttributes(astEvent, eventDef); |
|
|
|
|
astEvent.AddAnnotation(eventDef); |
|
|
|
|
astEvent.Name = CleanName(eventDef.Name); |
|
|
|
|
astEvent.ReturnType = ConvertType(eventDef.EventType, eventDef); |
|
|
|
|