mirror of
https://github.com/soarqin/DSP_Mods.git
synced 2026-11-19 17:05:20 +08:00
refactor: phase 5 transpiler docs, mod-compat helpers, and build quality gates
This commit is contained in:
1 parent
cca8b8594d
commit
c2016909ff
43 files changed
+2327
-135
No files matched your search
@@ -0,0 +1,28 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection.Emit;
|
||||
using BepInEx.Logging;
|
||||
using HarmonyLib;
|
||||
|
||||
namespace UXAssist.Common.Patching;
|
||||
|
||||
/// <summary>
|
||||
/// Helper for Harmony transpilers. Provides a standardized way to bail out and return the original
|
||||
/// instructions when a <see cref="CodeMatcher"/> fails to match, which makes version-fragile patches
|
||||
/// easier to diagnose at runtime.
|
||||
/// </summary>
|
||||
public static class TranspilerGuard
|
||||
{
|
||||
public static IEnumerable<CodeInstruction> Finish(
|
||||
this CodeMatcher matcher,
|
||||
IEnumerable<CodeInstruction> originalInstructions,
|
||||
ManualLogSource logger,
|
||||
string transpilerName)
|
||||
{
|
||||
if (matcher.IsInvalid)
|
||||
{
|
||||
logger?.LogWarning($"Transpiler '{transpilerName}' failed to match; returning original instructions.");
|
||||
return originalInstructions;
|
||||
}
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user