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

Add null/zero return clarifcations for TargetMethod/s #544

Merged
merged 1 commit into from
Aug 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion Harmony/Documentation/articles/patching-auxilary.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ static MethodBase TargetMethod(...)
static MethodBase CalculateMethod(...)
```

That method, if it exists, is expected to return a `MethodBase` of the method to be patched.
That method, if it exists, is expected to return a `MethodBase` of the method to be patched. The return cannot be null. If you want to conditionally skip patching, use a `Prepare()` method.

### TargetMethods

Expand All @@ -59,6 +59,8 @@ A typical implementation would `yield` the results like this:

[!code-csharp[example](../examples/patching-auxilary.cs?name=yield)]

Similar to `TargetMethod`, the implementation cannot return zero results. If you want to conditionally skip patching, use a `Prepare()` method.

### Cleanup

After patching, Harmony gives you a chance to clean up your state. For this, Harmony searches for a method called
Expand Down