From cff416d42a097b6f30538f7483f2d563ffd5faa6 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 a6d1861e5c4dbc3038214d6df777a831256002f2 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(); }