MessageValidation.OnnxRuntime 2.2.0

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

MessageValidation.OnnxRuntime

Edge-AI validation for the MessageValidation pipeline: score every message with a local ONNX model (anomaly detector, outlier model…) and reject it when the score exceeds a threshold — on the device, with no cloud round-trip.

dotnet add package MessageValidation.OnnxRuntime

Usage

services.AddMessageValidation(o => o.MapSource<TemperatureReading>("sensors/+/temperature"));
services.AddMessageDeserializer<JsonMessageDeserializer>();

services.AddMessageOnnxValidation<TemperatureReading>(
    modelPath: "models/temperature-anomaly.onnx",
    features: r => [(float)r.Value, r.Humidity],
    threshold: 0.8f);

services.AddMessageHandler<TemperatureReading, TemperatureHandler>();

Readings scoring above 0.8 fail validation with a single error on property "$anomaly" (OnnxMessageValidator<T>.AnomalyPropertyName) and are routed through the configured FailureBehavior (log, dead-letter, custom…), just like a rule-based failure.

Model contract

Input First model input, float tensor of shape [1, n] built from features(message)
Output First model output; its first element is read as the float score
Decision score <= threshold → valid; otherwise (including NaN) → invalid

Any model exported to ONNX with that shape works: scikit-learn (skl2onnx) IsolationForest / OneClassSVM wrapped to emit a score, PyTorch/TensorFlow autoencoders emitting reconstruction error, etc.

Hardware acceleration

The model loads once (singleton InferenceSession, thread-safe). Tune it for the device:

services.AddMessageOnnxValidation<TemperatureReading>(path, features, 0.8f,
    configureSession: o =>
    {
        o.IntraOpNumThreads = 1;          // small edge boards
        // o.AppendExecutionProvider_CUDA();  // Jetson, with the GPU runtime package
    });

The package depends on the CPU Microsoft.ML.OnnxRuntime runtime (win/linux/macOS, x64 and arm64, incl. Raspberry Pi 64-bit). Swap in a GPU/NPU runtime package in your app if needed.

Notes

  • This is a closed IMessageValidator<T> registration, so for T it takes precedence over open-generic adapters such as AddMessageFluentValidation.
  • Trim / Native AOT compatible.
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  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 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

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
2.2.0 56 11/16/2026