From a945960cef0ae21dda95099fa7156f9808e128e4 Mon Sep 17 00:00:00 2001 From: Tomas Kracmar Date: Fri, 6 Nov 2026 08:02:34 +0100 Subject: [PATCH] fix(khdb): fail clearly when a stale compiled type is loaded in the session Add-Type cannot replace a type that an older build of KhdbMerge.ps1 already defined, so an updated PasswordQuality.ps1 failed with "does not contain a method named 'Inspect'". Check for the newest method after the guarded Add-Type and tell the operator to start a new PowerShell session. --- src/Elysium/Private/KhdbMerge.ps1 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Elysium/Private/KhdbMerge.ps1 b/src/Elysium/Private/KhdbMerge.ps1 index 7fcc469..2a80ed4 100644 --- a/src/Elysium/Private/KhdbMerge.ps1 +++ b/src/Elysium/Private/KhdbMerge.ps1 @@ -203,3 +203,9 @@ namespace Elysium } '@ } + +# A compiled type cannot be replaced inside a running process. If an older build of this file already +# defined it (module re-imported or scripts updated in a long-lived console), fail with the fix. +if (-not [Elysium.KhdbText].GetMethod('Inspect')) { + throw 'Elysium.KhdbText is loaded from an older build in this PowerShell process. Close this window and start a new one.' +}