Skip to content

ARC0001: Incorrect query method signature on ReadModel

Reports public static non-void methods on [ReadModel] types whose return type is not the read model or an accepted wrapper. Default severity: Error. Move unrelated utility methods off the read model rather than exposing them as queries.

For read model T, the analyzer accepts:

  • T and T[]
  • IEnumerable<T> and types implementing it, including List<T> and IQueryable<T>
  • Task<T> and Task<C> where C is an accepted collection of T
  • IAsyncEnumerable<T>
  • ISubject<T> and ISubject<C> where C is an accepted collection of T

These are type shapes, not declarations to paste into a file. A nongeneric Task and ValueTask<T> are not accepted by this analyzer. For transport behavior, see query return types.

Compile each block separately with Cratis.Arc.Core. The first intentionally produces ARC0001; it is not a runnable application.

using System;
using Cratis.Arc.Queries.ModelBound;
[ReadModel]
public record User(Guid Id, string Name)
{
public static string GetName(Guid id) => "Ada";
}

Return the read model instead:

using System;
using Cratis.Arc.Queries.ModelBound;
[ReadModel]
public record User(Guid Id, string Name)
{
public static User GetById(Guid id) => new(id, "Ada");
}

This fixed declaration returns sample data; it does not demonstrate database persistence or host setup. Both declarations use records so ARC0008 does not distract from the return-type error.