From a0e45cbea0713b1889f79d81c70a0da8c32682d6 Mon Sep 17 00:00:00 2001 From: Leigh Pointer Date: Sat, 13 Dec 2025 12:55:24 +0100 Subject: [PATCH] Add null checks for RenderModeBoundary in ModuleBase methods Add null checks to key ModuleBase methods to ensure RenderModeBoundary is available before use. Throw a detailed InvalidOperationException with guidance if it is missing, improving error handling and developer feedback. --- Oqtane.Client/Modules/ModuleBase.cs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Oqtane.Client/Modules/ModuleBase.cs b/Oqtane.Client/Modules/ModuleBase.cs index 264930c4..43851818 100644 --- a/Oqtane.Client/Modules/ModuleBase.cs +++ b/Oqtane.Client/Modules/ModuleBase.cs @@ -372,6 +372,11 @@ namespace Oqtane.Modules } // UI methods + private static readonly string RenderModeBoundaryErrorMessage = + "RenderModeBoundary is not available. This method requires a RenderModeBoundary parameter. " + + "If you are using child components, ensure you pass the RenderModeBoundary property to the child component: " + + ""; + public void AddModuleMessage(string message, MessageType type) { AddModuleMessage(message, type, "top"); @@ -389,21 +394,37 @@ namespace Oqtane.Modules public void AddModuleMessage(string message, MessageType type, string position, MessageStyle style) { + if (RenderModeBoundary == null) + { + throw new InvalidOperationException(RenderModeBoundaryErrorMessage); + } RenderModeBoundary.AddModuleMessage(message, type, position, style); } public void ClearModuleMessage() { + if (RenderModeBoundary == null) + { + throw new InvalidOperationException(RenderModeBoundaryErrorMessage); + } RenderModeBoundary.AddModuleMessage("", MessageType.Undefined); } public void ShowProgressIndicator() { + if (RenderModeBoundary == null) + { + throw new InvalidOperationException(RenderModeBoundaryErrorMessage); + } RenderModeBoundary.ShowProgressIndicator(); } public void HideProgressIndicator() { + if (RenderModeBoundary == null) + { + throw new InvalidOperationException(RenderModeBoundaryErrorMessage); + } RenderModeBoundary.HideProgressIndicator(); }