< Summary

Information
Class: NexusLabs.Needlr.Analyzers.DiagnosticDescriptors
Assembly: NexusLabs.Needlr.Analyzers
File(s): /home/runner/work/needlr/needlr/src/NexusLabs.Needlr.Analyzers/DiagnosticDescriptors.cs
Line coverage
100%
Covered lines: 121
Uncovered lines: 0
Coverable lines: 121
Total lines: 185
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.cctor()100%11100%

File(s)

/home/runner/work/needlr/needlr/src/NexusLabs.Needlr.Analyzers/DiagnosticDescriptors.cs

#LineLine coverage
 1using Microsoft.CodeAnalysis;
 2
 3namespace NexusLabs.Needlr.Analyzers;
 4
 5/// <summary>
 6/// Contains diagnostic descriptors for all Needlr analyzers.
 7/// </summary>
 8public static class DiagnosticDescriptors
 9{
 10    private const string Category = "NexusLabs.Needlr";
 11    private const string HelpLinkBase = "https://github.com/nexus-labs/needlr/blob/main/docs/analyzers/";
 12
 13    /// <summary>
 14    /// NDLRCOR001: Reflection API used in AOT project.
 15    /// </summary>
 116    public static readonly DiagnosticDescriptor ReflectionInAotProject = new(
 117        id: DiagnosticIds.ReflectionInAotProject,
 118        title: "Reflection API used in AOT project",
 119        messageFormat: "'{0}' uses reflection and is not compatible with AOT/trimming. Use source-generated alternatives
 120        category: Category,
 121        defaultSeverity: DiagnosticSeverity.Error,
 122        isEnabledByDefault: true,
 123        description: "Reflection-based Needlr APIs cannot be used in projects with PublishAot or IsAotCompatible enabled
 124        helpLinkUri: HelpLinkBase + "NDLRCOR001.md");
 25
 26    /// <summary>
 27    /// NDLRCOR002: Plugin has constructor dependencies.
 28    /// </summary>
 129    public static readonly DiagnosticDescriptor PluginHasConstructorDependencies = new(
 130        id: DiagnosticIds.PluginHasConstructorDependencies,
 131        title: "Plugin has constructor dependencies",
 132        messageFormat: "Plugin '{0}' has constructor parameters but is instantiated before DI is available. Use a parame
 133        category: Category,
 134        defaultSeverity: DiagnosticSeverity.Warning,
 135        isEnabledByDefault: true,
 136        description: "IServiceCollectionPlugin and IPostBuildServiceCollectionPlugin implementations are instantiated be
 137        helpLinkUri: HelpLinkBase + "NDLRCOR002.md");
 38
 39    /// <summary>
 40    /// NDLRCOR003: DeferToContainer attribute in generated code.
 41    /// </summary>
 142    public static readonly DiagnosticDescriptor DeferToContainerInGeneratedCode = new(
 143        id: DiagnosticIds.DeferToContainerInGeneratedCode,
 144        title: "[DeferToContainer] attribute in generated code is ignored",
 145        messageFormat: "[DeferToContainer] on '{0}' is in generated code and will be ignored by Needlr. Move the attribu
 146        category: Category,
 147        defaultSeverity: DiagnosticSeverity.Error,
 148        isEnabledByDefault: true,
 149        description: "Source generators run in isolation and cannot see attributes added by other generators. The [Defer
 150        helpLinkUri: HelpLinkBase + "NDLRCOR003.md");
 51
 52    /// <summary>
 53    /// NDLRCOR004: Injectable type in global namespace may not be discovered.
 54    /// </summary>
 155    public static readonly DiagnosticDescriptor GlobalNamespaceTypeNotDiscovered = new(
 156        id: DiagnosticIds.GlobalNamespaceTypeNotDiscovered,
 157        title: "Injectable type in global namespace may not be discovered",
 158        messageFormat: "Type '{0}' is in the global namespace and won't be discovered when IncludeNamespacePrefixes is s
 159        category: Category,
 160        defaultSeverity: DiagnosticSeverity.Warning,
 161        isEnabledByDefault: true,
 162        description: "Types in the global namespace are not matched by namespace prefix filters. Either move the type to
 163        helpLinkUri: HelpLinkBase + "NDLRCOR004.md");
 64
 65    /// <summary>
 66    /// NDLRCOR005: Lifetime mismatch - longer-lived service depends on shorter-lived service.
 67    /// </summary>
 168    public static readonly DiagnosticDescriptor LifetimeMismatch = new(
 169        id: DiagnosticIds.LifetimeMismatch,
 170        title: "Lifetime mismatch: longer-lived service depends on shorter-lived service",
 171        messageFormat: "'{0}' is registered as {1} but depends on '{2}' which is registered as {3}. This causes a captiv
 172        category: Category,
 173        defaultSeverity: DiagnosticSeverity.Warning,
 174        isEnabledByDefault: true,
 175        description: "A longer-lived service (e.g., Singleton) depending on a shorter-lived service (e.g., Scoped or Tra
 176        helpLinkUri: HelpLinkBase + "NDLRCOR005.md");
 77
 78    /// <summary>
 79    /// NDLRCOR006: Circular dependency detected in service registration.
 80    /// </summary>
 181    public static readonly DiagnosticDescriptor CircularDependency = new(
 182        id: DiagnosticIds.CircularDependency,
 183        title: "Circular dependency detected",
 184        messageFormat: "Circular dependency detected: {0}. This will cause a runtime exception when resolving the servic
 185        category: Category,
 186        defaultSeverity: DiagnosticSeverity.Error,
 187        isEnabledByDefault: true,
 188        description: "A circular dependency occurs when a service directly or indirectly depends on itself. This will ca
 189        helpLinkUri: HelpLinkBase + "NDLRCOR006.md",
 190        customTags: WellKnownDiagnosticTags.CompilationEnd);
 91
 92    /// <summary>
 93    /// NDLRCOR007: Intercept attribute type must implement IMethodInterceptor.
 94    /// </summary>
 195    public static readonly DiagnosticDescriptor InterceptTypeMustImplementInterface = new(
 196        id: DiagnosticIds.InterceptTypeMustImplementInterface,
 197        title: "Intercept type must implement IMethodInterceptor",
 198        messageFormat: "Type '{0}' used in [Intercept] attribute does not implement IMethodInterceptor",
 199        category: Category,
 1100        defaultSeverity: DiagnosticSeverity.Error,
 1101        isEnabledByDefault: true,
 1102        description: "The type specified in an [Intercept] or [Intercept<T>] attribute must implement IMethodInterceptor
 1103        helpLinkUri: HelpLinkBase + "NDLRCOR007.md");
 104
 105    /// <summary>
 106    /// NDLRCOR008: [Intercept] applied to class without interfaces.
 107    /// </summary>
 1108    public static readonly DiagnosticDescriptor InterceptOnClassWithoutInterfaces = new(
 1109        id: DiagnosticIds.InterceptOnClassWithoutInterfaces,
 1110        title: "[Intercept] applied to class without interfaces",
 1111        messageFormat: "Class '{0}' has [Intercept] attribute but does not implement any interfaces. Interceptors requir
 1112        category: Category,
 1113        defaultSeverity: DiagnosticSeverity.Warning,
 1114        isEnabledByDefault: true,
 1115        description: "Interceptors work by generating a proxy class that implements the service's interfaces. If the cla
 1116        helpLinkUri: HelpLinkBase + "NDLRCOR008.md");
 117
 118    /// <summary>
 119    /// NDLRCOR009: Lazy&lt;T&gt; references type not discovered by source generation.
 120    /// </summary>
 1121    public static readonly DiagnosticDescriptor LazyResolutionUnknown = new(
 1122        id: DiagnosticIds.LazyResolutionUnknown,
 1123        title: "Lazy<T> references undiscovered type",
 1124        messageFormat: "Type '{0}' in Lazy<{0}> was not discovered by source generation. If registered via reflection, t
 1125        category: Category,
 1126        defaultSeverity: DiagnosticSeverity.Info,
 1127        isEnabledByDefault: true,
 1128        description: "The type parameter in Lazy<T> was not found in the source-generated type registry. This may indica
 1129        helpLinkUri: HelpLinkBase + "NDLRCOR009.md",
 1130        customTags: WellKnownDiagnosticTags.CompilationEnd);
 131
 132    /// <summary>
 133    /// NDLRCOR010: IEnumerable&lt;T&gt; has no implementations discovered.
 134    /// </summary>
 1135    public static readonly DiagnosticDescriptor CollectionResolutionEmpty = new(
 1136        id: DiagnosticIds.CollectionResolutionEmpty,
 1137        title: "IEnumerable<T> has no discovered implementations",
 1138        messageFormat: "No implementations of '{0}' were discovered by source generation. The collection will be empty u
 1139        category: Category,
 1140        defaultSeverity: DiagnosticSeverity.Info,
 1141        isEnabledByDefault: true,
 1142        description: "No types implementing the interface were found in the source-generated type registry. This may ind
 1143        helpLinkUri: HelpLinkBase + "NDLRCOR010.md",
 1144        customTags: WellKnownDiagnosticTags.CompilationEnd);
 145
 146    /// <summary>
 147    /// NDLRCOR011: [FromKeyedServices] references a key with no known registration.
 148    /// </summary>
 1149    public static readonly DiagnosticDescriptor KeyedServiceUnknownKey = new(
 1150        id: DiagnosticIds.KeyedServiceUnknownKey,
 1151        title: "[FromKeyedServices] references unknown key",
 1152        messageFormat: "Keyed service '{0}' with key \"{1}\" has no known registration. If registered via plugin or refl
 1153        category: Category,
 1154        defaultSeverity: DiagnosticSeverity.Info,
 1155        isEnabledByDefault: true,
 1156        description: "The keyed service reference was not found in source-generated registrations. Keyed services are ty
 1157        helpLinkUri: HelpLinkBase + "NDLRCOR011.md",
 1158        customTags: WellKnownDiagnosticTags.CompilationEnd);
 159
 160    /// <summary>
 161    /// NDLRCOR015: [RegisterAs&lt;T&gt;] type argument must be an interface implemented by the class.
 162    /// </summary>
 1163    public static readonly DiagnosticDescriptor RegisterAsTypeArgNotImplemented = new(
 1164        id: DiagnosticIds.RegisterAsTypeArgNotImplemented,
 1165        title: "[RegisterAs<T>] type argument not implemented",
 1166        messageFormat: "Type '{0}' has [RegisterAs<{1}>] but does not implement '{1}'. The type argument must be an inte
 1167        category: Category,
 1168        defaultSeverity: DiagnosticSeverity.Error,
 1169        isEnabledByDefault: true,
 1170        description: "When using [RegisterAs<T>], T must be an interface that the decorated class implements. The class 
 1171        helpLinkUri: HelpLinkBase + "NDLRCOR015.md");
 172
 173    /// <summary>
 174    /// NDLRCOR012: Disposable captive dependency - longer-lived service holds IDisposable with shorter lifetime.
 175    /// </summary>
 1176    public static readonly DiagnosticDescriptor DisposableCaptiveDependency = new(
 1177        id: DiagnosticIds.DisposableCaptiveDependency,
 1178        title: "Disposable captive dependency",
 1179        messageFormat: "'{0}' ({1}) depends on '{2}' ({3}) which implements {4}. The disposable will be disposed when it
 1180        category: Category,
 1181        defaultSeverity: DiagnosticSeverity.Error,
 1182        isEnabledByDefault: true,
 1183        description: "A longer-lived service holds a reference to a shorter-lived IDisposable/IAsyncDisposable. When the
 1184        helpLinkUri: HelpLinkBase + "NDLRCOR012.md");
 185}

Methods/Properties

.cctor()