From 40f826a11be0178f9bf0878c97dd818b69f367c4 Mon Sep 17 00:00:00 2001 From: Charlie Poole Date: Thu, 28 Nov 2024 08:48:01 -0800 Subject: [PATCH] Extract code from loop --- .../nunit.engine.core/Services/ExtensionManager.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/NUnitEngine/nunit.engine.core/Services/ExtensionManager.cs b/src/NUnitEngine/nunit.engine.core/Services/ExtensionManager.cs index 5becf2a7d..ecd770db8 100644 --- a/src/NUnitEngine/nunit.engine.core/Services/ExtensionManager.cs +++ b/src/NUnitEngine/nunit.engine.core/Services/ExtensionManager.cs @@ -15,6 +15,8 @@ namespace NUnit.Engine.Services { public class ExtensionManager : IExtensionManager { + static readonly Version CURRENT_ENGINE_VERSION = Assembly.GetExecutingAssembly().GetName().Version; + static readonly Logger log = InternalTrace.GetLogger(typeof(ExtensionManager)); private readonly IFileSystem _fileSystem; @@ -472,9 +474,7 @@ internal void FindExtensionsInAssembly(ExtensionAssembly assembly) string versionArg = extensionAttr.GetNamedArgument("EngineVersion") as string; if (versionArg != null) { - Assembly THIS_ASSEMBLY = Assembly.GetExecutingAssembly(); - Version ENGINE_VERSION = THIS_ASSEMBLY.GetName().Version; - if (new Version(versionArg) > ENGINE_VERSION) + if (new Version(versionArg) > CURRENT_ENGINE_VERSION) { log.Warning($" Ignoring {extensionType.Name}. It requires version {versionArg}."); continue;