Skip to content
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

Method Type.IsAssignableFrom(Type c) call NullReferenceException, when property UnderlyingSystemType = null #27487

Closed
andrey-kosteley opened this issue Sep 27, 2018 · 0 comments
Milestone

Comments

@andrey-kosteley
Copy link

Kind time of day.
Sorry for my English.

Environment:
I have a custom type - "MyType", the heir from the type "Type".
The "UnderlyingSystemType" property of my class is overridden and returns "null".
There is a variable of type "MyType", let's call it "myType_Variable".
And there is a variable of any type, let's call it "anyType_Variable"

A task:
Perform the method - Type.IsAssignableFrom(Type c)

I get:
NullReferenceException: Object reference not set to an instance of an object

Analysis:
I found out that the problem is in the IsRuntimeImplemented() method and the implementation of the IsAssignableFrom(Type c) method.

How do I think the problem is in the falsely flashing method IsAssignableFrom(Type c) from the .NET Framework.
Code from .NET Frameworks:
...
RuntimeType underlyingSystemType = this.UnderlyingSystemType as RuntimeType;
if (underlyingSystemType != null)
{
return underlyingSystemType.IsAssignableFrom(c);
}
...

I understand that I can override method IsAssignableFrom(Type c), I did so, but it seems to me that this use case should be out of the box. method IsAssignableFrom(Type c) is not mandatory for implementation.

@msftgits msftgits transferred this issue from dotnet/corefx Jan 31, 2020
@msftgits msftgits added this to the 3.0 milestone Jan 31, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants