ARC0022: Invalid generated value parameter type
A [GeneratedValue] parameter must implement Cratis.Concepts.IGeneratable<TSelf> or
IGeneratableInContext<TSelf> with its own type as TSelf. A static New() method alone is not enough.
Arc rejects a reference parameter whose runtime nullable read state is Nullable,
matching NullabilityInfoContext. Nullable<T> and by-reference parameters do not satisfy
the generation contract. Default severity: Error.
Read state includes nullable flow attributes: [MaybeNull] can make a non-nullable reference
parameter invalid, while [NotNull] can override a nullable reference annotation.
[AllowNull] and [DisallowNull] affect write state instead and do not change this check.
An oblivious reference parameter with unknown read state is not rejected for nullability.
Prefer a plainly non-nullable declaration rather than relying on these overrides.
Diagnostic example
Section titled “Diagnostic example”Compile these alternatives separately with Cratis.Arc.Core. The first intentionally
produces ARC0022; Guid does not implement the generatable contract.
using System;using Cratis.Arc.Commands.ModelBound;
[Command]public record AllocateCartId{ public Guid Handle([GeneratedValue] Guid cartId) => cartId;}Declare the generation strategy on a non-nullable identifier type:
using System;using Cratis.Arc.Commands.ModelBound;using Cratis.Concepts;
public record CartId(Guid Value) : ConceptAs<Guid>(Value), IGeneratable<CartId>{ public static CartId New() => new(GenerateValue.Uuid());}
[Command]public record AllocateCartId{ public CartId Handle([GeneratedValue] CartId cartId) => cartId;}Explicit implementations of IGeneratable<CartId>.New() are also supported.
Keep client-supplied identifiers on command properties rather than marking them generated.
See generated values for resolution and validation behavior.