Remove extra checks for known types in log formatter (#89000)
authorDavid Fowler <davidfowl@gmail.com>
Mon, 17 Jul 2023 14:21:20 +0000 (10:21 -0400)
committerGitHub <noreply@github.com>
Mon, 17 Jul 2023 14:21:20 +0000 (10:21 -0400)
Turns out the JIT will not box in tier 1, this was trying to optimize tier 0 code.

src/libraries/Microsoft.Extensions.Logging.Abstractions/src/LogValuesFormatter.cs

index 253c9f2..beae39c 100644 (file)
@@ -265,13 +265,6 @@ namespace Microsoft.Extensions.Logging
 
         private static bool TryFormatArgumentIfNullOrEnumerable<T>(T? value, [NotNullWhen(true)] ref object? stringValue)
         {
-            // Avoiding boxing of known types
-            if (typeof(T).IsPrimitive || typeof(T).IsEnum)
-            {
-                stringValue = null;
-                return false;
-            }
-
             if (value == null)
             {
                 stringValue = NullValue;