1

I cannot find a .net core equivalent for calling GetCustomAttributes on an assembly object. I see there is CustomAttributes property, but this doesn't return instances of the custom attributes, but rather metadata about the attributes. How can I retrieve the actual attribute instance?

Adam
  • 1,011
  • 1
  • 10
  • 25
  • http://stackoverflow.com/questions/12814723/what-is-an-equivalent-method-to-getcustomattributes-for-netcore-windows-8-fr – Hans Passant Jul 08 '16 at 09:59
  • That refers to types, and as as I can see in my code, GetTypeInfo doesn't exist for assembly? – Adam Jul 08 '16 at 13:45

1 Answers1

1

There's a GetCustomAttributes extension method. Just add using System.Reflection.

Eli Arbel
  • 22,391
  • 3
  • 45
  • 71
  • 1
    no idea why... I guess tooling still being in preview... but I couldn't get Visual Studio to agree. Since you stated this as fact, I decided to try again, hard, and so I unloaded/closed/reloaded/put one hand on my head/faced North-east, and suddenly visual studio says the extension method does exist... Thanks! – Adam Jul 08 '16 at 13:48
  • @Adam, must be that I don't do this, so I still see the curve lines under GetCustomAttributes? – Elaine Nov 01 '16 at 09:13
  • The .NET Core version requires a MemberInfo object as the first argument. I'm unsure of what to put in there. – jceddy Apr 06 '17 at 16:33