Skip to content

Commit

Permalink
Delete dead WinRT code in Activator (#55721)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichalStrehovsky authored Jul 16, 2021
1 parent 62fa1f8 commit e828a01
Showing 1 changed file with 3 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -118,32 +116,18 @@ 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);
}
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);

Expand Down

0 comments on commit e828a01

Please sign in to comment.