Querying attributes on classes/methods in C#
Are there any tools available for querying attributes defined for methods/classes开发者_JS百科?
It would be nice if it was possible to get a list of methods/classes with specific attributes, no attributes at all, etc.
I can imagine I could do this with reflection, but maybe there's a better way. I would be grateful if anyone has any idea about it. Thank you.
.NET Reflector
is a popular tool that does everything in your question. You could also find the same information using the objects in the System.Reflection
namespace.
Your hunch is right - that's why reflection exists.
You can also use static analysis tools such as nDepend (propitiatory) to query many aspects of any assembly.
精彩评论