< Summary - Kestrun — Combined Coverage

Information
Class: Kestrun.Forms.KrFormOptions
Assembly: Kestrun
File(s): /home/runner/work/Kestrun/Kestrun/src/CSharp/Kestrun/Forms/KrFormOptions.cs
Tag: Kestrun/Kestrun@5f1d2b981c9d7292c11fd448428c6ab6c811c5de
Line coverage
95%
Covered lines: 46
Uncovered lines: 2
Coverable lines: 48
Total lines: 129
Line coverage: 95.8%
Branch coverage
0%
Covered branches: 0
Total branches: 2
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 02/05/2026 - 00:28:18 Line coverage: 56.2% (27/48) Branch coverage: 0% (0/2) Total lines: 129 Tag: Kestrun/Kestrun@d9261bd752e45afa789d10bc0c82b7d5724d958903/26/2026 - 03:54:59 Line coverage: 95.8% (46/48) Branch coverage: 0% (0/2) Total lines: 129 Tag: Kestrun/Kestrun@844b5179fb0492dc6b1182bae3ff65fa7365521d 02/05/2026 - 00:28:18 Line coverage: 56.2% (27/48) Branch coverage: 0% (0/2) Total lines: 129 Tag: Kestrun/Kestrun@d9261bd752e45afa789d10bc0c82b7d5724d958903/26/2026 - 03:54:59 Line coverage: 95.8% (46/48) Branch coverage: 0% (0/2) Total lines: 129 Tag: Kestrun/Kestrun@844b5179fb0492dc6b1182bae3ff65fa7365521d

Coverage delta

Coverage delta 40 -40

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Name()100%11100%
get_Description()100%11100%
get_AllowedContentTypes()100%11100%
.ctor()0%6692.59%
get_RejectUnknownRequestContentType()100%11100%
get_Limits()100%11100%
get_DefaultUploadPath()100%11100%
get_SanitizeFileName()100%11100%
get_ComputeSha256()100%11100%
get_EnablePartDecompression()100%11100%
get_AllowedPartContentEncodings()100%11100%
get_MaxDecompressedBytesPerPart()100%11100%
get_RejectUnknownContentEncoding()100%11100%
get_Rules()100%11100%
get_OnPart()100%11100%
get_OnCompleted()100%11100%
get_Logger()100%11100%
.ctor(...)100%11100%

File(s)

/home/runner/work/Kestrun/Kestrun/src/CSharp/Kestrun/Forms/KrFormOptions.cs

#LineLine coverage
 1namespace Kestrun.Forms;
 2
 3/// <summary>
 4/// Configures form parsing behavior for Kestrun.
 5/// </summary>
 6public sealed class KrFormOptions
 7{
 8    /// <summary>
 9    /// Gets or sets the name of the form parser.
 10    /// </summary>
 2711    public string? Name { get; set; }
 12
 13    /// <summary>
 14    /// Gets or sets the description of the form parser.
 15    /// </summary>
 216    public string? Description { get; set; }
 17    /// <summary>
 18    /// Gets the allowed request content types.
 19    /// </summary>
 4220    public List<string> AllowedContentTypes { get; } =
 2821    [
 2822        "multipart/form-data"
 2823    ];
 24
 25    /// <summary>
 26    /// Gets or sets a value indicating whether unknown request content types should be rejected.
 27    /// </summary>
 3828    public bool RejectUnknownRequestContentType { get; set; } = true;
 29
 30    /// <summary>
 31    /// Gets the form parsing limits.
 32    /// </summary>
 6733    public KrFormLimits Limits { get; } = new();
 34
 35    /// <summary>
 36    /// Gets or sets the default upload path for stored parts.
 37    /// </summary>
 3338    public string DefaultUploadPath { get; set; } = KestrunHostManager.Default?.Options.DefaultUploadPath ?? Path.Combin
 39
 40    /// <summary>
 41    /// Gets or sets the filename sanitizer.
 42    /// </summary>
 3043    public Func<string, string> SanitizeFileName { get; set; } = static name =>
 2844    {
 045        var sanitized = Path.GetFileName(name);
 046        return string.IsNullOrWhiteSpace(sanitized) ? Path.GetRandomFileName() : sanitized;
 2847    };
 48
 49    /// <summary>
 50    /// Gets or sets a value indicating whether SHA-256 hashes should be computed for file parts.
 51    /// </summary>
 1052    public bool ComputeSha256 { get; set; }
 53
 54    /// <summary>
 55    /// Gets or sets a value indicating whether per-part decompression is enabled.
 56    /// </summary>
 1757    public bool EnablePartDecompression { get; set; }
 58
 59    /// <summary>
 60    /// Gets the allowed part content encodings for decompression.
 61    /// </summary>
 662    public List<string> AllowedPartContentEncodings { get; } =
 2863    [
 2864        "identity",
 2865        "gzip",
 2866        "deflate",
 2867        "br"
 2868    ];
 69
 70    /// <summary>
 71    /// Gets or sets the maximum decompressed bytes per part.
 72    /// </summary>
 3273    public long MaxDecompressedBytesPerPart { get; set; } = 20 * 1024 * 1024;
 74
 75    /// <summary>
 76    /// Gets or sets a value indicating whether unknown content encodings should be rejected.
 77    /// </summary>
 3778    public bool RejectUnknownContentEncoding { get; set; } = true;
 79
 80    /// <summary>
 81    /// Gets the per-part rules.
 82    /// </summary>
 11083    public List<KrFormPartRule> Rules { get; } = [];
 84
 85    /// <summary>
 86    /// Gets or sets the hook invoked for each part.
 87    /// </summary>
 688    public Func<KrPartContext, ValueTask<KrPartAction>>? OnPart { get; set; }
 89
 90    /// <summary>
 91    /// Gets or sets the hook invoked after parsing completes.
 92    /// </summary>
 793    public Func<KrFormContext, ValueTask<object?>>? OnCompleted { get; set; }
 94
 95    /// <summary>
 96    /// Gets or sets the logger used by the form parser.
 97    /// </summary>
 2498    public Serilog.ILogger? Logger { get; set; }
 99
 100    /// <summary>
 101    /// Initializes a new instance of the <see cref="KrFormOptions"/> class.
 102    /// </summary>
 54103    public KrFormOptions() { }
 104
 105    /// <summary>
 106    /// Initializes a new instance of the <see cref="KrFormOptions"/> class by copying settings from another instance.
 107    /// </summary>
 108    /// <param name="copyFrom">The instance to copy settings from.</param>
 1109    public KrFormOptions(KrFormOptions copyFrom)
 110    {
 1111        Name = copyFrom.Name;
 1112        Description = copyFrom.Description;
 1113        AllowedContentTypes.AddRange(copyFrom.AllowedContentTypes);
 1114        RejectUnknownRequestContentType = copyFrom.RejectUnknownRequestContentType;
 1115        DefaultUploadPath = copyFrom.DefaultUploadPath;
 1116        SanitizeFileName = copyFrom.SanitizeFileName;
 1117        ComputeSha256 = copyFrom.ComputeSha256;
 1118        EnablePartDecompression = copyFrom.EnablePartDecompression;
 1119        AllowedPartContentEncodings.AddRange(copyFrom.AllowedPartContentEncodings);
 1120        MaxDecompressedBytesPerPart = copyFrom.MaxDecompressedBytesPerPart;
 1121        RejectUnknownContentEncoding = copyFrom.RejectUnknownContentEncoding;
 1122        Rules.AddRange(copyFrom.Rules);
 1123        OnPart = copyFrom.OnPart;
 1124        OnCompleted = copyFrom.OnCompleted;
 1125        Logger = copyFrom.Logger;
 126        // Copy limits
 1127        Limits = new KrFormLimits(copyFrom.Limits);
 1128    }
 129}