public string GetNewEventName(EventDef eventDef) { string newName = eventNameCreator.Create(); AddEventName(newName); return(newName); }
public string CreateNamespace(TypeDef type, string ns) { string newName; string asmFullName; if (type.Module.Assembly != null) { asmFullName = type.Module.Assembly.FullName; } else { asmFullName = "<no assembly>"; } // Make sure that two namespaces with the same names in different modules aren't renamed // to the same name. var key = string.Format(" [{0}] [{1}] [{2}] [{3}] ", type.Module.Location, asmFullName, type.Module.Name, ns); if (namespaceToNewName.TryGetValue(key, out newName)) { return(newName); } return(namespaceToNewName[key] = createNamespaceName.Create()); }
public string Create(TypeSig typeRef) { typeRef = typeRef.RemovePinnedAndModifiers(); if (typeRef == null) { return(unknownNameCreator.Create()); } var gis = typeRef as GenericInstSig; if (gis != null) { if (gis.FullName == "System.Nullable`1" && gis.GenericArguments.Count == 1 && gis.GenericArguments[0] != null) { typeRef = gis.GenericArguments[0]; } } string prefix = GetPrefix(typeRef); var elementType = Renamer.GetScopeType(typeRef); if (elementType == null && IsFnPtrSig(typeRef)) { return(fnPtrNameCreator.Create()); } if (IsGenericParam(elementType)) { return(genericParamNameCreator.Create()); } NameCreator nc; var typeFullName = typeRef.FullName; if (typeNames.TryGetValue(typeFullName, out nc)) { return(nc.Create()); } var fullName = elementType == null ? typeRef.FullName : elementType.FullName; string shortName; var dict = prefix == "" ? fullNameToShortName : fullNameToShortNamePrefix; if (!dict.TryGetValue(fullName, out shortName)) { fullName = fullName.Replace('/', '.'); int index = fullName.LastIndexOf('.'); shortName = index > 0 ? fullName.Substring(index + 1) : fullName; index = shortName.LastIndexOf('`'); if (index > 0) { shortName = shortName.Substring(0, index); } } return(AddTypeName(typeFullName, shortName, prefix).Create()); }