Open sandboxFocus

Struct DurableDangerous<T>

Wraps a value that is asserted to be durable, that is, safe to be held across compilations, without the assertion being verified. The analyzer treats this type as durable whatever T is.

Implements
Namespace: Metalama.Framework.Utilities
Assembly: Metalama.Framework.dll
Syntax
public readonly struct DurableDangerous<T> : IEquatable<DurableDangerous<T>>
Type Parameters
Name Description
T

The type of the wrapped value.

Remarks

This is the escape hatch for a member whose durability holds in fact but cannot be established from its declared type, most commonly because the type comes from an assembly that cannot be annotated. The assertion is the responsibility of whoever writes it.

The Dangerous suffix follows the convention used elsewhere in this codebase for a value whose safety the reader must establish rather than assume. Prefer this wrapper over a diagnostic suppression, because it appears in the signature of the member, survives refactoring and can be found by a search for the type name.

Prefer, in order: making the member genuinely durable, for example by storing a SerializableDeclarationId or an IDurableRef<T>; applying DurableAttribute to the member so that its assignments are verified; and only then this wrapper.

Constructors

Name Description
DurableDangerous(T)

Initializes a new instance of the DurableDangerous<T> struct.

Properties

Name Description
Value

Gets the wrapped value.

Methods

Name Description
Equals(DurableDangerous<T>)
Equals(object?)
GetHashCode()
ToString()

Operators

Name Description
operator ==(DurableDangerous<T>, DurableDangerous<T>)

Determines whether two wrappers hold equal values.

implicit operator T(DurableDangerous<T>)

Unwraps the value.

implicit operator DurableDangerous<T>(T)

Wraps a value, asserting that it is durable.

operator !=(DurableDangerous<T>, DurableDangerous<T>)

Determines whether two wrappers hold values that are not equal.