//private string getAllStaticFields() //{ // string result = ""; // HashSet<FieldInfo> fieldInfos = new HashSet<FieldInfo>(); // foreach(Type type in Assembly.Load("Assembly-CSharp").GetTypes()) // { // foreach(FieldInfo fieldInfo in type.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static)) // { // fieldInfos.Add(fieldInfo); // //result += type.FullName + " " + fieldInfo.FieldType.Attributes + " " + fieldInfo.Name + "\n"; // } // } // foreach (Type type in Assembly.Load("Assembly-CSharp").GetTypes()) // { // foreach (MethodInfo methodInfo in type.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance)) // { // List<CodeInstruction> codeInstructions = PatchProcessor.GetOriginalInstructions(methodInfo, out ILGenerator iLGenerator); // int i = 0; // while(i < codeInstructions.Count) // { // if(codeInstructions[i].opcode == OpCodes.Ldsfld) { // if (codeInstructions[i + 1].opcode == OpCodes.Call || codeInstructions[i + 1].opcode == OpCodes.Callvirt) // { // MethodInfo instructionMethodInfo = (MethodInfo)codeInstructions[i + 1].operand; // if (instructionMethodInfo.Name.Equals("Clear") && instructionMethodInfo.DeclaringType.FullName.Contains("System.Collections")) // { // FieldInfo fieldInfo = (FieldInfo)codeInstructions[i].operand; // Log.Message(fieldInfo.FieldType.Name + " " + fieldInfo.DeclaringType.FullName + "." + fieldInfo.Name); // } // } // } // i++; // } // } // } // MethodBase methodBase = null; // methodBase.GetMethodBody().GetILAsByteArray(); // return result; //} public static string getPotentialModConflicts() { string modsText = ""; IEnumerable <MethodBase> originalMethods = Harmony.GetAllPatchedMethods(); foreach (MethodBase originalMethod in originalMethods) { Patches patches = Harmony.GetPatchInfo(originalMethod); if (patches is null) { } else { Patch[] sortedPrefixes = patches.Prefixes.ToArray(); PatchProcessor.GetSortedPatchMethods(originalMethod, sortedPrefixes); bool isRimThreadedPrefixed = false; string modsText1 = ""; foreach (Patch patch in sortedPrefixes) { if (patch.owner.Equals("majorhoff.rimthreaded") && !RimThreadedHarmony.nonDestructivePrefixes.Contains(patch.PatchMethod) && (patches.Prefixes.Count > 1 || patches.Postfixes.Count > 0 || patches.Transpilers.Count > 0)) { isRimThreadedPrefixed = true; modsText1 = "\n ---Patch method: " + patch.PatchMethod.DeclaringType.FullName + " " + patch.PatchMethod + "---\n"; modsText1 += " RimThreaded priority: " + patch.priority + "\n"; break; } } if (isRimThreadedPrefixed) { bool rimThreadedPatchFound = false; bool headerPrinted = false; foreach (Patch patch in sortedPrefixes) { if (patch.owner.Equals("majorhoff.rimthreaded")) { rimThreadedPatchFound = true; } if (!patch.owner.Equals("majorhoff.rimthreaded") && rimThreadedPatchFound) { //Settings.modsText += "method: " + patch.PatchMethod + " - "; if (!headerPrinted) { modsText += modsText1; } headerPrinted = true; modsText += " owner: " + patch.owner + " - "; modsText += " priority: " + patch.priority + "\n"; } } //foreach (Patch patch in patches.Postfixes) //{ // //Settings.modsText += "method: " + patch.PatchMethod + " - "; // modsText += " owner: " + patch.owner + " - "; // modsText += " priority: " + patch.priority + "\n"; //} foreach (Patch patch in patches.Transpilers) { if (!headerPrinted) { modsText += modsText1; } headerPrinted = true; //Settings.modsText += "method: " + patch.PatchMethod + " - "; modsText += " owner: " + patch.owner + " - "; modsText += " priority: " + patch.priority + "\n"; } } } } return(modsText); }