-
Notifications
You must be signed in to change notification settings - Fork 44
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
Add global flag to disallow global UnpatchAll behavior #40
Add global flag to disallow global UnpatchAll behavior #40
Conversation
Greetings! Thank you for the PR! Here are a few points/questions:
Instead, how about the following:
I am a bit hesitant to allow throwing an exception on UnpatchAll and instead would rather use the current logging system along with the obsoletion flag. |
I think obsoleting UnpatchAll and adding a static version that's explicit in its purpose would be the best bet. Unpatching a specific ID would be better done with a separate method like UnpatchID to make its actions clearer. |
Heya, I'll try my best to answer your questions, but if anything is unclear or you disagree with something, feel free to let me know.
In regard to the suggestions:
I'll gladly accept any help I can get for this though 🙂 |
How do you handle error reporting and logging? What information does a user see if a plugin throws an exception? Does it prevent other plugins from being loaded? After all, exceptions cause stack unwinding, which can cause other game logic not to run correctly. In that sense, instead of throwing an exception, the flag could log a warning like A long-term solution for preventing modders from using the method would be to mark
I think that's probably the best way to go. To summarise:
Feel free to comment on the suggestion.
That remark is probably old and should be removed. Right now, unpatching works by creating a It would undoubtedly require a little bit of fiddling, but you can essentially replace current |
Looking at it, the whole obsoletion and new methods might be out of the scope of this PR. As such, if you don't think you want/can make the new methods, I'm fine if this PR just adds the flag as you initially proposed. Although I still suggest thinking about whether the flag will cause a Of course, I don't mind if you make the new methods in this PR; I just thought it might get out of scope for this PR. |
The use of an exception was suggested to me, but if you rather prefer simply logging and returning, then I'll adjust it accordingly. As for the whole obsoletion and introduction of new methods, I'm fine with trying to do that as well. But preferably, I'd like to do that in a new PR so we can at least go ahead with a version that contains this change as it might take me some time to figure things out 🙂 |
This PR, as the title implies, adds a global flag to disallow the global UnpatchAll behavior.
This is an opt-in flag to keep binary compatibility and not introduce unexpected behavior by default, this while still being able to disallow the default behavior by turning on the flag.
Reasoning for introducing this flag is that, in certain contexts, it is often undesirable to unpatch every single patch at once
For example, in the case of modloaders where mods can be enabled/disabled at runtime and where accidentally calling the
.UnpatchAll()
method without an id, could break a whole bunch of other mods.