MessageValidation.OnnxRuntime
2.2.0
dotnet add package MessageValidation.OnnxRuntime --version 2.2.0
NuGet\Install-Package MessageValidation.OnnxRuntime -Version 2.2.0
<PackageReference Include="MessageValidation.OnnxRuntime" Version="2.2.0" />
<PackageVersion Include="MessageValidation.OnnxRuntime" Version="2.2.0" />
<PackageReference Include="MessageValidation.OnnxRuntime" />
paket add MessageValidation.OnnxRuntime --version 2.2.0
#r "nuget: MessageValidation.OnnxRuntime, 2.2.0"
#:package MessageValidation.OnnxRuntime@2.2.0
#addin nuget:?package=MessageValidation.OnnxRuntime&version=2.2.0
#tool nuget:?package=MessageValidation.OnnxRuntime&version=2.2.0
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 forTit takes precedence over open-generic adapters such asAddMessageFluentValidation. - Trim / Native AOT compatible.
| Product | Versions 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. |
-
net10.0
- MessageValidation (>= 2.2.0)
- Microsoft.ML.OnnxRuntime (>= 1.31.0)
-
net8.0
- MessageValidation (>= 2.2.0)
- Microsoft.ML.OnnxRuntime (>= 1.31.0)
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 |