From d294908353ad2485a013d60b0f7615296c2ae2af 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 5bca46b2d..790fa9a61 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 443fdc657223fb681a52598be358d2a43baa9795 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 790fa9a61..a28574fcd 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(); }