Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When applying a patch fails, the replacement's IL is not printed to the debug log #597

Open
Banane9 opened this issue Mar 6, 2024 · 2 comments
Assignees

Comments

@Banane9
Copy link

Banane9 commented Mar 6, 2024

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.

Harmony.log.txt output with blank replacements

Exception that caused the patch to fail

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

@pardeike
Copy link
Owner

pardeike commented Mar 7, 2024

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.

@Banane9
Copy link
Author

Banane9 commented Mar 7, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants