-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Type.GetType
throws when passed Program&&
#98426
Comments
Tagging subscribers to this area: @dotnet/area-system-reflection Issue DetailsDescriptionWith net7 Reproduction StepsCreate a console application targeting net8 with the following code
Expected behaviorThe output should be
Actual behaviorThe output is
Regression?Yes this is a regression. .NET7, .NET Framework, and mono (a version from mono github repo) all return null. Our test that hit this is not new, so suspect earlier versions of .NET also returned null. Known WorkaroundsNo response ConfigurationI was using 8.0.200. Windows, x64 Other informationNo response
|
I was able to repro; be sure to include namespace in the string ".Program&&"
|
@mrvoorhe what are you trying to do? Note that the doc for GetType(string) does throw We should determine if this change from 7.0 to 8.0 was on purpose or not. |
@steveharter At Unity we have a large suite of tests for IL2CPP that compares IL2CPP to mono, .NET Framework, and .NET. I'm updating our projects from I didn't dig into the history of the test. It's plausible we added the test in response to a bug report from a Unity user and maybe we did the wrong thing once upon a time. Or maybe we were just writing tests for invalid cases to make sure we did the same thing as mono/.NET Framework. I don't really care if the API throws or returns null in this case. I'm happy to let you decide that. I thought I would file a bug given that it was a long-standing behavior to return null and now that has changed. I thought maybe there was a chance it changed by accident and if that was the case maybe a bug report would be appreciated. |
This change was introduced by #83484 and related changes. We had multiple type name parsers and it was not unusual for them to have different behavior in corner cases like this one. The behavior was unified on:
https://learn.microsoft.com/en-us/dotnet/core/compatibility/core-libraries/9.0/type-instance that will appear in .NET 9 may also cause some new test cases to fail in your extensive suite. We allowed certain invalid array types to be loaded that caused all sorts of problems when these invalid types were passed to other APIs. We disallow loading these types now that will show up through
This error message is wrong. I have submitted #98548 to fix it. |
Thanks for the explanation @jkotas ! |
Should this get a breaking change notice added in such case? |
Added
Tagging @dotnet/compat for awareness of the breaking change. |
Yes: dotnet/docs#39594 |
Description
With net7
Type.GetType("Program&&")
will return null because a ref to a ref is not a valid type. Starting with net8, this code now throws.Reproduction Steps
Create a console application targeting net8 with the following code
Expected behavior
The output should be
Actual behavior
The output is
Regression?
Yes this is a regression. .NET7, .NET Framework, and mono (a version from mono github repo) all return null. Our test that hit this is not new, so suspect earlier versions of .NET also returned null.
Known Workarounds
No response
Configuration
I was using 8.0.200. Windows, x64
Other information
No response
The text was updated successfully, but these errors were encountered: