ARC0001: Incorrect query method signature on ReadModel
Query methods on types with [ReadModel] must return the ReadModel type, a collection, Task, IAsyncEnumerable, or ISubject of the ReadModel type.
Severity
Section titled “Severity”Error
Valid Return Types
Section titled “Valid Return Types”Query methods must return one of the following:
ReadModelIEnumerable<ReadModel>List<ReadModel>ReadModel[]Task<ReadModel>Task<IEnumerable<ReadModel>>IAsyncEnumerable<ReadModel>ISubject<ReadModel>ISubject<IEnumerable<ReadModel>>Example
Section titled “Example”Violation
Section titled “Violation”[ReadModel]public class User{ public Guid Id { get; set; } public string Name { get; set; }
// ARC0001: Invalid return type public static string GetName(Guid id) { return "name"; }}[ReadModel]public class User{ public Guid Id { get; set; } public string Name { get; set; }
public static User GetById(Guid id) => new();
public static IEnumerable<User> GetAll() => [];
public static Task<User> GetByIdAsync(Guid id) => Task.FromResult(new User());}Why This Rule Exists
Section titled “Why This Rule Exists”ReadModel query methods form the public query surface of a ReadModel. Standardized return types ensure:
- The runtime can recognize and execute queries consistently.
- Query results are predictable and can be composed with async patterns.
- Streaming and reactive query patterns are supported where appropriate.
Related Rules
Section titled “Related Rules”- ARC0002: Missing [Command] attribute on command-like type