Skip to content

ARC0025: Provide supplies a generated value type

Arc resolves [GeneratedValue] parameters before matching values from Provide(). A compatible provided value never supplies that generated parameter. The analyzer matches the command’s effective Handle() and Provide() methods, including inherited handlers and public or non-public instance providers. A provider hidden by a more-derived provider is not used. A nullable struct provider returning T? can supply T: a non-null value is boxed as T, while a null value supplies nothing. It unwraps Task<T>, ValueTask<T>, and OneOf alternatives, and flattens one tuple level, matching runtime resolution. Nested tuple elements and tasks inside a tuple are not flattened or awaited. Default severity: Warning.

The examples use this identifier, the same declaration as in generated values:

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());
}

Compile each alternative below together with it, one at a time; the first intentionally produces ARC0025.

[Command]
public record AllocateCartId
{
public CartId Provide() => CartId.New();
public CartId Handle([GeneratedValue] CartId cartId) => cartId;
}

Remove the redundant provided value:

[Command]
public record AllocateCartId
{
public CartId Handle([GeneratedValue] CartId cartId) => cartId;
}

If Provide() should own the value instead, remove [GeneratedValue] from the parameter. Other unmarked Handle() parameters can still consume a provided value of the same type. The warning does not mean that every value of that type returned by Provide() is unused; review those parameters before removing it.