Open snamds opened 5 months ago
Describe the bug The patch I wanna do works when built with x64/AnyCPU platform but it doesn't work with x86 platform
To Reproduce
public static void Patch() { Harmony harmony = new Harmony("TestPatch"); foreach (Type type in Assembly.GetAssembly(typeof(TimeZone)).GetTypes() .Where(myType => myType.IsClass && !myType.IsAbstract && myType.IsSubclassOf(typeof(TimeZone)))) { MethodInfo originalMethod1 = type.GetMethod("ToLocalTime"); var preFixMethodInfo1 = typeof(Program).GetMethod("PrefixTest", BindingFlags.Static | BindingFlags.NonPublic); HarmonyMethod prefix1 = new HarmonyMethod(preFixMethodInfo1); harmony.Patch(originalMethod1, prefix1, null, null, null); } } static void Main(string[] args) { Patch(); DateTime date3 = TimeZone.CurrentTimeZone.ToLocalTime(DateTime.Now); } static bool PrefixTest(ref DateTime __result, DateTime __0) { __result = DateTime.UtcNow; return false; }
The result is quite random. AccessViolationException / System.ExecutionEngineException / random "date3" values returned
Expected behavior TimeZone.CurrentTimeZone.ToLocalTime with the current prefix code should return DateTime.UtcNow
Runtime environment (please complete the following information):
Additional context Add any other context about the problem here.
This most likely tried to patch unsupported types/methods (generic or external).
Describe the bug The patch I wanna do works when built with x64/AnyCPU platform but it doesn't work with x86 platform
To Reproduce
The result is quite random. AccessViolationException / System.ExecutionEngineException / random "date3" values returned
Expected behavior TimeZone.CurrentTimeZone.ToLocalTime with the current prefix code should return DateTime.UtcNow
Runtime environment (please complete the following information):
Additional context Add any other context about the problem here.