Conversation
Reviewer's GuideThis PR bolsters patch reliability by introducing HarmonyFinalizer hooks across all patches for exception logging, standardizes class and method access modifiers to internal/private for consistency, and streamlines patch declarations by specifying targets directly in the HarmonyPatch attributes. Sequence diagram for exception handling in patch finalizerssequenceDiagram
participant PatchedMethod as Patched Method
participant PatchClass as Patch Finalizer
participant Logger as MarseyLogger
PatchedMethod->>PatchClass: Exception thrown
PatchClass->>Logger: Fatal($"Error while patching <PatchName>: {__exception}")
Class diagram for updated patch classes with HarmonyFinalizerclassDiagram
class ConsoleHostPatch {
+[HarmonyPatch("Robust.Client.Console.ClientConsoleHost", "CanExecute")]
-Postfix(ref bool __result)
-Finalizer(Exception __exception)
}
class ClientHeavyAttackPatch {
+[HarmonyPatch(typeof(MeleeWeaponSystem), "ClientHeavyAttack")]
-Prefix(ref EntityUid user, ...)
-Finalizer(Exception __exception)
}
class DrawOcclusionDepthPatch {
+[HarmonyPatch]
-Prefix()
-Finalizer(Exception __exception)
}
class GunUpdatePatch {
+[HarmonyPatch(typeof(GunSystem), nameof(GunSystem.Update))]
-Transpiler(IEnumerable<CodeInstruction> codes)
-Finalizer(Exception __exception)
}
class ClientAdminManagerPatch {
+[HarmonyPatch]
-Prefix(ref bool __result)
-Finalizer(Exception __exception)
}
class EntityMenuElementPatch {
+[HarmonyPatch]
-Prefix(EntityUid entity, EntityMenuElement __instance, ref string __result)
-Finalizer(Exception __exception)
}
class ClientConGroupControllerPatch {
+[HarmonyPatch]
-Prefix(ref bool __result)
-Finalizer(Exception __exception)
}
class MouseRotatorPatch {
+[HarmonyPatch]
-Prefix()
-Finalizer(Exception __exception)
}
class OverlaysPatch {
+[HarmonyPatch]
-Prefix()
-Finalizer(Exception __exception)
}
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey @noverd - I've reviewed your changes - here's some feedback:
- Consider consolidating the repeated [HarmonyFinalizer] logging logic into a shared helper or base class to reduce boilerplate across all patches.
- Verify that your finalizer signatures match Harmony’s expected signature (usually returning an Exception) so that errors are handled or propagated correctly.
- Double-check that changing patch classes from public to internal doesn’t inadvertently break any external consumers or reflection-based lookups.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider consolidating the repeated [HarmonyFinalizer] logging logic into a shared helper or base class to reduce boilerplate across all patches.
- Verify that your finalizer signatures match Harmony’s expected signature (usually returning an Exception) so that errors are handled or propagated correctly.
- Double-check that changing patch classes from public to internal doesn’t inadvertently break any external consumers or reflection-based lookups.
## Individual Comments
### Comment 1
<location> `ArabicaCliento/Patches/ConsoleHostPatch.cs:13` </location>
<code_context>
}
+
+
+ [HarmonyFinalizer]
+ private static void Finalizer(Exception __exception)
+ {
</code_context>
<issue_to_address>
Finalizer logs all exceptions, which may mask original errors.
Logging without rethrowing may suppress important exceptions and hide bugs. Consider rethrowing after logging or handling only specific exceptions.
</issue_to_address>
### Comment 2
<location> `ArabicaCliento/Patches/DrawOcclusionDepthPatch.cs:14` </location>
<code_context>
}
+
+
+ [HarmonyFinalizer]
+ private static void Finalizer(Exception __exception)
+ {
</code_context>
<issue_to_address>
Finalizer logs exceptions but does not handle or rethrow them.
Consider rethrowing the exception after logging to prevent silent failures and ensure errors are not masked.
</issue_to_address>
### Comment 3
<location> `ArabicaCliento/Patches/GunUpdatePatch.cs:61` </location>
<code_context>
}
+
+
+ [HarmonyFinalizer]
+ private static void Finalizer(Exception __exception)
+ {
</code_context>
<issue_to_address>
Finalizer logs exceptions but does not rethrow.
Evaluate if rethrowing exceptions after logging is necessary to ensure important errors are not silently ignored.
</issue_to_address>
### Comment 4
<location> `ArabicaCliento/Patches/ClientAdminManagerPatch.cs:28` </location>
<code_context>
}
+
+
+ [HarmonyFinalizer]
+ private static void Finalizer(Exception __exception)
+ {
+ MarseyLogger.Fatal($"Error while patching ClientAdminManagerPatch: {__exception}");
+ }
}
</code_context>
<issue_to_address>
Finalizer logs exceptions but does not rethrow.
Suppressing exceptions in the finalizer may conceal errors. Consider rethrowing after logging if needed.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| [HarmonyFinalizer] | ||
| private static void Finalizer(Exception __exception) | ||
| { | ||
| MarseyLogger.Fatal($"Error while patching ConsoleHostPatch: {__exception}"); |
There was a problem hiding this comment.
issue (bug_risk): Finalizer logs all exceptions, which may mask original errors.
Logging without rethrowing may suppress important exceptions and hide bugs. Consider rethrowing after logging or handling only specific exceptions.
| [HarmonyFinalizer] | ||
| private static void Finalizer(Exception __exception) | ||
| { | ||
| MarseyLogger.Fatal($"Error while patching DrawOcclusionDepthPatch: {__exception}"); |
There was a problem hiding this comment.
issue (bug_risk): Finalizer logs exceptions but does not handle or rethrow them.
Consider rethrowing the exception after logging to prevent silent failures and ensure errors are not masked.
| [HarmonyFinalizer] | ||
| private static void Finalizer(Exception __exception) | ||
| { | ||
| MarseyLogger.Fatal($"Error while patching GunUpdatePatch: {__exception}"); |
There was a problem hiding this comment.
issue (bug_risk): Finalizer logs exceptions but does not rethrow.
Evaluate if rethrowing exceptions after logging is necessary to ensure important errors are not silently ignored.
| [HarmonyFinalizer] | ||
| private static void Finalizer(Exception __exception) | ||
| { | ||
| MarseyLogger.Fatal($"Error while patching ClientAdminManagerPatch: {__exception}"); |
There was a problem hiding this comment.
issue (bug_risk): Finalizer logs exceptions but does not rethrow.
Suppressing exceptions in the finalizer may conceal errors. Consider rethrowing after logging if needed.
title 🥇
LocalPlayerAddCompSystemwith generic and replace with type-checking systemsSummary by Sourcery
Add Harmony finalizers for robust error handling in patches, streamline patch definitions, and standardize class modifiers to improve client stability
Enhancements: