Skip to content
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

Patch method generation fail should not mark the patch as applied #52

Open
ghorsington opened this issue Jul 29, 2022 · 0 comments
Open
Labels
enhancement New feature or request

Comments

@ghorsington
Copy link
Contributor

ghorsington commented Jul 29, 2022

This needs more testing but based on initial reports:

When patch method generation fails, it appears that the patch is still marked as applied. This is likely because patch info is saved into a global state before the patch method is updated:

var patchInfo = original.ToPatchInfo();
patchInfo.AddPrefixes(instance.Id, prefix);
patchInfo.AddPostfixes(instance.Id, postfix);
patchInfo.AddTranspilers(instance.Id, transpiler);
patchInfo.AddFinalizers(instance.Id, finalizer);
patchInfo.AddILManipulators(instance.Id, ilmanipulator);
var replacement = PatchFunctions.UpdateWrapper(original, patchInfo);
PatchManager.AddReplacementOriginal(original, replacement);
return replacement;

same for all other places where PatchFunctions.UpdateWrapper is called.

This causes more issues when trying to unpatch or add more patches in.

The logic should be refined as follows:

  • Update the patch state
  • Generate patch method and apply it
  • If the patch method cannot be applied, revert the patch info to the previous state

A functionally more stable approach might be to back up the previous patch state so it can be quickly restored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant