# ContentGuardResult

> Tracon documentation. Tracon is a .NET package family that adds a control
> plane on Microsoft Agent Framework, published as NuGet packages that run
> inside your own ASP.NET Core application.
>
> Page: https://tracon.dev/api/tracon.contentguardresult/
> Summary: ContentGuardResult: The result of an IContentGuard check.

<div class="api-provenance">Namespace Tracon · Assembly <code>Tracon.Abstractions.dll</code></div>

The result of an [IContentGuard](/api/tracon.icontentguard/) check.

```csharp
public sealed record ContentGuardResult : IEquatable<ContentGuardResult>
```

<dl class="api-relations"><dt>Inheritance</dt><dd><a href="https://learn.microsoft.com/dotnet/api/system.object">object</a> ← <a href="/api/tracon.contentguardresult/">ContentGuardResult</a></dd><dt>Implements</dt><dd><a href="https://learn.microsoft.com/dotnet/api/system.iequatable-1">IEquatable&lt;ContentGuardResult&gt;</a></dd><dt>Inherited Members</dt><dd><a href="https://learn.microsoft.com/dotnet/api/system.object.gettype">object.GetType()</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.tostring">object.ToString()</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)">object.Equals(object?)</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)">object.Equals(object?, object?)</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.referenceequals">object.ReferenceEquals(object?, object?)</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.gethashcode">object.GetHashCode()</a></dd></dl>

## Remarks

The result **does not carry the blocked content**. It only
carries the matched rule's name and the block reason; both are written to
the audit trail and the run event. Blocked content is sensitive by
definition, and writing it into an audit trail makes the problem
*permanent*.

## Constructors

### <a id="Tracon_ContentGuardResult__ctor"></a> ContentGuardResult\(\)

```csharp
public ContentGuardResult()
```

## Properties

### <a id="Tracon_ContentGuardResult_Action"></a> Action

The decision made.

```csharp
public required ContentGuardAction Action { get; init; }
```

#### Property Value

 [ContentGuardAction](/api/tracon.contentguardaction/)

### <a id="Tracon_ContentGuardResult_Allow"></a> Allow

The content passes unchanged.

```csharp
public static ContentGuardResult Allow { get; }
```

#### Property Value

 [ContentGuardResult](/api/tracon.contentguardresult/)

#### Remarks

A single instance is shared: this is the value guards return most
often, and it must not allocate on the hot path.

### <a id="Tracon_ContentGuardResult_MaskedText"></a> MaskedText

The new text to send to the model (or return to the client). Populated
only for [ContentGuardAction.Mask](/api/tracon.contentguardaction/).

```csharp
public string? MaskedText { get; init; }
```

#### Property Value

 [string](https://learn.microsoft.com/dotnet/api/system.string)?

### <a id="Tracon_ContentGuardResult_Reason"></a> Reason

The block reason. Does not carry the blocked TEXT.

```csharp
public string? Reason { get; init; }
```

#### Property Value

 [string](https://learn.microsoft.com/dotnet/api/system.string)?

### <a id="Tracon_ContentGuardResult_RuleName"></a> RuleName

The matched rule's name. Does not carry the matched CONTENT.

```csharp
public string? RuleName { get; init; }
```

#### Property Value

 [string](https://learn.microsoft.com/dotnet/api/system.string)?

## Methods

### <a id="Tracon_ContentGuardResult_Block_System_String_System_String_"></a> Block\(string, string\)

The content is blocked; the run becomes `Failed`.

```csharp
public static ContentGuardResult Block(string ruleName, string reason)
```

#### Parameters

`ruleName` [string](https://learn.microsoft.com/dotnet/api/system.string)

The matched rule's name.

`reason` [string](https://learn.microsoft.com/dotnet/api/system.string)

The block reason. MUST not carry the blocked text.

#### Returns

 [ContentGuardResult](/api/tracon.contentguardresult/)

A block decision.

### <a id="Tracon_ContentGuardResult_Equals_System_Object_"></a> Equals\(object?\)

```csharp
public override bool Equals(object? obj)
```

#### Parameters

`obj` [object](https://learn.microsoft.com/dotnet/api/system.object)?

#### Returns

 [bool](https://learn.microsoft.com/dotnet/api/system.boolean)

### <a id="Tracon_ContentGuardResult_Equals_Tracon_ContentGuardResult_"></a> Equals\(ContentGuardResult?\)

```csharp
public bool Equals(ContentGuardResult? other)
```

#### Parameters

`other` [ContentGuardResult](/api/tracon.contentguardresult/)?

#### Returns

 [bool](https://learn.microsoft.com/dotnet/api/system.boolean)

### <a id="Tracon_ContentGuardResult_GetHashCode"></a> GetHashCode\(\)

```csharp
public override int GetHashCode()
```

#### Returns

 [int](https://learn.microsoft.com/dotnet/api/system.int32)

### <a id="Tracon_ContentGuardResult_Mask_System_String_System_String_"></a> Mask\(string, string\)

The content passes after being modified.

```csharp
public static ContentGuardResult Mask(string maskedText, string ruleName)
```

#### Parameters

`maskedText` [string](https://learn.microsoft.com/dotnet/api/system.string)

The new form of the content.

`ruleName` [string](https://learn.microsoft.com/dotnet/api/system.string)

The matched rule's name.

#### Returns

 [ContentGuardResult](/api/tracon.contentguardresult/)

A mask decision.

### <a id="Tracon_ContentGuardResult_ToString"></a> ToString\(\)

```csharp
public override string ToString()
```

#### Returns

 [string](https://learn.microsoft.com/dotnet/api/system.string)

## Operators

### <a id="Tracon_ContentGuardResult_op_Equality_Tracon_ContentGuardResult_Tracon_ContentGuardResult_"></a> operator ==\(ContentGuardResult?, ContentGuardResult?\)

```csharp
public static bool operator ==(ContentGuardResult? left, ContentGuardResult? right)
```

#### Parameters

`left` [ContentGuardResult](/api/tracon.contentguardresult/)?

`right` [ContentGuardResult](/api/tracon.contentguardresult/)?

#### Returns

 [bool](https://learn.microsoft.com/dotnet/api/system.boolean)

### <a id="Tracon_ContentGuardResult_op_Inequality_Tracon_ContentGuardResult_Tracon_ContentGuardResult_"></a> operator \!=\(ContentGuardResult?, ContentGuardResult?\)

```csharp
public static bool operator !=(ContentGuardResult? left, ContentGuardResult? right)
```

#### Parameters

`left` [ContentGuardResult](/api/tracon.contentguardresult/)?

`right` [ContentGuardResult](/api/tracon.contentguardresult/)?

#### Returns

 [bool](https://learn.microsoft.com/dotnet/api/system.boolean)
