Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this code wasn't needed anymore, is

if (contentType == AssemblyContentType.WindowsRuntime)
sb.Append(", ContentType=WindowsRuntime");
still needed?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that can also be removed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that one is reachable:

using System;

Console.WriteLine(AssemblyName.GetAssemblyName(@"C:\Windows\System32\WinMetadata\Windows.UI.winmd"));
Windows.UI, Version=255.255.255.255, Culture=neutral, PublicKeyToken=null, ContentType=WindowsRuntime


object? o = CreateInstance(type!, bindingAttr, binder, args, culture, activationAttributes);

Expand Down