C# Getting an object's actual TypeDescriptionProvider or TypeDescriptor
See the question and my original answer on StackOverflowIf you look at TypeDescriptor.GetProvider
implementation using a tool such as .NET Reflector, you will see that the returned type is pretty hardcoded. It always returns a TypeDescriptionNode
, like you observed. Same story for GetTypeDescriptor
.
Now, what you could do is use Reflection mechanisms to get the actual TypeDescriptionProvider
from TypeDescriptionNode
. It's pretty easy, just get the private field named Provider
, this is where the TypeDescriptionNode stores the actual implementation. Of course it's not supported, but I don't think this will change in a near future, and I don't really see a better way...