Folks, I’m facing a very weird issue which arises only on Android device. Specifically, one of the int arguments passed to a method once passed to another nested method changes its value to some really weird value.
The code is something as follows:
public static uint GetRating(Item item, int level = 0) {
return (uint)(GetBaseRating(item, level) * GetRatingCoeff());
}
public static GetBaseRating(Item item, int level) {
…
}
Here’s what happens:
- Some code calls GetRating(item, 0);
- Inside GetRating variable level == 0, this was checked with the log
- When GetBaseRating is called, inside its scope level == 121679560 (or some other weird value)
After hours of pulling out my hair I simply changed arguments order of GetBaseOrder to this GetBaseRating(int level, Item item), and everything is just fine now!
I went a bit further and compared CIL opcodes for both versions of the code. But there is nothing suspicious.
I wonder if there’s some known issue and if there any ways to avoid such Mono runtime misbehaviour.