15adhami/XmlExtensions

ApplyPatch should check if number of arguments matches the number of parameter defined in PatchDef

Closed this issue · 1 comments

I've recently run into a situation where I've taken out a parameter from a PatchDef and missed removing the matching argument from ApplyPatch in two of the places where it was called. This caused no errors on game start and lead to hard to debug issues down the road.

The reason is that if there are less arguments than parameters the PatchOperation fails while substituting the variables, however when there are more arguments than parameters, the patch just ignores the superfluous ones.

I would like ApplyPatch to fail in either case and print an error message like the following to the debug log:
"Error: PatchDef <Name> expects <numParam> parameters but <numArg> were provided."

Sadly, I know enough C# to see where it goes wrong but not enough to fix it properly. I also lack a proper build environment. Otherwise I would have sent in a PullRequest.

If I'm being unclear or if you need any more information, please ask.

Thank you for the report. I've just updated the mod on Steam to include your suggestion.