What is reflection and what is its value?

Reflection provides objects (of type Type) that describe assemblies, modules and types. You can use reflection to dynamically create an instance of a type, bind the type to an existing object, or get the type from an existing object and invoke its methods or access its fields and properties. If you are using attributes in your code, reflection enables you to access them.

The main value of reflection is that it can be used to inspect assemblies, types, and members. It's a very powerful tool for determining the contents of an unknown assembly or object and can be used in a wide variety of cases.

Some useful applications:
  • Determining dependencies of an assembly
  • Locating types which conform to an interface, derive from a base / abstract class, and searching for members by attributes
  • Debugging - dumping out a list of the loaded assemblies, their references, current methods, etc.

No comments:

Post a Comment