< 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@d9261bd752e45afa789d10bc0c82b7d5724d9589
Line coverage
56%
Covered lines: 27
Uncovered lines: 21
Coverable lines: 48
Total lines: 129
Line coverage: 56.2%
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@d9261bd752e45afa789d10bc0c82b7d5724d9589 02/05/2026 - 00:28:18 Line coverage: 56.2% (27/48) Branch coverage: 0% (0/2) Total lines: 129 Tag: Kestrun/Kestrun@d9261bd752e45afa789d10bc0c82b7d5724d9589

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Name()100%11100%
get_Description()100%210%
get_AllowedRequestContentTypes()100%11100%
.ctor()50%6685.71%
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%210%

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>
 2011    public string? Name { get; set; }
 12
 13    /// <summary>
 14    /// Gets or sets the description of the form parser.
 15    /// </summary>
 016    public string? Description { get; set; }
 17    /// <summary>
 18    /// Gets the allowed request content types.
 19    /// </summary>
 1520    public List<string> AllowedRequestContentTypes { get; } =
 1521    [
 1522        "multipart/form-data"
 1523    ];
 24
 25    /// <summary>
 26    /// Gets or sets a value indicating whether unknown request content types should be rejected.
 27    /// </summary>
 2228    public bool RejectUnknownRequestContentType { get; set; } = true;
 29
 30    /// <summary>
 31    /// Gets the form parsing limits.
 32    /// </summary>
 5233    public KrFormLimits Limits { get; } = new();
 34
 35    /// <summary>
 36    /// Gets or sets the default upload path for stored parts.
 37    /// </summary>
 1838    public string DefaultUploadPath { get; set; } = KestrunHostManager.Default?.Options.DefaultUploadPath ?? Path.Combin
 39
 40    /// <summary>
 41    /// Gets or sets the filename sanitizer.
 42    /// </summary>
 1543    public Func<string, string> SanitizeFileName { get; set; } = static name =>
 1544    {
 045        var sanitized = Path.GetFileName(name);
 046        return string.IsNullOrWhiteSpace(sanitized) ? Path.GetRandomFileName() : sanitized;
 1547    };
 48
 49    /// <summary>
 50    /// Gets or sets a value indicating whether SHA-256 hashes should be computed for file parts.
 51    /// </summary>
 752    public bool ComputeSha256 { get; set; }
 53
 54    /// <summary>
 55    /// Gets or sets a value indicating whether per-part decompression is enabled.
 56    /// </summary>
 1457    public bool EnablePartDecompression { get; set; }
 58
 59    /// <summary>
 60    /// Gets the allowed part content encodings for decompression.
 61    /// </summary>
 462    public List<string> AllowedPartContentEncodings { get; } =
 1563    [
 1564        "identity",
 1565        "gzip",
 1566        "deflate",
 1567        "br"
 1568    ];
 69
 70    /// <summary>
 71    /// Gets or sets the maximum decompressed bytes per part.
 72    /// </summary>
 1773    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>
 2178    public bool RejectUnknownContentEncoding { get; set; } = true;
 79
 80    /// <summary>
 81    /// Gets the per-part rules.
 82    /// </summary>
 6783    public List<KrFormPartRule> Rules { get; } = [];
 84
 85    /// <summary>
 86    /// Gets or sets the hook invoked for each part.
 87    /// </summary>
 488    public Func<KrPartContext, ValueTask<KrPartAction>>? OnPart { get; set; }
 89
 90    /// <summary>
 91    /// Gets or sets the hook invoked after parsing completes.
 92    /// </summary>
 593    public Func<KrFormContext, ValueTask<object?>>? OnCompleted { get; set; }
 94
 95    /// <summary>
 96    /// Gets or sets the logger used by the form parser.
 97    /// </summary>
 2098    public Serilog.ILogger? Logger { get; set; }
 99
 100    /// <summary>
 101    /// Initializes a new instance of the <see cref="KrFormOptions"/> class.
 102    /// </summary>
 30103    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>
 0109    public KrFormOptions(KrFormOptions copyFrom)
 110    {
 0111        Name = copyFrom.Name;
 0112        Description = copyFrom.Description;
 0113        AllowedRequestContentTypes.AddRange(copyFrom.AllowedRequestContentTypes);
 0114        RejectUnknownRequestContentType = copyFrom.RejectUnknownRequestContentType;
 0115        DefaultUploadPath = copyFrom.DefaultUploadPath;
 0116        SanitizeFileName = copyFrom.SanitizeFileName;
 0117        ComputeSha256 = copyFrom.ComputeSha256;
 0118        EnablePartDecompression = copyFrom.EnablePartDecompression;
 0119        AllowedPartContentEncodings.AddRange(copyFrom.AllowedPartContentEncodings);
 0120        MaxDecompressedBytesPerPart = copyFrom.MaxDecompressedBytesPerPart;
 0121        RejectUnknownContentEncoding = copyFrom.RejectUnknownContentEncoding;
 0122        Rules.AddRange(copyFrom.Rules);
 0123        OnPart = copyFrom.OnPart;
 0124        OnCompleted = copyFrom.OnCompleted;
 0125        Logger = copyFrom.Logger;
 126        // Copy limits
 0127        Limits = new KrFormLimits(copyFrom.Limits);
 0128    }
 129}