---
title: 'ARC0025: Provide supplies a generated value type'
editUrl: https://github.com/Cratis/Arc/edit/main/Documentation/backend/csharp/code-analysis/ARC0025.md
description: Remove a redundant Provide value that cannot override a generated Handle parameter.
---


## Rule

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.**

## Diagnostic example

The examples use this identifier, the same declaration as in
[generated values](/arc/backend/csharp/commands/generated-values/):

```csharp
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.

```csharp
[Command]
public record AllocateCartId
{
    public CartId Provide() => CartId.New();

    public CartId Handle([GeneratedValue] CartId cartId) => cartId;
}
```

## Fix

Remove the redundant provided value:

```csharp
[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.
