< Summary - Kestrun — Combined Coverage

Information
Class: KestrunRuntimeApiAttribute
Assembly: Kestrun
File(s): /home/runner/work/Kestrun/Kestrun/src/CSharp/Kestrun/Utilities/KestrunRouteAttribute.cs
Tag: Kestrun/Kestrun@9d3a582b2d63930269564a7591aa77ef297cadeb
Line coverage
100%
Covered lines: 4
Uncovered lines: 0
Coverable lines: 4
Total lines: 64
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
get_Contexts()100%11100%
get_SafeForUntrusted()100%11100%
get_Notes()100%11100%

File(s)

/home/runner/work/Kestrun/Kestrun/src/CSharp/Kestrun/Utilities/KestrunRouteAttribute.cs

#LineLine coverage
 1#pragma warning disable CA1050
 2/// <summary>
 3/// Specifies the API context in which a Kestrun route or schedule can be executed.
 4/// </summary>
 5[Flags]
 6public enum KestrunApiContext
 7{
 8    /// <summary>
 9    /// No API context specified.
 10    /// </summary>
 11    None = 0,
 12    /// <summary>
 13    /// Used during module/configuration time.
 14    /// </summary>
 15    Definition = 1 << 0, // module/configuration time
 16    /// <summary>
 17    /// Used inside HTTP route execution.
 18    /// </summary>
 19    Route = 1 << 1, // inside HTTP route execution
 20
 21    /// <summary>
 22    /// Used during scheduled execution.
 23    /// </summary>
 24    Schedule = 1 << 2, // keep room for future split
 25
 26    /// <summary>
 27    /// Used during both scheduled execution and module/configuration time (shorthand for Schedule | Definition).
 28    /// </summary>
 29    ScheduleAndDefinition = Schedule | Definition,
 30    /// <summary>
 31    /// Used during both HTTP route and scheduled execution (shorthand for Route | Schedule).
 32    /// </summary>
 33    Runtime = Route | Schedule,             // if you like a shorthand
 34    /// <summary>
 35    /// Used in all available API contexts (Definition, Route, and Schedule).
 36    /// </summary>
 37    Everywhere = Definition | Route | Schedule
 38}
 39/// <summary>
 40/// Attribute to specify runtime API context and notes for Kestrun routes or schedules.
 41/// </summary>
 42/// <remarks>
 43/// Initializes a new instance of the <see cref="KestrunRuntimeApiAttribute"/> class with the specified API contexts.
 44/// </remarks>
 45/// <param name="contexts">The API contexts in which the route or schedule can be executed.</param>
 46[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = false, AllowMultiple = false)]
 147public sealed class KestrunRuntimeApiAttribute(KestrunApiContext contexts) : Attribute
 48{
 49    /// <summary>
 50    /// Gets the API contexts in which the route or schedule can be executed.
 51    /// </summary>
 352    public KestrunApiContext Contexts { get; } = contexts;
 53
 54    /// <summary>
 55    /// Indicates whether the route is safe to be executed by untrusted callers.
 56    /// </summary>
 257    public bool SafeForUntrusted { get; init; } // optional policy flag
 58    /// <summary>
 59    /// Optional notes or description for the route.
 60    /// </summary>
 261    public string? Notes { get; init; }
 62}
 63#pragma warning restore CA1050
 64