static int AppendMethod(MethodDefinition method) { string methodSignature = GetMethodSignature(method); string methodFullSignature = method.FullName; InjectedMethodInfo newInfo = new InjectedMethodInfo(); string typeName = ToLuaInjectionHelper.GetTypeName(method.DeclaringType, true); List <InjectedMethodInfo> typeMethodIndexGroup = null; bridgeInfo.TryGetValue(typeName, out typeMethodIndexGroup); if (typeMethodIndexGroup == null) { typeMethodIndexGroup = new List <InjectedMethodInfo>(); newInfo.methodPublishedName = method.Name; bridgeInfo.Add(typeName, typeMethodIndexGroup); } else { InjectedMethodInfo existInfo = typeMethodIndexGroup.Find(info => info.methodOverloadSignature == methodSignature); if (existInfo == null) { existInfo = typeMethodIndexGroup.Find(info => info.methodName == method.Name); if (existInfo != null) { newInfo.methodPublishedName = methodSignature; existInfo.methodPublishedName = existInfo.methodOverloadSignature; } else { newInfo.methodPublishedName = method.Name; } } else { if (existInfo.methodFullSignature != methodFullSignature) { Debug.LogError(typeName + "." + existInfo.methodPublishedName + " 签名跟历史签名不一致,无法增量,Injection中断,请修改函数签名、或者直接删掉InjectionBridgeEditorInfo.xml(该操作会导致无法兼容线上版的包体,需要强制换包)!"); EditorPrefs.SetInt(Application.dataPath + "WaitForInjection", 0); return(-1); } return(existInfo.methodIndex); } } newInfo.methodName = method.Name; newInfo.methodOverloadSignature = methodSignature; newInfo.methodFullSignature = methodFullSignature; newInfo.methodIndex = ++methodCounter; typeMethodIndexGroup.Add(newInfo); return(methodCounter); }
static bool LoadBridgeEditorInfo() { bridgeInfo.Clear(); methodCounter = 0; string incrementalFilePath = CustomSettings.injectionFilesPath + "InjectionBridgeEditorInfo.xml"; if (!File.Exists(incrementalFilePath)) { return(true); } var doc = new XmlDocument(); doc.Load(incrementalFilePath); var fileInfoRoot = doc.FindChildByName("Root"); if (fileInfoRoot == null) { return(true); } foreach (XmlNode typeChild in fileInfoRoot.ChildNodes) { List <InjectedMethodInfo> typeMethodInfo = new List <InjectedMethodInfo>(); string typeName = typeChild.FindAttributeByName("Name").Value; foreach (XmlNode methodChild in typeChild.ChildNodes) { InjectedMethodInfo info = new InjectedMethodInfo(); info.methodName = methodChild.FindAttributeByName("Name").Value; info.methodPublishedName = methodChild.FindAttributeByName("PublishedName").Value; info.methodOverloadSignature = methodChild.FindAttributeByName("Signature").Value; info.methodFullSignature = methodChild.FindAttributeByName("FullSignature").Value; info.methodIndex = int.Parse(methodChild.FindAttributeByName("Index").Value); typeMethodInfo.Add(info); methodCounter = Math.Max(methodCounter, info.methodIndex); } bridgeInfo.Add(typeName, typeMethodInfo); } return(true); }