> For the complete documentation index, see [llms.txt](https://docs.zongsoft.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.zongsoft.com/documentation/en/framework/core/common/annotation-utility.md).

# Annotation Utilities

AnnotationUtility member annotation reading tool.

`AnnotationUtility` is used to read display-related comments from type members, including classification, display name, and description.

| method           | Description                                                                                                                                                                                                                                            |
| ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `GetCategory`    | Read [`CategoryAttribute`](https://learn.microsoft.com/en-us/dotnet/api/system.componentmodel.categoryattribute) [*Source*](https://source.dot.net/#System.ComponentModel.Primitives/CategoryAttribute.cs).                                            |
| `GetDisplayName` | Read [`DisplayNameAttribute`](https://learn.microsoft.com/en-us/dotnet/api/system.componentmodel.displaynameattribute) [*Source*](https://source.dot.net/#System.ComponentModel.Primitives/DisplayNameAttribute.cs) or `DisplayAttribute.Name`.        |
| `GetDescription` | Read [`DescriptionAttribute`](https://learn.microsoft.com/en-us/dotnet/api/system.componentmodel.descriptionattribute) [*Source*](https://source.dot.net/#System.ComponentModel.Primitives/DescriptionAttribute.cs) or `DisplayAttribute.Description`. |

Source: [framework/externals/aliyun/src/Telecom/PhoneTransmitter.cs](https://github.com/Zongsoft/framework/blob/main/externals/aliyun/src/Telecom/PhoneTransmitter.cs#L71) (excerpt; see source for context).

{% code title="PhoneTransmitter.cs" %}

```csharp
_descriptor = new TransmitterDescriptor(this.Name, AnnotationUtility.GetDisplayName(this.GetType()), AnnotationUtility.GetDescription(this.GetType()));
```

{% endcode %}

## From Annotations to Display Metadata

The above is the actual code for the framework Aliyun PhoneTransmitter to create the transmitter descriptor. This type uses the DisplayName and Description attributes to declare the resource key. AnnotationUtility reads the annotations and cooperates with the resource mechanism to obtain the title and description. See [template sender](/documentation/en/framework/core/communication/transmitter.md) for a complete example, and [Resource management](/documentation/en/framework/core/resources.md) for resource search. Discussions' model fields and enumerations also rely on resource descriptions, but without this sender code.

## When to Use

When the description of a model, command, or configuration item is maintained uniformly by a type declaration, reading the annotation can avoid saving the name repeatedly in each interface. Annotations are responsible for displaying metadata, do not participate in database column name matching, and cannot replace parameter verification. Missing annotations or resources should be handled according to the caller's display convention, and the returned title should not be used as a permission key or persistent identifier.

## Related Resources

* [AnnotationUtility.cs](https://github.com/Zongsoft/framework/blob/main/Zongsoft.Core/src/Common/AnnotationUtility.cs)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.zongsoft.com/documentation/en/framework/core/common/annotation-utility.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
