Skip to content

Commit

Permalink
recognize AnyCPU in case of fallback to PEReader
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoRossignoli committed Jan 28, 2022
1 parent 41ab9c0 commit 31c8150
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/vstest.console/CommandLine/AssemblyMetadataProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,28 @@ private Architecture GetArchitectureFromAssemblyMetadata(string path)
switch (peReader.PEHeaders.CoffHeader.Machine)
{
case Machine.Amd64:
return Architecture.X64;
case Machine.IA64:
return Architecture.X64;
case Machine.Arm64:
return Architecture.ARM64;
case Machine.Arm:
return Architecture.ARM;
case Machine.I386:
return Architecture.X86;
// If requires 32bit or if R2R
var corflags = peReader.PEHeaders.CorHeader.Flags;
if ((corflags & CorFlags.Requires32Bit) != 0 || ((corflags & CorFlags.ILOnly) == 0))
{
return Architecture.X86;
}
else
{
return Architecture.AnyCPU;
}
default:
break;
{
EqtTrace.Error($"AssemblyMetadataProvider.GetArchitecture: Unhandled architecture '{peReader.PEHeaders.CoffHeader.Machine}'");
break;
}
}
}

Expand Down

0 comments on commit 31c8150

Please sign in to comment.