Changes

Jump to navigation Jump to search
update, expand a bit
Line 1: Line 1:  
←[[Modding:Index|Index]]
 
←[[Modding:Index|Index]]
   −
{{SMAPI upcoming|3.''x''}}
+
{{SMAPI upcoming|3.6}}
    
'''This page is for modders. Players: see [[Modding:Mod compatibility]] instead.'''
 
'''This page is for modders. Players: see [[Modding:Mod compatibility]] instead.'''
Line 9: Line 9:  
__TOC__
 
__TOC__
   −
==What's new?==
+
==For modders==
See the [https://github.com/pardeike/Harmony/releases/tag/v2.0.0 Harmony 2.0 release notes] and [https://harmony.pardeike.net Harmony 2.0 documentation] for more info.
+
===What's new?===
 +
See the [https://github.com/pardeike/Harmony/releases/tag/v2.0.0 Harmony 2.0 release notes] and [https://harmony.pardeike.net Harmony 2.0 documentation] for more info. Harmony 2.0 also has stricter validation in general, so invalid patches that would previously work (e.g. setting <tt>__result</tt> to the wrong type) will now cause errors.
   −
==Migration steps==
+
===Migration steps===
 
# Make sure you follow best practices outlined in the [[Modding:Modder Guide/APIs/Harmony|Harmony guide]]. In particular, use the <code>EnableHarmony</code> option (don't reference the Harmony DLL directly) and use the code API.
 
# Make sure you follow best practices outlined in the [[Modding:Modder Guide/APIs/Harmony|Harmony guide]]. In particular, use the <code>EnableHarmony</code> option (don't reference the Harmony DLL directly) and use the code API.
 
# Change <code>using Harmony;</code> to <code>using HarmonyLib;</code>.
 
# Change <code>using Harmony;</code> to <code>using HarmonyLib;</code>.
Line 20: Line 21:  
That's it! Otherwise usage should be identical.
 
That's it! Otherwise usage should be identical.
   −
==Troubleshooting==
+
===Troubleshooting===
==="You can only patch implemented methods/constructors"===
+
; "You can only patch implemented methods/constructors"
Consider this example:
+
: Consider this example:
<source lang="C#">
+
: <source lang="C#">
 
public class GameLocation
 
public class GameLocation
 
{
 
{
Line 32: Line 33:  
</source>
 
</source>
   −
<tt>Farm.cleanupBeforePlayerExit</tt> doesn't exist, so <tt>Farm</tt> inherits it from <tt>GameLocation</tt>. Harmony 1.x would let you patch <tt>Farm.cleanupBeforePlayerExit</tt>, but in Harmony 2.x you must target the actual method (<tt>GameLocation.cleanupBeforePlayerExit</tt> in this example).
+
: <tt>Farm.cleanupBeforePlayerExit</tt> doesn't exist, so <tt>Farm</tt> inherits it from <tt>GameLocation</tt>. Harmony 1.x would let you patch <tt>Farm.cleanupBeforePlayerExit</tt>, but in Harmony 2.x you must target the actual method (<tt>GameLocation.cleanupBeforePlayerExit</tt> in this example).
 +
 
 +
==Mod compatibility==
 +
SMAPI automatically rewrites most Harmony 1.''x'' mods for compatibility, though some mods may break due to Harmony 2.0 changes that can't be handled automatically (e.g. stricter validation). This rewriting will be removed in SMAPI 4.0, so mod authors should update their code when possible even if it still works for now.
    
[[Category:Modding]]
 
[[Category:Modding]]
translators
8,411

edits

Navigation menu