> ## Documentation Index
> Fetch the complete documentation index at: https://easyaf.nimbleapps.cloud/llms.txt
> Use this file to discover all available pages before exploring further.

# XmlPropertyInfo

> Provides XML serialization-related metadata about a property or field. This class cannot be inherited.

## Definition

**Assembly:** CloudNimble.XmlEssentials.dll

**Namespace:** CloudNimble.Text.Xml.Serialization

## Syntax

```csharp theme={"dark"}
CloudNimble.Text.Xml.Serialization.XmlPropertyInfo
```

## Summary

Provides XML serialization-related metadata about a property or field. This class cannot be inherited.

## Usage

An `XmlPropertyInfo` describes how one member of an object is mapped: its XML name, whether it's an attribute, an element, or the text of its parent, whether it's required, and the type info of its value. You read these objects from `XmlTypeInfo.Properties`. You don't create them.

```csharp theme={"dark"}
XmlTypeInfo<Order> metadata = MetadataOrderXmlContext.Default.Order;

output.WriteLine($"Root element: {metadata.RootName.LocalName}");
foreach (XmlPropertyInfo property in metadata.Properties)
{
    string kind = property.IsAttribute ? "attribute" : "element";
    output.WriteLine($"{property.Name.LocalName}: {kind}, {property.PropertyType.Type.Name}");
}
```

The code produces the following output:

```text theme={"dark"}
Root element: Order
Id: attribute, Int32
Customer: element, String
Line: element, List`1
```

`Name` is the XML name, after attributes and naming policies: the `Lines` property appears as `Line` because of `[XmlElement("Line")]`. `Order` is the explicit order of the member among its siblings, or `-1` when it has none.

The list is filled for a type that the serializer maps member by member, whether the type info comes from the reflection resolver or from a source-generated context in the default mode or in `Metadata` mode. It's empty for type info from a context in `Serialization` mode. The class is read-only. Unlike `JsonPropertyInfo` in System.Text.Json, it can't be used to change a contract.

[View the complete sample on GitHub](https://github.com/CloudNimble/XmlEssentials/blob/main/src/CloudNimble.XmlEssentials.Samples/33_SourceGenerationModes.cs)

## Constructors

### &#x20;.ctor Inherited

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={"dark"}
public Object()
```

## Properties

### &#x20;IsAttribute

Gets a value that indicates whether the member is serialized as an XML attribute.

#### Syntax

```csharp theme={"dark"}
public bool IsAttribute { get; }
```

#### Property Value

Type: `bool`
[`true`](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) if the member is serialized as an XML attribute; otherwise, [`false`](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool).

### &#x20;IsNillable

Gets a value that indicates whether the member is nillable.

#### Syntax

```csharp theme={"dark"}
public bool IsNillable { get; }
```

#### Property Value

Type: `bool`
[`true`](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) if the member is nillable; otherwise, [`false`](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool).

#### Remarks

A member is nillable when its type is a reference type, a \[Nullable`1](https://learn.microsoft.com/dotnet/api/system.nullable-1), or a collection, or when [XmlElementAttribute.IsNullable](/xmlessentials/api-reference/CloudNimble/Text/Xml/Serialization/XmlElementAttribute#isnullable) is [`true`](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool). Whether a [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) value is written
depends on the ignore condition of the member. When it is written, it is an element marked `xsi:nil="true"\`.

### &#x20;IsRequired

Gets a value that indicates whether the member must be present on deserialization.

#### Syntax

```csharp theme={"dark"}
public bool IsRequired { get; }
```

#### Property Value

Type: `bool`
[`true`](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) if the member must be present on deserialization; otherwise, [`false`](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool).

### &#x20;IsText

Gets a value that indicates whether the member is serialized as the text content of the element for its containing type.

#### Syntax

```csharp theme={"dark"}
public bool IsText { get; }
```

#### Property Value

Type: `bool`
[`true`](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) if the member is serialized as text content; otherwise, [`false`](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool).

### &#x20;Name

Gets the XML name of the member.

#### Syntax

```csharp theme={"dark"}
public CloudNimble.Text.Xml.XmlName Name { get; }
```

#### Property Value

Type: `CloudNimble.Text.Xml.XmlName`
The name of the element or attribute that the member is serialized as.

### &#x20;Order

Gets the serialization order of the member among the members of its containing type.

#### Syntax

```csharp theme={"dark"}
public int Order { get; }
```

#### Property Value

Type: `int`
The order of the member, or `-1` if no order is set.

### &#x20;PropertyType

Gets the metadata for the type of the member.

#### Syntax

```csharp theme={"dark"}
public CloudNimble.Text.Xml.Serialization.XmlTypeInfo PropertyType { get; }
```

#### Property Value

Type: `CloudNimble.Text.Xml.Serialization.XmlTypeInfo`
The serialization metadata for the type of the member.

## Methods

### &#x20;Equals Inherited Virtual

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={"dark"}
public virtual bool Equals(object obj)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `obj` | `object?` | - |

#### Returns

Type: `bool`

### &#x20;Equals Inherited

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={"dark"}
public static bool Equals(object objA, object objB)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `objA` | `object?` | - |
| `objB` | `object?` | - |

#### Returns

Type: `bool`

### &#x20;GetHashCode Inherited Virtual

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={"dark"}
public virtual int GetHashCode()
```

#### Returns

Type: `int`

### &#x20;GetType Inherited

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={"dark"}
public System.Type GetType()
```

#### Returns

Type: `System.Type`

### &#x20;MemberwiseClone Inherited

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={"dark"}
protected internal object MemberwiseClone()
```

#### Returns

Type: `object`

### &#x20;ReferenceEquals Inherited

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={"dark"}
public static bool ReferenceEquals(object objA, object objB)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `objA` | `object?` | - |
| `objB` | `object?` | - |

#### Returns

Type: `bool`

### &#x20;ToString Inherited Virtual

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={"dark"}
public virtual string ToString()
```

#### Returns

Type: `string?`

## Related APIs

* CloudNimble.Text.Xml.Serialization.XmlTypeInfo
* CloudNimble.Text.Xml.Serialization.XmlAttributeAttribute
* CloudNimble.Text.Xml.Serialization.XmlElementAttribute
* CloudNimble.Text.Xml.Serialization.XmlTextAttribute
* CloudNimble.Text.Xml.Serialization.XmlRequiredAttribute
* CloudNimble.Text.Xml.Serialization.XmlPropertyOrderAttribute
* CloudNimble.Text.Xml.XmlName


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.