You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by fr...@apache.org on 2026/09/25 07:57:04 UTC

(logging-log4net) 01/01: one home for the reflection in the tests - #326

This is an automated email from the ASF dual-hosted git repository.

FreeAndNil pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-log4net.git

commit 2cb51faa836504e571b4852917fb19450821cac7
Merge: fa011bc4 34fca464
Author: Jan Friedrich <43...@users.noreply.github.com>
AuthorDate: Fri Sep 25 09:56:57 2026 +0200

    one home for the reflection in the tests - #326
    
    One `ReflectionExtensions` in the test assembly replaces 27 hand written lookups over 13 files.
    Test only, no production change, no changelog entry.
    
    ```csharp
    // before
    => (string)typeof(LocalSyslogAppender)
      .GetMethod("EscapePercent", BindingFlags.Static | BindingFlags.NonPublic)!
      .Invoke(null, [message])!;
    
    // after
    => typeof(LocalSyslogAppender).Invoke<string>(nameof(EscapePercent), [message]);
    ```
    
    A renamed member now fails with its own name instead of a `NullReferenceException`.

 src/log4net.Tests/Appender/ContentEscapeTest.cs    |  10 +-
 src/log4net.Tests/Appender/EventLogAppenderTest.cs |  11 +-
 .../Appender/FileAppenderMutexNameTest.cs          |  13 +-
 .../Appender/LocalSyslogAppenderTest.cs            |  34 ++--
 src/log4net.Tests/Appender/LockingStreamTest.cs    |  38 ++---
 src/log4net.Tests/Appender/UdpAppenderTest.cs      |  19 +--
 src/log4net.Tests/Config/XmlConfiguratorTest.cs    |   7 +-
 src/log4net.Tests/Core/LevelMappingTest.cs         |   5 +-
 src/log4net.Tests/Core/LoggingEventTest.cs         |   6 +-
 src/log4net.Tests/Core/UserNameFixingTest.cs       |  16 +-
 src/log4net.Tests/Util/AotCompatibilityTest.cs     |  15 +-
 src/log4net.Tests/Util/ReflectionExtensions.cs     | 174 +++++++++++++++++++++
 src/log4net.Tests/Util/SystemInfoTest.cs           |  42 +++--
 src/log4net.Tests/Util/TransformTest.cs            |   4 +-
 14 files changed, 250 insertions(+), 144 deletions(-)