Skip to content

Fix incorrect class casts#593

Merged
notfood merged 1 commit intorwmt:devfrom
ianleeder:fix-incorrect-casts
Jul 21, 2025
Merged

Fix incorrect class casts#593
notfood merged 1 commit intorwmt:devfrom
ianleeder:fix-incorrect-casts

Conversation

@ianleeder
Copy link

For 1.6

My PR #576 was flawed. I saw a pattern and ran with it, relying too much on the compiler to catch any errors. My bad.

Thanks to @Tick-git for highlighting the issue. Many of these CodeInstruction operands weren't actually MethodInfo. The problem is that they shared common classes (a lot were FieldInfo which extends from MethodInfo), so the compiler let it all slide.

I've gone through this twice to ensure I'm casting to the correct classes now.

According to Tick this should resolve #590.

Note: Tick also pointed out that Harmony provides a bunch of extensions for doing these comparisons (for example .Calls(MethodInfo method) or .LoadsField(FieldInfo field)). I looked briefly at updating the code to use these, but I'm not confident enough with the Reflection and patches to ensure it's doing the right thing (for example .Calls() makes checks on the instruction.opcode before doing an equality check)

@notfood notfood added fix Fixes for a bug or desync. 1.5 Fixes or bugs relating to 1.5 (Not Anomaly). 1.6 Fixes or bugs relating to 1.6 (Not Odyssey). labels Jul 21, 2025
@notfood
Copy link
Member

notfood commented Jul 21, 2025

I think I prefer having the warning rather than the guessing.

@notfood notfood moved this to In review in 1.6 and Odyssey Jul 21, 2025
@notfood notfood merged commit 17e3347 into rwmt:dev Jul 21, 2025
1 check passed
@github-project-automation github-project-automation bot moved this from In review to Done in 1.6 and Odyssey Jul 21, 2025
@notfood notfood moved this to Backlog in Backports Jul 21, 2025
@notfood notfood removed this from Backports Jul 21, 2025
@notfood notfood removed the 1.5 Fixes or bugs relating to 1.5 (Not Anomaly). label Jul 21, 2025
@ianleeder ianleeder deleted the fix-incorrect-casts branch August 15, 2025 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1.6 Fixes or bugs relating to 1.6 (Not Odyssey). fix Fixes for a bug or desync.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants