# CustomResourceSnapshotExtensions Methods

- Package: [Aspire.Hosting](/reference/api/csharp/aspire.hosting.md)
- Type: [CustomResourceSnapshotExtensions](/reference/api/csharp/aspire.hosting/customresourcesnapshotextensions.md)
- Kind: `Methods`
- Members: `1`

Provides extension methods for creating updated [CustomResourceSnapshot](/reference/api/csharp/aspire.hosting/customresourcesnapshot.md) values.

## WithHealthReports(CustomResourceSnapshot, ImmutableArray<HealthReportSnapshot>)

- Name: `WithHealthReports(CustomResourceSnapshot, ImmutableArray<HealthReportSnapshot>)`
- Modifiers: `extension`
- Returns: [CustomResourceSnapshot](/reference/api/csharp/aspire.hosting/customresourcesnapshot.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/ApplicationModel/CustomResourceSnapshotExtensions.cs#L27-L29)

Creates a copy of the resource snapshot with the specified health reports.

```csharp
public static class CustomResourceSnapshotExtensions
{
    public static CustomResourceSnapshot WithHealthReports(
        this CustomResourceSnapshot snapshot,
        ImmutableArray<HealthReportSnapshot> healthReports)
    {
        // ...
    }
}
```

## Parameters

- `snapshot` ([CustomResourceSnapshot](/reference/api/csharp/aspire.hosting/customresourcesnapshot.md))
  The resource snapshot to update.
- `healthReports` (`ImmutableArray<HealthReportSnapshot>`)
  The health reports to publish for the resource snapshot.

## Returns

[CustomResourceSnapshot](/reference/api/csharp/aspire.hosting/customresourcesnapshot.md) -- A copy of `snapshot` with updated health reports.

## Exceptions

- `ArgumentNullException` -- Thrown when `snapshot` is `null`.

## Remarks

This method is intended for use with [ResourceNotificationService.PublishUpdateAsync(IResource, string, Func<CustomResourceSnapshot, CustomResourceSnapshot>)](/reference/api/csharp/aspire.hosting/resourcenotificationservice/methods.md#publishupdateasync-iresource-string-func-customresourcesnapshot-customresourcesnapshot) and [ResourceNotificationService.PublishUpdateAsync(IResource, string, Func<CustomResourceSnapshot, CustomResourceSnapshot>)](/reference/api/csharp/aspire.hosting/resourcenotificationservice/methods.md#publishupdateasync-iresource-string-func-customresourcesnapshot-customresourcesnapshot). Updating health reports also recomputes [CustomResourceSnapshot.HealthStatus](/reference/api/csharp/aspire.hosting/customresourcesnapshot/properties.md#healthstatus) based on the snapshot state.
