Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NetStandard: Missing Type Methods and Properties

I have a code in PCL that I want to migrate to .NetStandard. Unfortunately tho, my code is dependent on .Net reflection and I cant find some of the methods previously available. So here is the list of methods or properties that I cant find under .NetStandard. Can any one point me in right direction about how to refactor my code?

Type.IsInstanceOfType()
Type.IsAssignableFrom()
Type.GetNestedTypes()
Type.GetConstructors()
Type.IsClass
Type.IsEnum
Type.IsValueType
like image 822
Soroush Falahati Avatar asked Oct 05 '16 18:10

Soroush Falahati


2 Answers

Use GetTypeInfo. Then those members are available off the TypeInfo now.

var example = typeof(string).GetTypeInfo().IsClass;
like image 80
vcsjones Avatar answered Nov 20 '22 10:11

vcsjones


Or you could use ReflectionBridge : https://www.nuget.org/packages/ReflectionBridge/

like image 34
Stef Heyenrath Avatar answered Nov 20 '22 12:11

Stef Heyenrath