Browse Source

Remove `n from generic class names.

pull/70/head
Daniel Grunwald 15 years ago
parent
commit
f648be9fb7
  1. 24
      ICSharpCode.Decompiler/Ast/AstBuilder.cs

24
ICSharpCode.Decompiler/Ast/AstBuilder.cs

@ -132,7 +132,7 @@ namespace Decompiler @@ -132,7 +132,7 @@ namespace Decompiler
TypeDeclaration astType = new TypeDeclaration();
astType.AddAnnotation(typeDef);
astType.Modifiers = ConvertModifiers(typeDef);
astType.Name = typeDef.Name;
astType.Name = CleanName(typeDef.Name);
if (typeDef.IsEnum) { // NB: Enum is value type
astType.ClassType = ClassType.Enum;
@ -165,7 +165,7 @@ namespace Decompiler @@ -165,7 +165,7 @@ namespace Decompiler
astType.AddChild(ConvertType(field.FieldType), TypeDeclaration.BaseTypeRole);
} else {
EnumMemberDeclaration enumMember = new EnumMemberDeclaration();
enumMember.Name = field.Name;
enumMember.Name = CleanName(field.Name);
astType.AddChild(enumMember, TypeDeclaration.MemberRole);
}
}
@ -184,6 +184,14 @@ namespace Decompiler @@ -184,6 +184,14 @@ namespace Decompiler
return astType;
}
string CleanName(string name)
{
int pos = name.LastIndexOf('`');
if (pos >= 0)
name = name.Substring(0, pos);
return name;
}
#region Convert Type Reference
/// <summary>
/// Converts a type reference.
@ -453,7 +461,7 @@ namespace Decompiler @@ -453,7 +461,7 @@ namespace Decompiler
MethodDeclaration astMethod = new MethodDeclaration();
astMethod.AddAnnotation(methodDef);
astMethod.ReturnType = ConvertType(methodDef.ReturnType, methodDef.MethodReturnType);
astMethod.Name = methodDef.Name;
astMethod.Name = CleanName(methodDef.Name);
astMethod.TypeParameters.AddRange(MakeTypeParameters(methodDef.GenericParameters));
astMethod.Parameters.AddRange(MakeParameters(methodDef.Parameters));
astMethod.Constraints.AddRange(MakeConstraints(methodDef.GenericParameters));
@ -468,7 +476,7 @@ namespace Decompiler @@ -468,7 +476,7 @@ namespace Decompiler
{
return genericParameters.Select(
gp => new TypeParameterDeclaration {
Name = gp.Name,
Name = CleanName(gp.Name),
Variance = gp.IsContravariant ? VarianceModifier.Contravariant : gp.IsCovariant ? VarianceModifier.Covariant : VarianceModifier.Invariant
});
}
@ -488,7 +496,7 @@ namespace Decompiler @@ -488,7 +496,7 @@ namespace Decompiler
// don't show visibility for static ctors
astMethod.Modifiers &= ~Modifiers.VisibilityMask;
}
astMethod.Name = methodDef.DeclaringType.Name;
astMethod.Name = CleanName(methodDef.DeclaringType.Name);
astMethod.Parameters.AddRange(MakeParameters(methodDef.Parameters));
astMethod.Body = AstMethodBodyBuilder.CreateMethodBody(methodDef, context);
return astMethod;
@ -499,7 +507,7 @@ namespace Decompiler @@ -499,7 +507,7 @@ namespace Decompiler
PropertyDeclaration astProp = new PropertyDeclaration();
astProp.AddAnnotation(propDef);
astProp.Modifiers = ConvertModifiers(propDef.GetMethod ?? propDef.SetMethod);
astProp.Name = propDef.Name;
astProp.Name = CleanName(propDef.Name);
astProp.ReturnType = ConvertType(propDef.PropertyType, propDef);
if (propDef.GetMethod != null) {
astProp.Getter = new Accessor {
@ -518,7 +526,7 @@ namespace Decompiler @@ -518,7 +526,7 @@ namespace Decompiler
{
CustomEventDeclaration astEvent = new CustomEventDeclaration();
astEvent.AddAnnotation(eventDef);
astEvent.Name = eventDef.Name;
astEvent.Name = CleanName(eventDef.Name);
astEvent.ReturnType = ConvertType(eventDef.EventType, eventDef);
astEvent.Modifiers = ConvertModifiers(eventDef.AddMethod);
if (eventDef.AddMethod != null) {
@ -538,7 +546,7 @@ namespace Decompiler @@ -538,7 +546,7 @@ namespace Decompiler
{
FieldDeclaration astField = new FieldDeclaration();
astField.AddAnnotation(fieldDef);
VariableInitializer initializer = new VariableInitializer(fieldDef.Name);
VariableInitializer initializer = new VariableInitializer(CleanName(fieldDef.Name));
astField.AddChild(initializer, FieldDeclaration.Roles.Variable);
astField.ReturnType = ConvertType(fieldDef.FieldType, fieldDef);
astField.Modifiers = ConvertModifiers(fieldDef);

Loading…
Cancel
Save