diff --git a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/MetadataReader.netstandard.cs b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/MetadataReader.netstandard.cs index f33c0455ee2db..a11a8fcacda4e 100644 --- a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/MetadataReader.netstandard.cs +++ b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/MetadataReader.netstandard.cs @@ -85,12 +85,6 @@ public static unsafe AssemblyName GetAssemblyName(string assemblyFile) peReader = new PEReader((byte*)safeBuffer.DangerousGetHandle(), (int)safeBuffer.ByteLength); MetadataReader mdReader = peReader.GetMetadataReader(MetadataReaderOptions.None); AssemblyName assemblyName = mdReader.GetAssemblyDefinition().GetAssemblyName(); - - AssemblyFlags aFlags = mdReader.AssemblyTable.GetFlags(); -#pragma warning disable SYSLIB0037 // AssemblyName.ProcessorArchitecture is obsolete - assemblyName.ProcessorArchitecture = CalculateProcArch(peReader, aFlags); -#pragma warning restore SYSLIB0037 - return assemblyName; } finally @@ -107,42 +101,6 @@ public static unsafe AssemblyName GetAssemblyName(string assemblyFile) } } - private static ProcessorArchitecture CalculateProcArch(PEReader peReader, AssemblyFlags aFlags) - { - // 0x70 specifies "reference assembly". - // For these, CLR wants to return None as arch so they can be always loaded, regardless of process type. - if (((uint)aFlags & 0xF0) == 0x70) - return ProcessorArchitecture.None; - - PEHeaders peHeaders = peReader.PEHeaders; - switch (peHeaders.CoffHeader.Machine) - { - case Machine.IA64: - return ProcessorArchitecture.IA64; - case Machine.Arm: - return ProcessorArchitecture.Arm; - case Machine.Amd64: - return ProcessorArchitecture.Amd64; - case Machine.I386: - { - CorFlags flags = peHeaders.CorHeader!.Flags; - if ((flags & CorFlags.ILOnly) != 0 && - (flags & CorFlags.Requires32Bit) == 0) - { - // platform neutral. - return ProcessorArchitecture.MSIL; - } - - // requires x86 - return ProcessorArchitecture.X86; - } - } - - // ProcessorArchitecture is a legacy API and does not cover other Machine kinds. - // For example ARM64 is not expressible - return ProcessorArchitecture.None; - } - private static AssemblyNameFlags GetAssemblyNameFlags(AssemblyFlags flags) { AssemblyNameFlags assemblyNameFlags = AssemblyNameFlags.None; diff --git a/src/libraries/System.Reflection.Metadata/tests/Metadata/MetadataReaderTests.cs b/src/libraries/System.Reflection.Metadata/tests/Metadata/MetadataReaderTests.cs index 3b946e5a80779..56943320ce5a4 100644 --- a/src/libraries/System.Reflection.Metadata/tests/Metadata/MetadataReaderTests.cs +++ b/src/libraries/System.Reflection.Metadata/tests/Metadata/MetadataReaderTests.cs @@ -3095,7 +3095,7 @@ public void GetAssemblyName() Assert.Equal(new AssemblyName(a.FullName).ToString(), name.ToString()); #pragma warning disable SYSLIB0037 // AssemblyName.ProcessorArchitecture is obsolete - Assert.Equal(ProcessorArchitecture.MSIL, name.ProcessorArchitecture); + Assert.Equal(ProcessorArchitecture.None, name.ProcessorArchitecture); #pragma warning restore SYSLIB0037 } }