From 1d2a78979f5ee231be69518d698e97c886ec5ce9 Mon Sep 17 00:00:00 2001 From: de4dot Date: Thu, 10 May 2012 19:00:12 +0200 Subject: [PATCH] Use generic prop creator if the type has a generic parameter --- de4dot.code/renamer/VariableNameState.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/de4dot.code/renamer/VariableNameState.cs b/de4dot.code/renamer/VariableNameState.cs index 67dcd0d4..a877a2fa 100644 --- a/de4dot.code/renamer/VariableNameState.cs +++ b/de4dot.code/renamer/VariableNameState.cs @@ -89,7 +89,7 @@ namespace de4dot.code.renamer { public string getNewPropertyName(PropertyDefinition propertyDefinition) { var propType = propertyDefinition.PropertyType; string newName; - if (propType is GenericParameter) + if (isGeneric(propType)) newName = existingPropertyNames.getName(propertyDefinition.Name, genericPropertyNameCreator); else newName = existingPropertyNames.getName(propertyDefinition.Name, () => propertyNameCreator.create(propType)); @@ -97,6 +97,17 @@ namespace de4dot.code.renamer { return newName; } + static bool isGeneric(TypeReference type) { + while (true) { + if (type is GenericParameter) + return true; + var ts = type as TypeSpecification; + if (ts == null) + return false; + type = ts.ElementType; + } + } + public string getNewEventName(EventDefinition eventDefinition) { string newName = eventNameCreator.create(); addEventName(newName);