TorchAPI / Torch

An extensible modding framework and improved client/DS for Space Engineers. Still a work in progress!
Apache License 2.0
146 stars 76 forks source link

Add injecting of private class fields into patching methods #360

Closed sirhamsteralot closed 4 years ago

sirhamsteralot commented 4 years ago

Code by equinox™ testing underway.

--ps there is only one file changed despite the 5 commits, probably should make them into one commit.

Equinox- commented 4 years ago

Fix your formatting

rexxar-tc commented 4 years ago

Anyone built a test case for this yet?

sirhamsteralot commented 4 years ago

I'm just going to do this now, if i can get torch to build i will test it with a little test plugin aswell.

sirhamsteralot commented 4 years ago

Tested by Prefixing UpdateMassFromInventories and changing a gridname in m_grid to check later if all grids were changed. Test Code: https://imgur.com/plu82W9 Results: https://imgur.com/HwfE1y6 After a while nothing gets renamed anymore because everything has been successfully renamed and so the field got properly injected. The results were also successfull without using the argument with ref: https://imgur.com/qPwUAfC

To test it working with statics m_removalResults was accessed and the size of the list was output: https://imgur.com/7GkBakB Result, only after manually removing a block on a grid: https://imgur.com/QJe7amP This shows its not null and the correct values are actually being inserted.

(these are terrible tests i know but at least it shows that the feature is now working).