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
<PackageReference Include="didx.iso20022.sdk" Version="1.0.5" />
<PackageVersion Include="didx.iso20022.sdk" Version="1.0.5" />
<PackageReference Include="didx.iso20022.sdk" />
paket add didx.iso20022.sdk --version 1.0.5
#r "nuget: didx.iso20022.sdk, 1.0.5"
#:package didx.iso20022.sdk@1.0.5
#addin nuget:?package=didx.iso20022.sdk&version=1.0.5
#tool nuget:?package=didx.iso20022.sdk&version=1.0.5
๐ผ 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
๐ 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, andValidator.csfiles - 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 underContracts/XsdDownloadUrl: URL pointing to the official ISO 20022 ZIP file for the business areaRootElementNameInSchema(optional): Overrides the expected root element in the XSD. Defaults toDocument. UseAppHdrfor head messages.Messages(optional): List of specific messages to process. Each item includes:Id: The full ISO 20022 message IDGenerateValidator: Whether a FluentValidation class should be generated (trueby 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โ AValidator.csclass will be generated for the messageGenerateValidator: falseโ Only theModel.csand 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 messageSchema.xsdโ Embedded ISO 20022 schemaValidator.csโ FluentValidation stub (optional, based onGenerateValidator)
๐งช 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:
- 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.
- 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.xsdis 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 | Versions 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. |
-
net9.0
- FluentValidation (>= 12.0.0)
- FluentValidation.DependencyInjectionExtensions (>= 12.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Initial release of the ISO 20022 SDK