Soenneker.AdaptiveCard.Util 4.0.629

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Soenneker.AdaptiveCard.Util --version 4.0.629
                    
NuGet\Install-Package Soenneker.AdaptiveCard.Util -Version 4.0.629
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Soenneker.AdaptiveCard.Util" Version="4.0.629" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.AdaptiveCard.Util" Version="4.0.629" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.AdaptiveCard.Util" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Soenneker.AdaptiveCard.Util --version 4.0.629
                    
#r "nuget: Soenneker.AdaptiveCard.Util, 4.0.629"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Soenneker.AdaptiveCard.Util@4.0.629
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Soenneker.AdaptiveCard.Util&version=4.0.629
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.AdaptiveCard.Util&version=4.0.629
                    
Install as a Cake Tool

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

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:

  • Build creates a title/summary card with optional facts, exception details, and additional text.
  • BuildTable turns 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.

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
Loading failed

Update dependency Soenneker.Utils.Environment to 4.0.723 (#1358)