runtime: Reflection regression - Type.GetType does not skip leading `.`

Description

Type.GetType does not find the type when type name starts with . (dot)…

Reproduction Steps

class MyType
{
    static void Main() => Console.WriteLine(Type.GetType(".MyType"));
}

Expected behavior

Type is found

Actual behavior

Type is not found

Regression?

Yes, this used to work on SDK 8.0.100-preview.4.23171.22

Known Workarounds

No response

Configuration

SDK 8.0.100-preview.4.23210.1 macOS-11.6.7 x64

Other information

No response

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 17 (17 by maintainers)

Commits related to this issue

Most upvoted comments

@EgorBo Thank you for taking a look!

The problem is in Type.GetType API and it affects all platforms (it is not OSX specific). I have updated the description. assembly.GetType(".GlobalNamespaceContextModel") is the statement in the repro that triggered the issue.

The issue is that Type.GetType implementation had a quirk that made it ignore leading . in the type name. The new managed type name parser is missing this quirk.