Flow.Scorecard 0.0.2

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

Flow.Scorecard

MIT

A typed, fluent scorecard engine for .NET 10.

Concepts

A scorecard has an ID, name, optional description and version, and an ordered set of scoring rules. Each rule returns a decimal contribution:

  • A positive value increases the total.
  • A negative value applies a penalty.
  • Zero means the rule made no contribution.

Rules run sequentially in registration order. A rule exception is captured in its result and contributes zero, while later rules continue to execute. Cancellation stops execution immediately and propagates OperationCanceledException; no partial scorecard result is returned.

Getting started

Install the package:

dotnet add package Flow.Scorecard

Define the DTO and scorecard:

public sealed record CustomerScoreRequest(
    int Age,
    decimal AnnualIncome,
    int YearsAtAddress,
    int MissedPayments);

Scorecard<CustomerScoreRequest> scorecard = ScorecardBuilder<CustomerScoreRequest>.Create()
    .WithId("CUSTOMER-001")
    .WithName("Customer suitability score")
    .WithVersion("1.0.0")
    .WithRule("AGE", "Age range", request => request.Age is >= 25 and <= 65 ? 20m : 0m)
    .WithRule("INCOME", "Income", request => request.AnnualIncome switch
    {
        >= 75_000m => 40m,
        >= 40_000m => 25m,
        _ => 0m,
    })
    .WithRule("STABILITY", "Address stability", request =>
        Math.Min(request.YearsAtAddress * 5m, 20m))
    .WithRule("MISSED", "Missed payments", request => request.MissedPayments * -15m)
    .Build();

Synchronous, Task<decimal>, and ValueTask<decimal> rules are supported. Asynchronous rules also receive a cancellation token.

Dependency injection and execution

Register one or more scorecards. Registrations are keyed by scorecard ID, allowing the same DTO type to have multiple scorecards:

services.AddFlowScorecard<CustomerScoreRequest>(() => scorecard);
services.AddFlowScorecardRegistry();

Execute a known scorecard through its typed manager:

IScorecardManager<CustomerScoreRequest> manager =
    serviceProvider.GetRequiredKeyedService<IScorecardManager<CustomerScoreRequest>>("CUSTOMER-001");

string correlationId =
    Activity.Current?.TraceId.ToString()
    ?? Guid.CreateVersion7().ToString();

Guid executionContextId = Guid.CreateVersion7();

ScorecardExecutionResult result = await manager.Execute(
    correlationId,
    executionContextId,
    request,
    cancellationToken);

Or dispatch by ID through the registry, including across different DTO types:

ScorecardExecutionResult result = await registry.ExecuteAsync(
    "CUSTOMER-001",
    correlationId,
    executionContextId,
    request,
    cancellationToken);

Acting on a score

Flow.Scorecard deliberately has no score-band or action model. Keep those application decisions with the caller:

string nextAction = result.TotalScore switch
{
    >= 70m => "Proceed",
    >= 40m => "Refer for review",
    _ => "Stop",
};

Check result.Succeeded before trusting the score as complete. Each ScoringRuleExecutionResult includes the rule's score, elapsed time, success state, metadata, and any captured exception.

Building and testing

dotnet build src/Flow.Scorecard.slnx
dotnet test src/Flow.Scorecard.slnx
dotnet run --project src/Flow.Scorecard.Samples.Console

Contributing

Contributions are welcome. See CONTRIBUTING.md before opening an issue or pull request.

License

MIT License. See 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.

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
0.0.2 124 8/16/2026