Oakrey.Applications.Reporting 3.0.3

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

Oakrey.Applications.Reporting

A .NET 10 Windows library for structured, lifecycle-driven reporting. The library defines a generic reporting pipeline built around a TStatus : Enum and supports hierarchical report/block/item events, evidence attachment, key-value metadata, thread-safe file output, and multi-consumer fanout.

Main Features

  • Generic IReporter<TStatus, TObject> and IReportConsumer<TStatus, TObject> contracts driven by a caller-defined TStatus enum.
  • Hierarchical lifecycle: ReportBegin ? BlockBegin ? ItemBegin ? ItemCompleted ? BlockCompleted ? ReportCompleted.
  • Evidence attachment on every item completion via Oakrey.Evidences.IEvidence.
  • Key-value properties and trace list carried by ReportMetadata.
  • RunnableReporter fans out all lifecycle events to multiple IReportConsumer instances simultaneously.
  • FileReporter writes timestamped .txt report files with thread-safe locking.
  • DocumentsReportFilePathProvider writes reports to %USERPROFILE%\Documents\Reports with compact date-time file names.
  • Pluggable file path strategy via IReportFilePathProvider.
  • Pluggable label strategy via IReporterTypeNameProvider.

Architecture

classDiagram
    class IReporter~TStatus,TObject~ {
        +ReportBegin(summary, metadata)
        +ReportCompleted(status, summary, passObject)
        +BlockBegin(name)
        +BlockCompleted(name)
        +ItemBegin(item)
        +ItemCompleted(item, status, evidence)
        +ItemCompleted(item, status, evidence, message)
    }

    class IReportConsumer~TStatus,TObject~ {
        +ReportBegin(summary, metadata)
        +ReportCompleted(status, summary, passObject)
        +BlockBegin(name)
        +BlockCompleted(name)
        +ItemBegin(item)
        +ItemCompleted(item, status, evidence)
    }

    class RunnableReporter~TStatus,TObject~ {
        +RunnableReporter(IEnumerable~IReportConsumer~)
    }

    class FileReporter~TStatus,TObject~ {
        +FileReporter(IReportFilePathProvider, IReporterTypeNameProvider)
        +Dispose()
    }

    class IReportFilePathProvider {
        +GetDirectoryPath() DirectoryInfo
        +GetFileInfo() FileInfo
    }

    class DocumentsReportFilePathProvider
    class IReporterTypeNameProvider {
        +ReportName string
        +BlockName string
        +ItemName string
    }

    class ReportMetadata {
        +Properties Dictionary~string,string~
        +Traces List~string~
    }

    IReporter~TStatus,TObject~ <|.. RunnableReporter~TStatus,TObject~
    IReportConsumer~TStatus,TObject~ <|.. FileReporter~TStatus,TObject~
    RunnableReporter~TStatus,TObject~ --> IReportConsumer~TStatus,TObject~
    FileReporter~TStatus,TObject~ --> IReportFilePathProvider
    FileReporter~TStatus,TObject~ --> IReporterTypeNameProvider
    IReportFilePathProvider <|.. DocumentsReportFilePathProvider
Type Responsibility
IReporter<TStatus,TObject> Public contract for the full reporting lifecycle
IReportConsumer<TStatus,TObject> Contract for individual output sinks
RunnableReporter<TStatus,TObject> Multicasts all events to a collection of IReportConsumer instances
FileReporter<TStatus,TObject> Thread-safe file sink; opens/closes a .txt file per report run
IReportFilePathProvider Abstracts directory and file path resolution
DocumentsReportFilePathProvider Default provider: Documents\Reports\ with compact date-time naming
IReporterTypeNameProvider Provides the label strings used as line prefixes in the output
ReportMetadata Carries key-value properties and a trace list attached to a report

Requirements

  • .NET 10 (Windows)
  • Oakrey.Collections >= 2.0.0
  • Oakrey.Evidences >= 2.0.0
  • Oakrey.Files >= 3.0.0
  • Oakrey.Strings >= 2.1.0

Installation

.NET CLI

dotnet add package Oakrey.Applications.Reporting

Package Manager Console

Install-Package Oakrey.Applications.Reporting

NuGet Package Manager

Search for Oakrey.Applications.Reporting under Tools > NuGet Package Manager > Manage NuGet Packages for Solution.

Configuration

File path strategy

Implement IReportFilePathProvider to control where reports are written. The built-in DocumentsReportFilePathProvider resolves to %USERPROFILE%\Documents\Reports\ and generates compact date-time file names via Oakrey.Files.FileNameSource.

// Built-in � Documents\Reports\
IReportFilePathProvider pathProvider = new DocumentsReportFilePathProvider();

// Custom
public class MyPathProvider : IReportFilePathProvider
{
    public DirectoryInfo GetDirectoryPath() => new(@"C:\MyApp\Reports");
    public FileInfo GetFileInfo() => new(Path.Combine(@"C:\MyApp\Reports", $"report_{DateTime.Now:yyyyMMddHHmmss}.txt"));
}

Label strategy

Implement IReporterTypeNameProvider to control the line prefixes in the output file.

public class MyLabels : IReporterTypeNameProvider
{
    public string ReportName => "REPORT";
    public string BlockName  => "BLOCK";
    public string ItemName   => "ITEM";
}

Example Usage

Single file consumer

using Oakrey.Applications.Reporting;

IReportFilePathProvider pathProvider = new DocumentsReportFilePathProvider();
IReporterTypeNameProvider labels = new MyLabels();

using FileReporter<MyStatus, string> consumer = new(pathProvider, labels);

ReportMetadata metadata = new()
{
    Properties = new Dictionary<string, string> { ["Environment"] = "Production" },
    Traces = ["Build 42"]
};

consumer.ReportBegin("Nightly run", metadata);
consumer.BlockBegin("Validation");
consumer.ItemBegin(myItem);
consumer.ItemCompleted(myItem, MyStatus.Passed, evidence);
consumer.BlockCompleted("Validation");
consumer.ReportCompleted(MyStatus.Passed, "All checks passed", null);

Multi-consumer fanout

IReportConsumer<MyStatus, string>[] consumers = [fileReporter, otherConsumer];
IReporter<MyStatus, string> reporter = new RunnableReporter<MyStatus, string>(consumers);

reporter.ReportBegin("Nightly run", metadata);
// All lifecycle calls are broadcast to every consumer.
reporter.ReportCompleted(MyStatus.Passed, "Done", null);

Development Notes

  • The project targets net10.0-windows; it is not cross-platform.
  • FileReporter uses System.Threading.Lock (C# 13 / .NET 9+) for thread safety � do not port to older runtimes without replacing the lock.
  • FileReporter must be disposed to flush and close the underlying FileStream.
  • RunnableReporter does not own or dispose its consumers; caller is responsible for lifetime management.
  • ReportMetadata is a struct � pass by reference or assign explicitly to avoid unintended copies.

Project Information

Property Value
Author Oakrey
License MIT
NuGet package Oakrey.Applications.Reporting
Repository https://dev.azure.com/oakrey/OpenPackages/_git/ApplicationServices
Package URL https://www.oakrey.cz/opkg_applications

License

This project is licensed under the MIT License.

Product Compatible and additional computed target framework versions.
.NET net10.0-windows7.0 is compatible. 
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
3.0.3 36 5/15/2026
3.0.2 113 3/13/2026
3.0.1 114 2/11/2026
3.0.0 437 11/18/2025
2.0.1 227 9/29/2025
2.0.0 237 8/4/2025
1.0.0 283 4/17/2025