Use generic prop creator if the type has a generic parameter

This commit is contained in:
de4dot 2012-05-10 19:00:12 +02:00
parent f05a334c11
commit 1d2a78979f

View File

@ -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);