From 5c5a30fe9ff3e678589a77c9b23328f8d5290444 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Thu, 15 Jul 2021 10:15:20 +0200 Subject: [PATCH 1/3] Delete dead WinRT code in Activator --- .../src/System/Activator.RuntimeType.cs | 22 +++---------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Activator.RuntimeType.cs b/src/libraries/System.Private.CoreLib/src/System/Activator.RuntimeType.cs index 2ccdc5c741dbf..0979451f8f1c6 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Activator.RuntimeType.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Activator.RuntimeType.cs @@ -102,8 +102,6 @@ public static partial class Activator [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "Implementation detail of Activator that linker intrinsically recognizes")] - [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2057:UnrecognizedReflectionPattern", - Justification = "Implementation detail of Activator that linker intrinsically recognizes")] [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2072:UnrecognizedReflectionPattern", Justification = "Implementation detail of Activator that linker intrinsically recognizes")] [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2096:UnrecognizedReflectionPattern", @@ -118,8 +116,7 @@ public static partial class Activator object?[]? activationAttributes, ref StackCrawlMark stackMark) { - Type? type = null; - Assembly? assembly = null; + Assembly assembly; if (assemblyString == null) { assembly = Assembly.GetExecutingAssembly(ref stackMark); @@ -127,23 +124,10 @@ public static partial class Activator else { AssemblyName assemblyName = new AssemblyName(assemblyString); - - if (assemblyName.ContentType == AssemblyContentType.WindowsRuntime) - { - // WinRT type - we have to use Type.GetType - type = Type.GetType(typeName + ", " + assemblyString, throwOnError: true, ignoreCase); - } - else - { - // Classic managed type - assembly = RuntimeAssembly.InternalLoad(assemblyName, ref stackMark, AssemblyLoadContext.CurrentContextualReflectionContext); - } + assembly = RuntimeAssembly.InternalLoad(assemblyName, ref stackMark, AssemblyLoadContext.CurrentContextualReflectionContext); } - if (type == null) - { - type = assembly!.GetType(typeName, throwOnError: true, ignoreCase); - } + Type type = assembly!.GetType(typeName, throwOnError: true, ignoreCase); object? o = CreateInstance(type!, bindingAttr, binder, args, culture, activationAttributes); From cd8ecfb1f059cb23fcdf2a3eb23fe0ee97eb2a66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Thu, 15 Jul 2021 10:16:42 +0200 Subject: [PATCH 2/3] Missed nullable junk --- .../src/System/Activator.RuntimeType.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Activator.RuntimeType.cs b/src/libraries/System.Private.CoreLib/src/System/Activator.RuntimeType.cs index 0979451f8f1c6..7e0f76114b4d1 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Activator.RuntimeType.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Activator.RuntimeType.cs @@ -127,9 +127,9 @@ public static partial class Activator assembly = RuntimeAssembly.InternalLoad(assemblyName, ref stackMark, AssemblyLoadContext.CurrentContextualReflectionContext); } - Type type = assembly!.GetType(typeName, throwOnError: true, ignoreCase); + Type type = assembly.GetType(typeName, throwOnError: true, ignoreCase); - object? o = CreateInstance(type!, bindingAttr, binder, args, culture, activationAttributes); + object? o = CreateInstance(type, bindingAttr, binder, args, culture, activationAttributes); return o != null ? new ObjectHandle(o) : null; } From 13c5a500a3bd3107e3df77f1881af85287f868d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Thu, 15 Jul 2021 15:23:07 +0200 Subject: [PATCH 3/3] Huh? --- .../src/System/Activator.RuntimeType.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Activator.RuntimeType.cs b/src/libraries/System.Private.CoreLib/src/System/Activator.RuntimeType.cs index 7e0f76114b4d1..1f1643d21fd2b 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Activator.RuntimeType.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Activator.RuntimeType.cs @@ -127,9 +127,9 @@ public static partial class Activator assembly = RuntimeAssembly.InternalLoad(assemblyName, ref stackMark, AssemblyLoadContext.CurrentContextualReflectionContext); } - Type type = assembly.GetType(typeName, throwOnError: true, ignoreCase); + Type? type = assembly.GetType(typeName, throwOnError: true, ignoreCase); - object? o = CreateInstance(type, bindingAttr, binder, args, culture, activationAttributes); + object? o = CreateInstance(type!, bindingAttr, binder, args, culture, activationAttributes); return o != null ? new ObjectHandle(o) : null; }