From be5d24dd7aa74114e4dcfb83a748f85a230cea94 Mon Sep 17 00:00:00 2001 From: Youssef Fahmy Date: Sat, 2 May 2026 10:30:38 +0200 Subject: [PATCH 1/2] Avoid Castle's default trace logging --- src/Moq/Interception/CastleProxyFactory.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Moq/Interception/CastleProxyFactory.cs b/src/Moq/Interception/CastleProxyFactory.cs index c17d9be42..3d893cb87 100644 --- a/src/Moq/Interception/CastleProxyFactory.cs +++ b/src/Moq/Interception/CastleProxyFactory.cs @@ -14,6 +14,7 @@ using System.Text; #endif +using Castle.Core.Logging; using Castle.DynamicProxy; using Moq.Internals; @@ -33,7 +34,11 @@ sealed class CastleProxyFactory : ProxyFactory public CastleProxyFactory() { this.generationOptions = new ProxyGenerationOptions { Hook = new IncludeObjectMethodsHook(), BaseTypeForInterfaceProxy = typeof(InterfaceProxy) }; - this.generator = new ProxyGenerator(); + this.generator = new ProxyGenerator() + { + Logger = NullLogger.Instance, + }; + this.classGenerators = new ConcurrentDictionary(); } From eba608b085de318341622491ae36d86dd1f222fc Mon Sep 17 00:00:00 2001 From: Youssef Fahmy Date: Mon, 4 May 2026 21:43:57 +0200 Subject: [PATCH 2/2] Force warn --- src/Moq/Interception/CastleProxyFactory.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Moq/Interception/CastleProxyFactory.cs b/src/Moq/Interception/CastleProxyFactory.cs index 3d893cb87..5971422a2 100644 --- a/src/Moq/Interception/CastleProxyFactory.cs +++ b/src/Moq/Interception/CastleProxyFactory.cs @@ -34,10 +34,8 @@ sealed class CastleProxyFactory : ProxyFactory public CastleProxyFactory() { this.generationOptions = new ProxyGenerationOptions { Hook = new IncludeObjectMethodsHook(), BaseTypeForInterfaceProxy = typeof(InterfaceProxy) }; - this.generator = new ProxyGenerator() - { - Logger = NullLogger.Instance, - }; + this.generator = new ProxyGenerator(); + (this.generator.Logger as TraceLogger)?.Level = LoggerLevel.Warn; this.classGenerators = new ConcurrentDictionary(); }