Permalink
Fetching contributors…
Cannot retrieve contributors at this time
43 lines (38 sloc) 2.89 KB
title ms.custom ms.date ms.prod ms.reviewer ms.suite ms.technology ms.tgt_pltfrm ms.topic helpviewer_keywords ms.assetid caps.latest.revision author ms.author manager
Extending Metadata Using Attributes
03/30/2017
.net
dotnet-standard
article
metadata, extending
attributes [.NET Framework], metadata
elements [.NET Framework], attributes
common language runtime, attributes
annotating programming elements
keyword-like descriptive declarations
runtime, attributes
extending metadata
30386922-1e00-4602-9ebf-526b271a8b87
12
rpetrusha
ronpet
wpickett

Extending Metadata Using Attributes

The common language runtime allows you to add keyword-like descriptive declarations, called attributes, to annotate programming elements such as types, fields, methods, and properties. When you compile your code for the runtime, it is converted into Microsoft intermediate language (MSIL) and placed inside a portable executable (PE) file along with metadata generated by the compiler. Attributes allow you to place extra descriptive information into metadata that can be extracted using runtime reflection services. The compiler creates attributes when you declare instances of special classes that derive from xref:System.Attribute?displayProperty=nameWithType.

The .NET Framework uses attributes for a variety of reasons and to address a number of issues. Attributes describe how to serialize data, specify characteristics that are used to enforce security, and limit optimizations by the just-in-time (JIT) compiler so the code remains easy to debug. Attributes can also record the name of a file or the author of code, or control the visibility of controls and members during forms development.

Related Topics

Title Description
Applying Attributes Describes how to apply an attribute to an element of your code.
Writing Custom Attributes Describes how to design custom attribute classes.
Retrieving Information Stored in Attributes Describes how to retrieve custom attributes for code that is loaded into the execution context.
Metadata and Self-Describing Components Provides an overview of metadata and describes how it is implemented in a .NET Framework portable executable (PE) file.
How to: Load Assemblies into the Reflection-Only Context Explains how to retrieve custom attribute information in the reflection-only context.

Reference

xref:System.Attribute?displayProperty=nameWithType