-
Notifications
You must be signed in to change notification settings - Fork 5k
Added an override for IsCollectible in RuntimeType to fix inconsistency between Mono and CoreCLR #115785
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
Conversation
… value when called on a Type
cc: @nealef |
@@ -1327,6 +1327,8 @@ protected override bool IsValueTypeImpl() | |||
// Returns true for generic parameters with the Enum constraint. | |||
public override bool IsEnum => GetBaseType() == EnumType; | |||
|
|||
public override bool IsCollectible => RuntimeTypeHandle.GetAssembly(this)!.IsCollectible; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this just return false given that collectible assemblies are not implemented in Mono?
This is not a correct implementation in case collectible assemblies were ever implemented in Mono. Correct implementation would have to take into account all generic instantiation arguments.
Does MethodInfo, etc. have the same bug? If I am reading the code correctly, the following program is going to print true on Mono:
We have a lot of advanced tests for collectible property that are disabled on Mono, but we are missing the basic ones. Could you please add some basic tests
|
Tagging subscribers to this area: @dotnet/area-system-reflection |
Yes, MethodInfo and PropertyInfo too have differing values. They are true in Mono but are false in CoreCLR. |
Yes, that's correct on CoreCLR. Mono does not support collectible assemblies. |
@dotnet-policy-service agree company="IBM" |
@dotnet-policy-service agree company="IBM" |
It turns out NativeAOT has the same bug. Could you please add overrides A good place to add them is: Lines 90 to 128 in e163124
|
…incorrect values for it.
src/libraries/System.Runtime/tests/System.Runtime.Tests/System/Reflection/IsCollectibleTests.cs
Show resolved
Hide resolved
...oreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Runtime/General/ThunkedApis.cs
Outdated
Show resolved
Hide resolved
...oreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Runtime/General/ThunkedApis.cs
Outdated
Show resolved
Hide resolved
…ed IsCollectible overrides for RuntimeEventInfo and RuntimeConstructorInfo in Mono and CoreCLR.
The new test is still failing on NAOT. I have pushed a fix to add missing FieldInfo override for NAOT. |
Thank you! |
/ba-g Known issue #115955 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
In Mono, calling
IsCollectible
on aType
was returnedTrue
, whereas in CoreCLR it returnedFalse
for the same scenario. This discrepancy was caused by a missing override ofIsCollectible
in theRuntimeType
class in Mono.The discrepancy could also be seen here link