Replace unnecessary string.Replace in ManifestBuilder.GetTypeName (#80557)
authorStephen Toub <stoub@microsoft.com>
Thu, 12 Jan 2023 22:40:26 +0000 (17:40 -0500)
committerGitHub <noreply@github.com>
Thu, 12 Jan 2023 22:40:26 +0000 (17:40 -0500)
src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs

index c543aff..007b4dd 100644 (file)
@@ -5879,7 +5879,14 @@ namespace System.Diagnostics.Tracing
             if (type.IsEnum)
             {
                 string typeName = GetTypeName(type.GetEnumUnderlyingType());
-                return typeName.Replace("win:Int", "win:UInt"); // ETW requires enums to be unsigned.
+                return typeName switch // ETW requires enums to be unsigned.
+                {
+                    "win:Int8" => "win:UInt8",
+                    "win:Int16" => "win:UInt16",
+                    "win:Int32" => "win:UInt32",
+                    "win:Int64" => "win:UInt64",
+                    _ => typeName,
+                };
             }
 
             switch (Type.GetTypeCode(type))