Search Issue Tracker

Fixed in 2023.1.X

Fixed in 2020.3.X, 2021.3.X, 2022.1.X

Votes

0

Found in

2020.3

2021.3

2021.3.0f1

2022.1

2022.2

Issue ID

1422119

Regression

Yes

[IL2CPP] Assembly.GetType returns a nested Class when the nested Class is defined before the non-nested one

IL2CPP

-

Reproduction steps:
1. Open the attached project "Case_1422119.zip" and load Scene "Assembly.GetType"
2. Ensure IL2CPP is selected as the Scripting Backend in Project Settings and "Development Build" is checked in Build Settings
3. Build and Run the Project
4. Observe the errors thrown in the Build

Expected result: The following errors are thrown:
"ClassA found in Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null: ClassA."
"ClassB not found in Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null."
Actual result: The following errors are thrown:
"ClassA found in Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null: ClassParent+ClassA."
"ClassB found in Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null: ClassParent+ClassB."

Reproducible with: 2020.2.0a18, 2020.3.35f1, 2021.3.3f1, 2022.1.1f1, 2022.2.0a14
Not reproducible with: 2019.4.39f1, 2020.1.17f1
Could not test with: 2020.2.0a1 - 2020.2.0a17 (Building the project fails)

Notes:
- The project contains 2 definitions of ClassA: one is nested inside the ClassParent and one is defined outside of it. ClassB is nested inside ClassParent as well
- The ClassA found by GetType is the one that is defined first (in this case, ClassParent is defined before ClassA, thus the ClassA nested inside ClassParent is the one that is found)
- Not reproducible in Editor, Mono Builds, and C# Console Application

  1. Resolution Note (fix version 2023.1):

    Fixed in 2023.1.0a1

  2. Resolution Note (fix version 2022.1):

    Fixed in 2022.1.8f1

  3. Resolution Note (fix version 2021.3):

    Fixed in 2021.3.7f1

  4. Resolution Note (fix version 2020.3):

    Fixed in 2020.3.38f1

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.