I notice that .NET core doesn't allow myObj.GetType().GetProperties() as no GetProperties method exists. Is there another way to obtain the properties of a class through reflection?
2 Answers
Just to sum up to anyone else, just adding using System.Reflection to the top of the page is not enough. You will have to add the System.Reflection.TypeExtensions NuGet package as described in the question comments.
PM> Install-Package System.Reflection.TypeExtensions -Version 4.3.0
4 Comments
user3791372
1/ This is a comment to a comment written as an answer, 2/ No you don't. 3./ This garnered an upvote surprisingly quickly.
Moslem Ben Dhaou
Yes you do. I had the same issue in a .NET Standard 1.6 project and only the combination above solved it for me. In .NET Core unfortunately namespaces are now spread over multiple assemblies.
Rikon
1/ Yeah you do 2/Seems like if you're answering your own question (and not a complete answer) you're on shaky ground about getting picky with upvotes... I upvoted both of you... Together it's a complete answer
user3791372
@MoslemBenDhaou the question refers to ".Net Core" not .Net Standard
myObj.GetType().GetTypeInfo().GetProperties()