Soenneker.AdaptiveCard.Util
4.0.626
Prefix Reserved
See the version list below for details.
dotnet add package Soenneker.AdaptiveCard.Util --version 4.0.626
NuGet\Install-Package Soenneker.AdaptiveCard.Util -Version 4.0.626
<PackageReference Include="Soenneker.AdaptiveCard.Util" Version="4.0.626" />
<PackageVersion Include="Soenneker.AdaptiveCard.Util" Version="4.0.626" />
<PackageReference Include="Soenneker.AdaptiveCard.Util" />
paket add Soenneker.AdaptiveCard.Util --version 4.0.626
#r "nuget: Soenneker.AdaptiveCard.Util, 4.0.626"
#:package Soenneker.AdaptiveCard.Util@4.0.626
#addin nuget:?package=Soenneker.AdaptiveCard.Util&version=4.0.626
#tool nuget:?package=Soenneker.AdaptiveCard.Util&version=4.0.626
Soenneker.AdaptiveCard.Util
A small builder for creating consistent Adaptive Cards for Microsoft Teams, alerting pipelines, and other Adaptive Card hosts.
It provides two operations:
Buildcreates a title/summary card with optional facts, exception details, and additional text.BuildTableturns the public properties of a list of objects into a header row and data rows.
Both operations add diagnostic footer fields when available: environment, project name, machine name, and an Eastern Time timestamp.
Installation
dotnet add package Soenneker.AdaptiveCard.Util
Registration
Register the builder with the lifetime used by your application:
using Soenneker.AdaptiveCard.Util.Registrars;
builder.Services.AddAdaptiveCardUtilAsSingleton();
Scoped registration is also available:
builder.Services.AddAdaptiveCardUtilAsScoped();
Both methods register IAdaptiveCardUtil only when it has not already been registered, so an application can supply its own implementation before calling the registrar.
Build a diagnostic card
Inject IAdaptiveCardUtil, assemble the content, and pass the resulting AdaptiveCard to the client responsible for delivering or serializing it:
using System.Diagnostics;
using Soenneker.AdaptiveCard.Util.Abstract;
public sealed class FailureCardFactory
{
private readonly IAdaptiveCardUtil _cardUtil;
public FailureCardFactory(IAdaptiveCardUtil cardUtil)
{
_cardUtil = cardUtil;
}
public AdaptiveCards.AdaptiveCard Create(
string orderId,
Exception exception)
{
var facts = new Dictionary<string, string?>
{
["Order"] = orderId,
["Region"] = "us-east",
["Correlation ID"] = Activity.Current?.Id
};
return _cardUtil.Build(
title: "Order processing failed",
summary: "The order worker stopped before completion.",
facts: facts,
e: exception,
additionalBody: "Review the worker logs before retrying the order.");
}
}
The resulting card uses Adaptive Card schema 1.2 and includes the Microsoft Teams msteams.width = Full property. Fact entries with a null or empty value are omitted. Exception and additional-body text wrap automatically.
To stay within practical Teams payload limits, text blocks larger than 27 KiB in UTF-8 are truncated to at most 5,000 characters and the truncation is logged.
Configure footer values
Environment and ProjectName are read from IConfiguration. For example, in appsettings.json:
{
"Environment": "Production",
"ProjectName": "Order Processor"
}
Only non-empty configured values are included. Machine name and the current Eastern Time timestamp are added automatically.
Build a table card
BuildTable<T> uses each public property name as a column heading and each property value as a cell:
using Soenneker.AdaptiveCard.Util.Abstract;
public sealed record DeploymentRow(
string Service,
string Version,
string Status);
static AdaptiveCards.AdaptiveCard CreateDeploymentCard(
IAdaptiveCardUtil cardUtil)
{
var rows = new List<DeploymentRow>
{
new("API", "4.12.0", "Healthy"),
new("Worker", "4.12.0", "Degraded")
};
return cardUtil.BuildTable(
title: "Deployment status",
items: rows,
summary: "Production services");
}
Property getters are cached per item type, so repeated calls with the same T do not repeat the reflection setup. Cell values are produced with ToString(); null values become empty cells.
Keep table models intentionally small. Adaptive Cards do not provide responsive HTML-style tables, and every public property becomes a column. Project data into a dedicated row type when you need to control column names, order, or formatting.
BuildTable adds its title and column headings only when items contains at least one row. Handle an empty result separately when the card must explicitly say that no records were found.
API
| Method | Purpose |
|---|---|
Build(string title, string? summary, Dictionary<string, string?>? facts, Exception? e, string? additionalBody) |
Creates a general diagnostic or informational card. |
BuildTable<T>(string title, List<T> items, string? summary) |
Creates a property-based table card from a typed list. |
AddAdaptiveCardUtilAsSingleton() |
Registers IAdaptiveCardUtil as a singleton. |
AddAdaptiveCardUtilAsScoped() |
Registers IAdaptiveCardUtil as scoped. |
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- AdaptiveCards (>= 3.1.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.11)
- Soenneker.Extensions.Configuration (>= 4.0.868)
- Soenneker.Extensions.DateTimeOffsets (>= 4.0.138)
- Soenneker.Utils.Environment (>= 4.0.721)
- Soenneker.Utils.TimeZones (>= 4.0.766)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Soenneker.AdaptiveCard.Util:
| Package | Downloads |
|---|---|
|
Soenneker.MsTeams.Util
A centralized utility for sending rich, configurable Adaptive Card messages to Microsoft Teams channels via a service bus, with environment-aware filtering and dynamic content generation. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.0.631 | 0 | 8/31/2026 |
| 4.0.630 | 0 | 8/31/2026 |
| 4.0.629 | 0 | 8/31/2026 |
| 4.0.628 | 0 | 8/31/2026 |
| 4.0.626 | 24 | 8/30/2026 |
| 4.0.624 | 23 | 8/30/2026 |
| 4.0.623 | 43 | 8/30/2026 |
| 4.0.621 | 37 | 8/30/2026 |
| 4.0.620 | 31 | 8/30/2026 |
| 4.0.619 | 85 | 8/30/2026 |
| 4.0.617 | 42 | 8/29/2026 |
| 4.0.614 | 105 | 8/29/2026 |
| 4.0.613 | 34 | 8/29/2026 |
| 4.0.612 | 42 | 8/29/2026 |
| 4.0.610 | 66 | 8/29/2026 |
| 4.0.608 | 377 | 8/26/2026 |
| 4.0.607 | 77 | 8/26/2026 |
| 4.0.606 | 126 | 8/26/2026 |
| 4.0.605 | 136 | 8/25/2026 |
| 4.0.604 | 204 | 8/22/2026 |
Update dependency Soenneker.Extensions.Configuration to 4.0.868 (#1349)