Skip to content

Commit

Permalink
Release v2.3.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
pardeike committed Mar 3, 2024
1 parent 39d924d commit 0126028
Show file tree
Hide file tree
Showing 10 changed files with 64 additions and 310 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>

<PropertyGroup>
<HarmonyVersion>2.3.1.0</HarmonyVersion>
<HarmonyVersion>2.3.1.1</HarmonyVersion>
<HarmonyPrerelease></HarmonyPrerelease>
<MonoModCoreVersion>1.1.0</MonoModCoreVersion>
</PropertyGroup>
Expand Down
2 changes: 0 additions & 2 deletions Harmony.sln
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
.editorconfig = .editorconfig
.gitattributes = .gitattributes
.gitignore = .gitignore
azure-pipelines-job-template.yml = azure-pipelines-job-template.yml
azure-pipelines.yml = azure-pipelines.yml
CNAME = CNAME
CODE_OF_CONDUCT.md = CODE_OF_CONDUCT.md
Directory.Build.props = Directory.Build.props
Expand Down
62 changes: 31 additions & 31 deletions Harmony/Documentation/articles/new.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,43 @@ Harmony 2 has come a long way since the last release 1.2.0.1. Here are all the c

#### 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
CI/CD with GitHub Actions
Switched to `MonoMod.Core` 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
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
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`
16 changes: 9 additions & 7 deletions Harmony/Documentation/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ It supports **Mono** and **.NET** environments on Windows, Unix and macOS except

Designed to be used by multiple users (usually called Mods) that would otherwise override each others hooks, it was originally created for the game [RimWorld](https://rimworldgame.com) and its large modding community by [Andreas Pardeike](https://www.patreon.com/pardeike).

Enjoy!
Enjoy!
/Andreas Pardeike

# Getting Started

Installation is usually done by copying and referencing [0Harmony.dll](https://github.com/pardeike/Harmony/releases) from your project or by using the [Lib.Harmony](https://www.nuget.org/packages/Lib.Harmony) nuget package.
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

Expand All @@ -27,7 +29,7 @@ If you find a factual error or if you have feedback about the documentation you
- file a documentation Issue on the repo
- or write about it on the official discord

**New to modding and C#?** Beside the basic language features you need at least a good overview of **Reflection** in C#. Read this short and useful [introduction](https://dotnetcademy.net/Learn/4/Pages/1).
**New to modding and C#?** Beside the basic language features you need at least a good overview of **Reflection** in C#. Read this short and useful [introduction](https://dotnetcademy.net/Learn/4/Pages/1).

## Community

Expand All @@ -37,11 +39,11 @@ Help by promoting this library so other developers can find it. One way is to up

# Contact

Andreas Pardeike
[email protected]
twitter: @pardeike
Andreas Pardeike
[email protected]
twitter: @pardeike

## Donations

Donations keep me going:
Donations keep me going:
[https://www.patreon.com/pardeike](https://www.patreon.com/pardeike)
3 changes: 1 addition & 2 deletions Harmony/Internal/InlineSignatureParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ namespace HarmonyLib
{
internal static class InlineSignatureParser
{
// Based on https://github.com/MonoMod/MonoMod.Common/blob/fb7fed148af165905ee0f2db1bb4c78a0137fb89/Utils/ReflectionHelper.ParseCallSite.cs
// ... which is based on https://github.com/jbevain/cecil/blob/96026325ee1cb6627a3e4a32b924ab2905f02553/Mono.Cecil/AssemblyReader.cs#L3448
// Based on code of MonoMod, which is based on https://github.com/jbevain/cecil/blob/96026325ee1cb6627a3e4a32b924ab2905f02553/Mono.Cecil/AssemblyReader.cs#L3448

internal static InlineSignature ImportCallSite(Module moduleFrom, byte[] data)
{
Expand Down
2 changes: 1 addition & 1 deletion Harmony/Internal/MethodCopier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ internal List<CodeInstruction> FinalizeILCodes(Emitter emitter, List<MethodInfo>
var cecilGenerator = generator.GetProxiedShim<CecilILGenerator>();
if (cecilGenerator is null)
{
// Right now InlineSignatures can only be emitted using MonoMod.Common and its CecilILGenerator.
// Right now InlineSignatures can only be emitted using MonoMod and its CecilILGenerator.
// That is because DynamicMethod's original ILGenerator is very restrictive about the calli opcode.
throw new NotSupportedException();
}
Expand Down
4 changes: 2 additions & 2 deletions Harmony/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

[assembly: ComVisible(false)]
[assembly: InternalsVisibleTo("HarmonyTests")]
// MonoMod.Common uses IgnoresAccessChecksTo on its end,
// MonoMod.Core uses IgnoresAccessChecksTo on its end,
// but older versions of the .NET runtime bundled with older versions of Windows
// require Harmony to expose its internals instead.
// This is only relevant for when MonoMod.Common gets merged into Harmony.
// This is only relevant for when MonoMod.Core gets merged into Harmony.
[assembly: InternalsVisibleTo("MonoMod.Utils.Cil.ILGeneratorProxy")]
[assembly: Guid("69aee16a-b6e7-4642-8081-3928b32455df")]
37 changes: 19 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<p align="center">
<img src="https://raw.githubusercontent.com/pardeike/Harmony/master/HarmonyLogo.png" alt="Harmony" width="180" /><br>
<b>Version 2</b><br>
<b>Version 2.3</b><br>
A library for patching, replacing and decorating<br>
.NET and Mono methods during runtime.
</p>
Expand All @@ -15,15 +15,17 @@ It is also used in unit testing WPF 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
• 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.
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

Expand All @@ -33,9 +35,9 @@ Please check out the [documentation](https://harmony.pardeike.net) and join the

I put thousands of hours into this project and its 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)
• 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

This project uses the great [MonoMod.Core](https://github.com/MonoMod) library by [0x0ade](https://github.com/0x0ade) and [nike4613](https://github.com/nike4613).

Expand All @@ -46,20 +48,19 @@ Harmony 1 is deprecated and not under active development anymore. The latest ver
<br>&nbsp;

<p align="center">
<a href="../../releases/latest"><img src="https://img.shields.io/github/release/pardeike/harmony.svg?style=flat" /></a>
<a href="https://www.nuget.org/packages/lib.harmony"><img src="https://img.shields.io/nuget/v/lib.harmony.svg?style=flat" /></a>
<a href="https://harmony.pardeike.net"><img src="https://img.shields.io/badge/documentation-%F0%9F%94%8D-blue?style=flat" /></a>
<a href="../../blob/master/LICENSE"><img src="https://img.shields.io/github/license/pardeike/harmony.svg?style=flat-squared&label=License" /></a>
<a href="../../releases/latest"><img src="https://img.shields.io/github/release/pardeike/harmony.svg?style=flat-squared&label=Release" /></a>
<a href="https://harmony.pardeike.net"><img src="https://img.shields.io/badge/documentation-%F0%9F%94%8D-9cf?style=flat-squared&label=Documentation" /></a>
</p>
<p align="center">
<a href="https://github.com/pardeike/Harmony/actions/workflows/test.yml"><img src="https://github.com/pardeike/Harmony/actions/workflows/test.yml/badge.svg" /></a>
<a href="https://dev.azure.com/pardeike/Harmony/_build"><img src="https://pardeike.visualstudio.com/Harmony/_apis/build/status/Build%20and%20test" /></a>
<a href="https://github.com/pardeike/Harmony/releases/latest"><img src="https://img.shields.io/github/downloads/pardeike/Harmony/total.svg?style=flat-squared&logo=github&color=009900&label=Release%20Downloads" /></a>
<a href="https://www.nuget.org/packages/Lib.Harmony"><img src="https://img.shields.io/nuget/dt/Lib.Harmony?style=flat-squared&logo=nuget&label=Nuget%20Downloads&color=009900" /></a>
</p>
<p align="center">
<a href="https://github.com/pardeike/Harmony/releases/latest"><img src="https://img.shields.io/github/downloads/pardeike/Harmony/total.svg?style=flat&logo=github" /></a>
<a href="https://discord.gg/xXgghXR"><img src="https://img.shields.io/discord/131466550938042369.svg?style=flat&logo=discord&label=discord" /></a>
<a href="../../blob/master/LICENSE"><img src="https://img.shields.io/github/license/pardeike/harmony.svg?style=flat" /></a>
<a href="https://github.com/pardeike/Harmony/actions/workflows/test.yml"><img src="https://img.shields.io/github/actions/workflow/status/pardeike/Harmony/test.yml?style=flat-squared&logo=github&label=CI%20Tests" /></a>
<a href="https://discord.gg/xXgghXR"><img src="https://img.shields.io/discord/131466550938042369.svg?style=flat-squared&logo=discord&label=Official%20Discord" /></a>
</p>
<p align="center">
<a href="mailto:[email protected]"><img src="https://img.shields.io/badge/[email protected]?style=flat" /></a>
<a href="https://twitter.com/pardeike"><img src="https://img.shields.io/badge/[email protected]?style=flat&logo=twitter" /></a>
<a href="mailto:[email protected]"><img src="https://img.shields.io/badge/[email protected]?style=flat-squared&label=Email" /></a>
<a href="https://twitter.com/pardeike"><img src="https://img.shields.io/badge/[email protected]?style=flat-squared&logo=twitter&label=Twitter" /></a>
</p>
Loading

0 comments on commit 0126028

Please sign in to comment.