Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pardeike/Harmony
A library for patching, replacing and decorating .NET and Mono methods during runtime
https://github.com/pardeike/Harmony
cil csharp detour detours dotnet monkey-patching mono non-destructive patcher runtime unity
Last synced: 3 months ago
JSON representation
A library for patching, replacing and decorating .NET and Mono methods during runtime
- Host: GitHub
- URL: https://github.com/pardeike/Harmony
- Owner: pardeike
- License: mit
- Created: 2017-01-04T09:43:16.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2024-10-27T19:43:09.000Z (3 months ago)
- Last Synced: 2024-10-29T14:50:46.658Z (3 months ago)
- Topics: cil, csharp, detour, detours, dotnet, monkey-patching, mono, non-destructive, patcher, runtime, unity
- Language: C#
- Homepage: https://www.patreon.com/pardeike
- Size: 15.9 MB
- Stars: 5,268
- Watchers: 98
- Forks: 492
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- awesome-unity3d - Harmony - A library for patching, replacing and decorating .NET and Mono methods during runtime. (Open Source Repositories / Modding)
- awesome-dotnet - Lib.Harmony - Rewrite mono and C# methods at the runtime, Either write a method that will be executed, or edit the code of the method in IL, mainly used for game modding. (Compilers, Transpilers and Languages)
README
Version 2.3
A library for patching, replacing and decorating
.NET and Mono methods during runtime.### About
Harmony gives you an elegant and high level way to alter the functionality in applications written in C#. It works great in games and is well established in titles like
• **Rust**
• **Rimworld**
• **7 Days To Die**
• **Stardew Valley**
• **Subnautica**
• **Oxygen Not Included**
• **Besiege**
• **Cities:Skylines**
• **Kerbal Space Program**
• **Resonite**
• **BattleTech**
• **Slime Rancher**and others like Ravenfield, Sheltered, Staxel, The Ultimate Nerd Game, Total Miner, Unturned, SCP: Secret Laboratory ...
It is also used in unit testing WPF controls at Microsoft and Google and in many other areas.
### How it works
If you develop in C# and your code is loaded as a module/plugin into a host application, you can use Harmony to alter the functionality of all the available assemblies of that application. Where other patch libraries simply allow you to replace the original method, Harmony goes one step further and gives you:
• A way to keep the original method intact
• Execute your code before and/or after the original method
• Modify the original with IL code processors
• Multiple Harmony patches co-exist and don't conflict with each other
• Works at runtime and does not touch any files### Installation
If you want a single file, dependency-merged assembly, you should use the [Lib.Harmony](https://www.nuget.org/packages/Lib.Harmony) nuget package. This is the **preferred** way.
If you instead want to supply the dependencies yourself, you should use the [Lib.Harmony.Thin](https://www.nuget.org/packages/Lib.Harmony.Thin) nuget package. You get more control but you are responsible to make all references available at runtime.
### Documentation
Please check out the [documentation](https://harmony.pardeike.net) and join the official [discord server](https://discord.gg/xXgghXR).
### Contribute
I put thousands of hours into this project and its support. So every little action helps:
• Become a [GitHub sponsor](https://github.com/sponsors/pardeike) or a [Patreon](https://www.patreon.com/pardeike)
• Upvote this [stackoverflow answer](https://stackoverflow.com/questions/7299097/dynamically-replace-the-contents-of-a-c-sharp-method/42043003#42043003)
• Spread the word in your developer communitiesThis project uses the great [MonoMod.Core](https://github.com/MonoMod) library by [0x0ade](https://github.com/0x0ade) and [nike4613](https://github.com/nike4613).
### Harmony 1
Harmony 1 is deprecated and not under active development anymore. The latest version of it (v1.2.0.1) is stable and contains only minor bugs. Keep using it if you are in an environment that exclusively uses Harmony 1. Currently Harmony 1.x and 2.x are **NOT COMPATIBLE** with each other and **SHOULD NOT BE MIXED**. The old documentation can still be found at the [Wiki](https://github.com/pardeike/Harmony/wiki).