Skip to content

Latest commit

 

History

History
34 lines (28 loc) · 2.65 KB

index.md

File metadata and controls

34 lines (28 loc) · 2.65 KB
title description ms.date helpviewer_keywords ms.assetid
Extending Metadata Using Attributes
Learn how to extend metadata using attributes in .NET. Attributes are keyword-like descriptive declarations to annotate programming elements, like types and fields.
10/14/2020
metadata, extending
attributes [.NET], metadata
elements [.NET], attributes
common language runtime, attributes
annotating programming elements
keyword-like descriptive declarations
runtime, attributes
extending metadata
30386922-1e00-4602-9ebf-526b271a8b87

Extend 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 common intermediate language (CIL) 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.

.NET 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 articles

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 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