Browse pages
LS2007: Reaction or Job Name Hides Its Kind
LS2007 is a compiler check that reports a reaction, the type that answers a domain event, or a scheduled job whose name does not say which of the two it is, so the model builder cannot discover it by name. This page states what the rule reports, where the error sits, and how to name the reaction or job for its kind.
Reference#
What the Rule Enforces#
LS2007 enforces Use architectural suffixes (litespec/workspace/naming#use-architectural-suffixes). It runs in Application and Infrastructure. Its category is LiteSpec.Layers. It reports an error and is enabled by default, as the Analyzers overview describes.
What the Rule Reports#
The rule reports a class that implements an interface named IEventHandler or IDomainEventReaction unless its name ends in Reaction or matches {Action}On{PastFact}Handler, with an action before On and a fact between On and Handler. The rule reports a class that derives from BackgroundService or implements IHostedService unless its name ends in Job or Worker, or contains Recurring. The diagnostic sits on the type name, and its message names the kind and the accepted shape.
Failing Example#
internal sealed class SubscriberNotifier : IEventHandler<OrderPlacedEvent>
{
}
internal sealed class ReminderLoop : BackgroundService
{
}Passing Example#
internal sealed class NotifySubscribersOnOrderPlacedHandler : IEventHandler<OrderPlacedEvent>
{
}
internal sealed class ReminderJob : BackgroundService
{
}How to Fix#
Name a reaction {Action}On{PastFact}Handler or end it in Reaction, and name a job to end in Job or Worker, or to contain Recurring.
Notes#
What the Rule Ignores#
The rule does not report a class that is neither a reaction nor a job, and it does not report interfaces. A class that is both a reaction and a job is checked against both shapes. It does not run in Domain, Application.Abstractions, or WebApi.