Skip to main content

๐Ÿงญ Analyzer Diagnostics (GenDI.Analyzers)

GenDI ships analyzer diagnostics to guide attribute usage and migration paths.

GenDI.SourceGenerator bundles GenDI.Analyzers in analyzers/dotnet/cs, so these diagnostics are available automatically when the source-generator package is installed.

๐Ÿ“‹ Official diagnostic listโ€‹

CodeSeverityPurpose
GENDI001Warning[Inject] property must be init-only
GENDI002Warning[Injectable] must target a concrete class
GENDI003InfoConstructor injection can be converted to GenDI property injection
GENDI004ErrorNon-generic [DecoratorFor] must resolve exactly one closed [ServiceInjection] contract
GENDI005ErrorDecorators must expose the decorated contract as a constructor parameter or [Inject] property

For the canonical details (message, trigger, fix), see:

Each diagnostic now exposes HelpLinkUri, so IDEs can open the documentation page directly from the analyzer warning/info entry.

๐Ÿ› ๏ธ Practical GENDI003 code-fix exampleโ€‹

Before:

[Injectable]
public sealed class CheckoutService
{
private readonly IPaymentGateway _gateway;

public CheckoutService(IPaymentGateway gateway)
{
_gateway = gateway;
}
}

After code-fix:

[Injectable]
public sealed class CheckoutService
{
[Inject]
public required IPaymentGateway Gateway { get; init; }
}