Moller.Utilities 1.0.3

There is a newer version of this package available.
See the version list below for details.
dotnet add package Moller.Utilities --version 1.0.3
                    
NuGet\Install-Package Moller.Utilities -Version 1.0.3
                    
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="Moller.Utilities" Version="1.0.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Moller.Utilities" Version="1.0.3" />
                    
Directory.Packages.props
<PackageReference Include="Moller.Utilities" />
                    
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 Moller.Utilities --version 1.0.3
                    
#r "nuget: Moller.Utilities, 1.0.3"
                    
#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 Moller.Utilities@1.0.3
                    
#: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=Moller.Utilities&version=1.0.3
                    
Install as a Cake Addin
#tool nuget:?package=Moller.Utilities&version=1.0.3
                    
Install as a Cake Tool

Moller.Utilities

Moller.Utilities is a small .NET utility library that currently provides:

  • Fluent validation helpers for arguments and state
  • A thread-safe PeriodicActionRunner for running repeated background work

Target Framework

This library currently targets net10.0.

Installation

Once published to NuGet, install it with:

dotnet add package Moller.Utilities

Features

Fluent Validation

The Validation API provides a chainable way to validate values and preserve the caller argument name automatically.

using Moller.Utilities;

string name = "Alice";

var validatedName = Validation.For(name)
    .IsNotNull()
    .IsNotEmpty()
    .IsNotNullOrWhiteSpace()
    .Ensure(x => x!.Length <= 50, "Name must be 50 characters or fewer.")
    .Value();

You can also use the instance-style extension syntax:

using Moller.Utilities;

string connectionName = "Primary";

var value = connectionName
    .Validate()
    .IsNotNull()
    .IsNotEmpty()
    .Value();

For simple reference-type null checks:

using Moller.Utilities;

MyService service = maybeNullService.RequireNotNull();

Supported validation helpers include:

  • IsNotNull()
  • IsNotDefault()
  • IsNotEmpty()
  • IsNotNullOrWhiteSpace()
  • Ensure(...)
  • IsInRange(...) for int, long, float, double, and decimal
  • IsPositive()
  • IsNegative()
  • IsNotZero()
  • Value()

PeriodicActionRunner

PeriodicActionRunner runs an Action immediately, then repeats it on a fixed interval using a background task.

using Moller.Utilities;

using var runner = new PeriodicActionRunner();

runner.Start(() =>
{
    Console.WriteLine($"Heartbeat: {DateTimeOffset.Now}");
}, intervalMilliseconds: 1000);

await Task.Delay(5000);
await runner.StopAsync();

You can also pass your own CancellationToken. In that case, the runner will observe that token, but it will not cancel or dispose it for you.

using Moller.Utilities;

using var cts = new CancellationTokenSource();
using var runner = new PeriodicActionRunner();

runner.Start(
    action: () => Console.WriteLine("Polling..."),
    intervalMilliseconds: 2000,
    cancellationToken: cts.Token);

cts.Cancel();
await runner.StopAsync();

Logging

PeriodicActionRunner accepts an optional ILogger<PeriodicActionRunner> and logs start, stop, execution, and exception events through Microsoft.Extensions.Logging.

using Microsoft.Extensions.Logging;
using Moller.Utilities;

ILogger<PeriodicActionRunner> logger = loggerFactory.CreateLogger<PeriodicActionRunner>();
using var runner = new PeriodicActionRunner(logger);

Notes

  • PeriodicActionRunner.Start(...) throws if the runner is already active.
  • StopAsync() is safe to call even if the runner was never started.
  • Stop() blocks synchronously and is best avoided on UI threads.
  • Exceptions thrown by the repeated action are logged and the loop continues running.

License

MIT License

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.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.2.0 0 3/23/2026
1.1.0 0 3/18/2026
1.0.3 0 3/18/2026
1.0.2 0 3/18/2026
1.0.1 0 3/18/2026
1.0.0 0 3/17/2026