public RenamedClass SearchForNewName(EntityName target) { if (name.NameNew != null) { if (target.Compare(NameNew)) { return(this); } if (target.Compare(NameNewFull)) { return(this); } } foreach (RenamedBase item in items) { if (item.EntityType != EntityType.Class) { continue; } RenamedClass c = (RenamedClass)item; c = c.SearchForNewName(target); if (c != null) { return(c); } } return(null); }
private void SubstituteParams(IList <EntityName> p) { for (int i = 0; i < p.Count; i++) { EntityName paramName = null; try { string[] values = p[i].PathName.Split('.'); foreach (RenamedBase item in SearchItem(values)) { paramName = item.Name.NameOld; } } catch { } if (paramName == null) { foreach (RenamedClass item in SearchClassNoNs(p[i].Name)) { paramName = item.Name.NameOld; } } if (paramName != null) { p[i] = paramName; } } }
private string BuildName(string className, string ownName, bool useNew, bool isShort) { if (className == null) { className = string.Empty; } else { className = className + "."; } string result; if (resultType == null) { result = "void"; } else { EntityName resultName = useNew ? resultType.NameNew : resultType.NameOld; result = SystemTypeProcessor.SimplifyType(resultName, !isShort); } if (entityType == EntityType.Method) { return(string.Format("{0} {1}{2}({3})", result, className, ownName, MethodParamList(isShort, useNew))); } if (resultType != null) { return(string.Format("{0} {1}{2}", result, className, ownName)); } return(string.Format("{0}{1}", className, ownName)); }
public bool Compare(EntityName to, bool ignoreNs) { if (!(ignoreNs && (@namespace == null || to.@namespace == null)) && string.Compare(@namespace, to.@namespace, StringComparison.Ordinal) != 0) { return(false); } return(string.Compare(name, to.name, StringComparison.Ordinal) == 0); }
public bool CompareNamespace(EntityName entityName) { int i = 0; if (entityName.nsCache == null) { return(true); } return(CompareNamespace(entityName.nsCache, ref i)); }
public RenamedBase SearchForOldName(EntityName target) { foreach (RenamedClass renamedClass in classes) { RenamedClass c = renamedClass.SearchForOldName(target); if (c != null) { return(c); } } return(null); }
public EntityName(string value) { if (value == string.Empty) { name = value; return; } if (value[0] == '[') { int i = value.IndexOf(']'); module = value.Substring(1, i - 1); value = value.Substring(i + 1); } int j = value.IndexOf('<'); if (j != -1 && value[value.Length - 1] == '>') { List<string> p = new List<string>(ParseList(value, j + 1, '>')); value = value.Substring(0, j); genericParams = new EntityName[p.Count]; for (int q = 0; q < p.Count; q++) genericParams[q] = new EntityName(p[q]); } j = value.IndexOf('`'); if (j != -1) value = value.Substring(0, j); char delimiter = '\0'; if (value.IndexOf(':') != -1) delimiter = ':'; else if (value.IndexOf('.') != -1) delimiter = '.'; if (delimiter != '\0') { int i = value.LastIndexOf(delimiter); while (i > 0 && value[i - 1] == delimiter) i--; @namespace = value.Substring(0, i); nsCache = @namespace.Split('.'); while (i < value.Length && value[i] == delimiter) i++; value = value.Substring(i); } name = value; }
public RenamedBase SearchForOldName(EntityName target) { RenamedClass c; if (classesCache.TryGetValue(target.Name, out c)) { return(c); } if (classesCache.TryGetValue(target.FullName, out c)) { return(c); } return(null); }
public Entity(string s) { methodParams = BuildParams(ref s); s = s.TrimEnd(' '); int i = s.IndexOf(' '); if (i == -1) name = s; else { string res = s.Substring(0, i); if (res != "void") result = res; name = s.Substring(i).TrimStart(' '); } }
private IEnumerable <RenamedBase> SearchItemOriginal(EntityName name) { string[] values; try { values = name.PathName.Split('.'); } catch { yield break; } foreach (RenamedBase renamedItem in SearchItemOriginal(values)) { yield return(renamedItem); } }
public void AssignName(EntityName entityName) { name = entityName.name; @namespace = entityName.@namespace; if (entityName.nsCache != null) { nsCache = new string[entityName.nsCache.Length]; for (int i = 0; i < entityName.nsCache.Length; i++) { nsCache[i] = entityName.nsCache[i]; } } else { nsCache = null; } module = entityName.module; }
public static string SimplifyType(EntityName value, bool fullName) { // fallback for case which should never happen if (value == null) { return("??"); } if (Configs.Instance.SimplifySystemNames && (string.IsNullOrEmpty(value.Namespace) || value.Namespace == "System")) { string result; if (replacements.TryGetValue(value.Name, out result)) { return(result); } } return(fullName ? value.PathName : value.Name); }
public Entity(string s) { methodParams = BuildParams(ref s); s = s.TrimEnd(' '); int i = s.IndexOf(' '); if (i == -1) { name = s; } else { string res = s.Substring(0, i); if (res != "void") { result = res; } name = s.Substring(i).TrimStart(' '); } }
public bool Compare(string name) { int i = name.IndexOf('('); EntityName ename = name.Substring(0, i); if (!ename.Compare(this.name.NameNew, false)) { return(false); } int j = name.IndexOf(')', i); string p = name.Substring(i + 1, j - i - 1); string[] strings = p.Split(new string[] { ", ", "," }, StringSplitOptions.RemoveEmptyEntries); if (strings.Length != methodParams.Count) { return(false); } for (int k = 0; k < strings.Length; k++) { string s = strings[k].Trim(' '); if (s == "*") { continue; } EntityName e = s; if (!e.Compare(methodParams[k].NameNew, true)) { return(false); } } return(true); }
public override bool Equals(object obj) { if (ReferenceEquals(this, obj)) { return(true); } EntityName target = null; if (obj is string) { target = new EntityName(obj as string); } if (obj is EntityName) { target = (EntityName)obj; } if (target == null) { return(false); } return(Compare(target, false)); }
public Entity(Entity entity, RenamedBase item, IList <EntityName> methodParams) { this.methodParams = new List <EntityName>(methodParams); result = entity.result; name = item.NameOldFull + "." + entity.name.Name; }
public RenamedBase SearchForOldName(EntityName target) { foreach (RenamedClass renamedClass in classes) { RenamedClass c = renamedClass.SearchForOldName(target); if (c != null) return c; } return null; }
private IEnumerable<RenamedBase> SearchItemOriginal(EntityName name) { string[] values; try { values = name.PathName.Split('.'); } catch { yield break; } foreach (RenamedBase renamedItem in SearchItemOriginal(values)) yield return renamedItem; }
public RenamedItem(NanoXmlElement el, RenamedClass owner) { try { this.owner = owner; entityType = (EntityType)Enum.Parse(typeof(EntityType), el.Name.Substring(7)); string str = el.GetAttribute("oldName"); int i; if ((i = str.IndexOf(' ')) != -1) { string s = str.Substring(0, i); int k = s.IndexOf('/'); if (k != -1) { resultType = new RenamedParam(s.Substring(0, k) + "." + s.Substring(k + 1)); } else { resultType = new RenamedParam(s); } str = str.Substring(i + 1); } if ((i = str.IndexOf("::")) != -1) { str = str.Substring(i + 2); } if ((i = str.IndexOf('(')) != -1) { methodParams = new List <RenamedParam>(); foreach (string s in EntityName.ParseList(str, i + 1, ')')) { int k = s.IndexOf('/'); if (k != -1) { methodParams.Add(new RenamedParam(s.Substring(0, k) + "." + s.Substring(k + 1))); } else { methodParams.Add(new RenamedParam(s)); } } str = str.Substring(0, i); i = str.IndexOf('['); if (i != -1 && str[i + 2] == ']') { str = str.Substring(0, i); } } string strNew = el.GetAttribute("newName"); if (strNew != "dropped") { name = new Renamed(str, strNew); } else { name = new Renamed(str); } } catch (Exception e) { throw new ObfuscarParserException("Failed to process item element", e, el.Path); } }
public void AssignName(EntityName entityName) { name = entityName.name; @namespace = entityName.@namespace; if (entityName.nsCache != null) { nsCache = new string[entityName.nsCache.Length]; for (int i = 0; i < entityName.nsCache.Length; i++) nsCache[i] = entityName.nsCache[i]; } else nsCache = null; module = entityName.module; }
public bool Compare(EntityName to, bool ignoreNs) { if (!(ignoreNs && (@namespace == null || to.@namespace == null)) && string.Compare(@namespace, to.@namespace, StringComparison.Ordinal) != 0) return false; return string.Compare(name, to.name, StringComparison.Ordinal) == 0; }
public EntityName(string value) { if (value == string.Empty) { name = value; return; } if (value[0] == '[') { int i = value.IndexOf(']'); module = value.Substring(1, i - 1); value = value.Substring(i + 1); } int j = value.IndexOf('<'); if (j != -1 && value[value.Length - 1] == '>') { List <string> p = new List <string>(ParseList(value, j + 1, '>')); value = value.Substring(0, j); genericParams = new EntityName[p.Count]; for (int q = 0; q < p.Count; q++) { genericParams[q] = new EntityName(p[q]); } } j = value.IndexOf('`'); if (j != -1) { value = value.Substring(0, j); } char delimiter = '\0'; if (value.IndexOf(':') != -1) { delimiter = ':'; } else if (value.IndexOf('.') != -1) { delimiter = '.'; } if (delimiter != '\0') { int i = value.LastIndexOf(delimiter); while (i > 0 && value[i - 1] == delimiter) { i--; } @namespace = value.Substring(0, i); nsCache = @namespace.Split('.'); while (i < value.Length && value[i] == delimiter) { i++; } value = value.Substring(i); } name = value; }
public override bool Equals(object obj) { if (ReferenceEquals(this, obj)) return true; EntityName target = null; if (obj is string) target = new EntityName(obj as string); if (obj is EntityName) target = (EntityName)obj; if (target == null) return false; return Compare(target, false); }
public bool CompareNamespace(EntityName entityName) { int i = 0; if (entityName.nsCache == null) return true; return CompareNamespace(entityName.nsCache, ref i); }
private EntityName(string ns, string[] nsCache, string name, string module, EntityName[] genericParams) { @namespace = ns; if (nsCache != null) { this.nsCache = new string[nsCache.Length]; for (int i = 0; i < nsCache.Length; i++) this.nsCache[i] = nsCache[i]; } if (genericParams != null) { this.genericParams = new EntityName[genericParams.Length]; for (int i = 0; i < genericParams.Length; i++) this.genericParams[i] = new EntityName( genericParams[i].@namespace, genericParams[i].nsCache, genericParams[i].name, genericParams[i].module, genericParams[i].genericParams ); } this.name = name; this.module = module; }
public Entity(Entity entity, RenamedBase item, IList<EntityName> methodParams) { this.methodParams = new List<EntityName>(methodParams); result = entity.result; name = item.NameOldFull + "." + entity.name.Name; }