Harmony
Harmony copied to clipboard
When applying a patch fails, the replacement's IL is not printed to the debug log
Describe the bug
When using the [HarmonyDebug] attributes or setting Harmony.DEBUG = true, the replacement's IL should be logged to the Harmony.log.txt file. However, when the construction of the method fails because of Cecil, no replacement IL is logged.
To Reproduce
- Create a patch that fails to apply due to an error in Cecil (not sure what exactly was the problem...)
- Observe that no replacement IL is logged.
Expected behavior The IL constructed for the replacement should always be logged, before it is finalized with Cecil and potentially fails to log.
Screenshots / Code See Reproduction.
Runtime environment (please complete the following information):
- OS: Windows 10, 64bit
- .NET version: Mono, 5.11.0 as .NET Framework 4.6.57.0
- Harmony version: 2.3.1 (thin)
- Name of game or host application: Resonite
Additional context Discussion in discord starting here: https://discord.com/channels/131466550938042369/361891646742462467/1215048908628299787
Transpiler are chained and their results is collected, then logged. If an exceptions occurs in a transpiler there is no result yet. Which means there is nothing to log.
If an exceptions occurs in a transpiler there is no result yet.
But there is no exception in the transpiler - the exception occurs in Cecil when Harmony tries to "compile" the CodeInstructions back into a replacement method. But it looks like the logging only occurs after that step, which makes it hard to tell what the problem with the IL was.