Working with reflection and attributes
Reflection is a programming feature that allows code to understand and manipulate itself. Key benefits of reflection include the following:
- Dynamic type access: Reflection enables you to access types in a dynamic manner at runtime. This is particularly useful for creating plug-in architectures where new functionality can be added without recompiling the application.
- Late binding: You can invoke methods and access properties on objects dynamically without knowing their types at compile time. This can be used to interact with APIs where the type information is not available beforehand.
- Metadata inspection: Reflection allows the examination of various types and their members, which is great for tools and libraries that need to handle types generically, for example, serialization frameworks and ORM tools.
Let’s start by looking at metadata inspection.
Metadata in .NET assemblies
A .NET assembly is made...