![]() |
VOOZH | about |
dotnet add package Oakrey.Applications.Reporting --version 3.0.4
NuGet\Install-Package Oakrey.Applications.Reporting -Version 3.0.4
<PackageReference Include="Oakrey.Applications.Reporting" Version="3.0.4" />
<PackageVersion Include="Oakrey.Applications.Reporting" Version="3.0.4" />Directory.Packages.props
<PackageReference Include="Oakrey.Applications.Reporting" />Project file
paket add Oakrey.Applications.Reporting --version 3.0.4
#r "nuget: Oakrey.Applications.Reporting, 3.0.4"
#:package Oakrey.Applications.Reporting@3.0.4
#addin nuget:?package=Oakrey.Applications.Reporting&version=3.0.4Install as a Cake Addin
#tool nuget:?package=Oakrey.Applications.Reporting&version=3.0.4Install as a Cake Tool
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.
IReporter<TStatus, TObject> and IReportConsumer<TStatus, TObject> contracts driven by a caller-defined TStatus enum.ReportBegin ? BlockBegin ? ItemBegin ? ItemCompleted ? BlockCompleted ? ReportCompleted.Oakrey.Evidences.IEvidence.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.IReportFilePathProvider.IReporterTypeNameProvider.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 |
Oakrey.Collections >= 2.0.0Oakrey.Evidences >= 2.0.0Oakrey.Files >= 3.0.0Oakrey.Strings >= 2.1.0dotnet add package Oakrey.Applications.Reporting
Install-Package Oakrey.Applications.Reporting
Search for Oakrey.Applications.Reporting under Tools > NuGet Package Manager > Manage NuGet Packages for Solution.
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"));
}
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";
}
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);
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);
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.| 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 |
This project is licensed under the MIT License.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0-windows7.0 net10.0-windows7.0 is compatible. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.