< Summary

Information
Class: TeleFlow.Framework.States.DefaultStateStorageKeyBuilder
Assembly: TeleFlow.Framework.Core
File(s): /_/src/TeleFlow.Framework.Core/States/DefaultStateStorageKeyBuilder.cs
Line coverage
94%
Covered lines: 18
Uncovered lines: 1
Coverable lines: 19
Total lines: 39
Line coverage: 94.7%
Branch coverage
85%
Covered branches: 6
Total branches: 7
Branch coverage: 85.7%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
Build(...)100%11100%
FormatPart(...)80%5587.5%
Escape(...)100%22100%

File(s)

/_/src/TeleFlow.Framework.Core/States/DefaultStateStorageKeyBuilder.cs

#LineLine coverage
 1namespace TeleFlow.Framework.States;
 2
 3/// <summary>
 4/// Builds deterministic string keys from <see cref="StateKey"/> for durable state providers while
 5/// preserving the structured state ownership model used by the runtime pipeline.
 6/// </summary>
 7public sealed class DefaultStateStorageKeyBuilder : IStateStorageKeyBuilder
 8{
 9    public string Build(StateKey key, StateStorageKeyPart part)
 10    {
 511        return string.Join(
 512            ":",
 513            Escape(key.Namespace),
 514            FormatPart(part),
 515            $"scope={Escape(key.Scope)}",
 516            $"subject={Escape(key.Subject)}",
 517            $"partition={Escape(key.Partition)}",
 518            $"destiny={Escape(key.Destiny)}");
 19    }
 20
 21    private static string FormatPart(StateStorageKeyPart part)
 22    {
 523        return part switch
 524        {
 225            StateStorageKeyPart.State => "state",
 126            StateStorageKeyPart.Data => "data",
 127            StateStorageKeyPart.History => "history",
 128            StateStorageKeyPart.Lock => "lock",
 029            _ => throw new ArgumentOutOfRangeException(nameof(part), part, "Unknown state storage key part.")
 530        };
 31    }
 32
 33    private static string Escape(string? value)
 34    {
 2535        return value is null
 2536            ? string.Empty
 2537            : Uri.EscapeDataString(value);
 38    }
 39}