< Summary

Information
Class: Trailblazer.Support.TransientAttribute
Assembly: Trailblazer
File(s): /home/runner/work/Trailblazer/Trailblazer/src/Trailblazer/Support/TransientState/TransientAttribute.cs
Line coverage
100%
Covered lines: 5
Uncovered lines: 0
Coverable lines: 5
Total lines: 45
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

Metrics

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

File(s)

/home/runner/work/Trailblazer/Trailblazer/src/Trailblazer/Support/TransientState/TransientAttribute.cs

#LineLine coverage
 1using System;
 2
 3namespace Trailblazer.Support;
 4
 5/// <summary>
 6/// Marks a property as transient, indicating that it holds frame-local state
 7/// that can be synchronized from another instance or cleared back to defaults.
 8/// </summary>
 9/// <remarks>
 10/// When a default value source and member are provided via the two-argument constructor,
 11/// <see cref="ITransient.ClearTransientState"/> resets the property to that static member's value
 12/// instead of <c>default(T)</c>. Useful for types whose zero-value is not a valid reset state
 13/// (e.g. identity matrices or quaternions).
 14/// </remarks>
 15[AttributeUsage(AttributeTargets.Property)]
 16public class TransientAttribute : Attribute
 17{
 18    /// <summary>
 19    /// Gets the type that declares the static member to use as the clear default, or <c>null</c>
 20    /// to use <c>default(T)</c>.
 21    /// </summary>
 22    public Type? DefaultValueSource { get; }
 23
 24    /// <summary>
 25    /// Gets the name of the static field or property on <see cref="DefaultValueSource"/> to use
 26    /// as the clear default, or <c>null</c> to use <c>default(T)</c>.
 27    /// </summary>
 28    public string? DefaultValueMember { get; }
 29
 30    /// <summary>
 31    /// Marks the property as transient and clears it to <c>default(T)</c> on reset.
 32    /// </summary>
 8033    public TransientAttribute() { }
 34
 35    /// <summary>
 36    /// Marks the property as transient and clears it to a specific static member value on reset.
 37    /// </summary>
 38    /// <param name="defaultValueSource">The type declaring the static default member.</param>
 39    /// <param name="defaultValueMember">The name of the static field or property to read.</param>
 440    public TransientAttribute(Type defaultValueSource, string defaultValueMember)
 41    {
 442        DefaultValueSource = defaultValueSource;
 443        DefaultValueMember = defaultValueMember;
 444    }
 45}