Skip to content

AssemblyName.GetPublicKeyToken() may return byte[160] instead of byte[8] #69153

@AArnott

Description

@AArnott

This is a regression in .NET 7, possibly due to #62866.
This only repros when the AssemblyName is obtained from AssemblyName.GetAssemblyName when passed the path to an ILMerge output assembly.

Consider the following test:

string assemblyPath = Environment.ExpandEnvironmentVariables("ILmergeProduced.dll");
Assert.Equal(8, AssemblyName.GetAssemblyName(this.assemblyPath).GetPublicKeyToken()?.Length)

That test passes on net472 and net6.0, but fails on net7.0 with:

Assert.Equal() Failure
Expected: 8
Actual:   160

Consider this full repro.
Just open in VS and run tests in Test Explorer (assuming .NET 7 Preview 5 is installed).

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions