didx.iso20022.sdk 1.0.5

dotnet add package didx.iso20022.sdk --version 1.0.5
                    
NuGet\Install-Package didx.iso20022.sdk -Version 1.0.5
                    
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="didx.iso20022.sdk" Version="1.0.5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="didx.iso20022.sdk" Version="1.0.5" />
                    
Directory.Packages.props
<PackageReference Include="didx.iso20022.sdk" />
                    
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 didx.iso20022.sdk --version 1.0.5
                    
#r "nuget: didx.iso20022.sdk, 1.0.5"
                    
#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 didx.iso20022.sdk@1.0.5
                    
#: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=didx.iso20022.sdk&version=1.0.5
                    
Install as a Cake Addin
#tool nuget:?package=didx.iso20022.sdk&version=1.0.5
                    
Install as a Cake Tool

๐Ÿ’ผ ISO 20022 SDK

A modern C# SDK that provides strongly-typed ISO 20022 message models, full schema validation, and rich conversion utilities.

โœ… Built on .NET 9


๐Ÿ“ฆ Install

๐Ÿ”— Package on NuGet

NuGet

๐ŸŒ Package source

nuget.org (https://api.nuget.org/v3/index.json)

๐Ÿ“ฅ Install package

Install-Package didx.iso20022.sdk

๐Ÿ”— Source

All message definitions are sourced directly from the official ISO 20022 registry:
๐Ÿ”— https://www.iso20022.org/iso-20022-message-definitions


โœ… Features

  • ๐Ÿงฉ Strongly-typed C# models for ISO 20022 messages
  • ๐Ÿ“„ Auto-validated against official XSD schemas
  • ๐Ÿงช FluentValidation-based semantic rule checking
  • ๐Ÿ” Convert to/from XML and JSON using extensions
  • ๐Ÿ› ๏ธ Tooling to download, parse, and generate message models
  • ๐Ÿง  Intuitive structure โ€“ each message lives in its own namespace

๐Ÿงฑ Structure

๐Ÿ“‚ Didx.Iso20022.Sdk

The core SDK containing:

  • Generated message classes in Contracts/*
  • Embedded schema resources (Schema.xsd)
  • Validators (Validator.cs)
  • Conversion extensions
  • Schema validation logic

Each ISO 20022 message is structured in a dedicated namespace:

Contracts/{Area}/{Message}/Model.cs  
Contracts/{Area}/{Message}/Schema.xsd  
Validation/{Area}/{Message}/Validator.cs

Each message has a root object named Document.


๐Ÿ”ง Didx.Iso20022.Sdk.Tools

Handles code generation:

  • Downloads ZIPs per area/message from ISO 20022
  • Extracts schemas
  • Generates Model.cs, Schema.xsd, and Validator.cs files
  • Preserves existing files (no overwrites)

Run generation:

dotnet run --project ./Didx.Iso20022.Sdk.Tools -- --generate
โš™๏ธ Configuration โ€“ appsettings.json

This configuration determines which ISO 20022 schemas are downloaded and which message contracts and validators are generated.

You can configure multiple message areas (e.g. Pain, Acmt, Head) under MessageDefinitions.Areas. Each area includes:

  • NamespaceSuffix: Used as the namespace and folder name under Contracts/
  • XsdDownloadUrl: URL pointing to the official ISO 20022 ZIP file for the business area
  • RootElementNameInSchema (optional): Overrides the expected root element in the XSD. Defaults to Document. Use AppHdr for head messages.
  • Messages (optional): List of specific messages to process. Each item includes:
    • Id: The full ISO 20022 message ID
    • GenerateValidator: Whether a FluentValidation class should be generated (true by default)

If Messages is omitted, all .xsd files in the ZIP will be processed, and validators will be generated for all.


โœ… Example: Specific Messages with Validator Control
{
  "MessageDefinitions": {
    "Areas": [
      {
        "NamespaceSuffix": "Pain",
        "XsdDownloadUrl": "https://www.iso20022.org/business-area/81/download",
        "Messages": [
          { "Id": "pain.001.001.12", "GenerateValidator": true },
          { "Id": "pain.002.001.14", "GenerateValidator": false }
        ]
      },
      {
        "NamespaceSuffix": "Head",
        "XsdDownloadUrl": "https://www.iso20022.org/business-area/136/download",
        "RootElementNameInSchema": "AppHdr",
        "Messages": [
          { "Id": "head.001.001.02", "GenerateValidator": true },
          { "Id": "head.001.001.04", "GenerateValidator": false }
        ]
      }
    ]
  }
}
  • GenerateValidator: true โ†’ A Validator.cs class will be generated for the message
  • GenerateValidator: false โ†’ Only the Model.cs and embedded schema will be included
โœ… Example: Process All Messages in Area (No Messages Specified)
{
  "MessageDefinitions": {
    "Areas": [
      {
        "NamespaceSuffix": "Pain",
        "XsdDownloadUrl": "https://www.iso20022.org/business-area/81/download"
      },
      {
        "NamespaceSuffix": "Acmt",
        "XsdDownloadUrl": "https://www.iso20022.org/business-area/26/download"
      }
    ]
  }
}
๐Ÿ“ฆ Output per Message

For every processed message, the following files are generated under the Contracts/{NamespaceSuffix}/ folder:

  • Model.cs โ€“ Strongly-typed C# class for the message
  • Schema.xsd โ€“ Embedded ISO 20022 schema
  • Validator.cs โ€“ FluentValidation stub (optional, based on GenerateValidator)

๐Ÿงช Didx.Iso20022.Sdk.Tests

Unit tests ensure:

  • Schema validation works for known-good samples
  • Fluent validators pass
  • XML/JSON round-trips serialize/deserialize correctly

Example:

using Didx.Iso20022.Sdk.Extensions;
using FluentAssertions;
using Document = Didx.Iso20022.Sdk.Contracts.Pain.Creditor.Payment.Activation.Request.Status.Report.V11.Document;
using Validator = Didx.Iso20022.Sdk.Validation.Pain.Creditor.Payment.Activation.Request.Status.Report.V11.Validator;

public class Tests : MessageTestBase<Document>
{
    protected override string SampleFileName => "Sample.xml";

    [Fact]
    public void FromXml_ShouldDeserializeSuccessfully()
    {
        var xml = Sample.ToXml();
        var result = xml.FromXml<Document>();
        result.Should().NotBeNull();
        result.CdtrPmtActvtnReqStsRpt.Should().NotBeNull();
    }

    [Fact]
    public void ToXml_ShouldSerializeSuccessfully()
    {
        var xml = Sample.ToXml();
        xml.Should().Contain("Document").And.Contain("CdtrPmtActvtnReqStsRpt");
    }

    [Fact]
    public void ToJson_ShouldSerializeSuccessfully()
    {
        var json = Sample.ToJson();
        json.Should().Contain("cdtrPmtActvtnReqStsRpt");
    }

    [Fact]
    public void FromJson_ShouldDeserializeSuccessfully()
    {
        var json = Sample.ToJson();
        var result = json.FromJson<Document>();
        result.Should().NotBeNull();
    }

    [Fact]
    public void Validate_ShouldPassSchemaValidation()
    {
        Sample.ValidateSchema();
    }

    [Fact]
    public void Validate_ShouldPassFluentValidation()
    {
        var validator = new Validator();
        var result = validator.Validate(Sample);

        Assert.True(result.IsValid, $"Validation failed: {string.Join("; ", result.Errors.Select(e => e.ErrorMessage))}");
    }
}

๐Ÿท๏ธ [MessageMetadata] Attribute

Each generated Document class includes a [MessageMetadata] attribute, exposing key ISO 20022 metadata at runtime:

[MessageMetadata(
    Id = "pain.001.001.12",
    Name = "CustomerCreditTransferInitiationV12",
    BusinessArea = "Pain",
    Version = "001.12")]
public class Document
{
    // ...
}

This metadata helps with introspection, routing, logging, and analysis.


๐Ÿ” Accessing Metadata at Runtime

Use the MessageMetadataResolver to easily retrieve metadata for any message type:

var metadata = MessageMetadataResolver.Get<Document>();
Console.WriteLine(metadata?.Id);           // "pain.001.001.12"
Console.WriteLine(metadata?.Name);         // "CustomerCreditTransferInitiationV12"
Console.WriteLine(metadata?.BusinessArea); // "Pain"
Console.WriteLine(metadata?.Version);      // "001.12"

Or with a Type instance:

var metadata = MessageMetadataResolver.Get(typeof(Document));

This enables tools, validators, and consumers to programmatically identify ISO 20022 messages.

๐Ÿ” Conversion & Validation Extensions

These helper methods simplify working with ISO 20022 documents:

var xml = message.ToXml();
var json = message.ToJson();

var messageFromXml = xml.FromXml<Document>();
var messageFromJson = json.FromJson<Document>();

message.ValidateSchema(); // Validate against XSD

Extensions live under Didx.Iso20022.Sdk.Extensions.


๐Ÿงฉ Validation Flow

Validation runs in two layers:

  1. XSD Schema Validation
Document.ValidateSchema();

This invokes:

Didx.Iso20022.Sdk.Validation.MessageSchemaValidator.Validate(Document);

Throws a FluentValidation.ValidationException if the payload is not schema-compliant.

  1. FluentValidation
var validator = new Validator();
var result = validator.Validate(Document);

Each Validator.cs is found under its message-specific namespace. Only base validation rules are generated automatically โ€” customize as needed.


๐Ÿ’ก Notes

  • Schema.xsd is embedded per message and used for validation.
  • Generated files (Model.cs, Schema.xsd, Validator.cs) are additive and organized by namespace.
  • File generation is non-destructive โ€” existing files are never overwritten.
Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.5 189 6/18/2025
1.0.4 170 6/17/2025
1.0.3 167 6/17/2025
1.0.2 170 6/17/2025
1.0.1 180 6/17/2025
1.0.0 171 6/5/2025

Initial release of the ISO 20022 SDK