From 2c159addf8948e1089371b7f69787999eef51ee8 Mon Sep 17 00:00:00 2001 From: Artur Gordashnikov Date: Mon, 20 Jan 2025 13:02:51 +0200 Subject: [PATCH] Fix closure --- src/Castle.Core/DynamicProxy/Internal/InvocationHelper.cs | 2 +- src/Castle.Core/DynamicProxy/ProxyUtil.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Castle.Core/DynamicProxy/Internal/InvocationHelper.cs b/src/Castle.Core/DynamicProxy/Internal/InvocationHelper.cs index bad0f3d854..c6a0c70357 100644 --- a/src/Castle.Core/DynamicProxy/Internal/InvocationHelper.cs +++ b/src/Castle.Core/DynamicProxy/Internal/InvocationHelper.cs @@ -50,7 +50,7 @@ public static MethodInfo GetMethodOnType(Type type, MethodInfo proxiedMethod) var cacheKey = new CacheKey(proxiedMethod, type); - return cache.GetOrAdd(cacheKey, ck => ObtainMethod(proxiedMethod, type)); + return cache.GetOrAdd(cacheKey, static ck => ObtainMethod(ck.Method, ck.Type)); } private static MethodInfo ObtainMethod(MethodInfo proxiedMethod, Type type) diff --git a/src/Castle.Core/DynamicProxy/ProxyUtil.cs b/src/Castle.Core/DynamicProxy/ProxyUtil.cs index 5adc871fb4..79bd611769 100644 --- a/src/Castle.Core/DynamicProxy/ProxyUtil.cs +++ b/src/Castle.Core/DynamicProxy/ProxyUtil.cs @@ -162,9 +162,9 @@ public static bool IsAccessible(Type type) /// The assembly to inspect. internal static bool AreInternalsVisibleToDynamicProxy(Assembly asm) { - return internalsVisibleToDynamicProxy.GetOrAdd(asm, a => + return internalsVisibleToDynamicProxy.GetOrAdd(asm, static a => { - var internalsVisibleTo = asm.GetCustomAttributes(); + var internalsVisibleTo = a.GetCustomAttributes(); return internalsVisibleTo.Any(attr => attr.AssemblyName.Contains(ModuleScope.DEFAULT_ASSEMBLY_NAME)); }); }