Skip to content

Diagnostics

Compiler diagnostics emitted by DesignPatterns source generators and analyzers. IDs are defined in DesignPatterns.Diagnostics.DiagnosticIds.

Help links in the IDE point to this page (#dp### anchors).

Singleton (DP001–DP002)

IDSeverityWhen
DP001Error[GenerateSingleton] target is not partial
DP002ErrorInvalid singleton target (must be sealed class with parameterless ctor)

Strategy (DP003–DP007)

IDSeverityWhen
DP003ErrorDuplicate strategy key
DP004ErrorImplementation does not match strategy contract
DP005(reserved / handler overlap — see DP005 under Chain)
DP006InfoImplementation type not registered with [RegisterStrategy]
DP007ErrorStrategy implementation missing parameterless constructor

Chain of Responsibility (DP005, DP008–DP009, DP024)

IDSeverityWhen
DP005ErrorDuplicate [HandlerOrder] value
DP008ErrorHandler does not implement the pipeline contract
DP009ErrorHandler missing parameterless constructor
DP024InfoHandler type not registered with [HandlerOrder]

Composite (DP010–DP015)

IDSeverityWhen
DP010ErrorDuplicate composite part key
DP011ErrorUnknown parent key
DP012ErrorCycle in composite tree
DP013ErrorPart does not match node contract
DP014ErrorPart missing parameterless constructor
DP015ErrorRegistry holder missing [CompositeBuildable]

Decorator (DP016–DP019)

IDSeverityWhen
DP016ErrorDuplicate decorator order
DP017ErrorDecorator does not match contract
DP018ErrorType does not implement IDecorator<T>
DP019ErrorDecorator missing parameterless constructor

Factory Registry (DP020–DP023)

IDSeverityWhen
DP020ErrorDuplicate factory key
DP021ErrorFactory does not match product contract
DP022ErrorFactory missing parameterless constructor
DP023InfoProduct type not registered with [RegisterFactory]

Registry key (DP025)

IDSeverityWhen
DP025InfoString literal key passed to a generated Strategy or Factory registry lookup is not among registered keys

Where it applies: Get / TryGet / Create / TryCreate on IStrategyRegistry<,> / IFactoryRegistry<,> when the key argument is a string literal (not a {Contract}Keys constant).

Message: includes the contract type and the list of registered keys.

Fix: prefer {Contract}Keys.* constants. The CorrectRegistryKey CodeFix suggests the closest registered key when the typo is near a known key.

See also Registry key conventions.

Plugin assemblies (DP033)

IDSeverityWhen
DP033ErrorThe same strategy key for the same contract is registered in more than one referenced provider assembly

Where it applies: host (or any) compilations that reference multiple plugin provider assemblies contributing [RegisterStrategy] / [RegisterStrategy<TContract>] for the same contract with an identical key string.

Message: includes the key, contract type, and conflicting assembly names.

Fix: use distinct keys per provider assembly, or reference only one provider per contract dimension. Duplicate keys within a single assembly remain DP003 (generator).

See Plugin assemblies sample and the main repo PluginAssemblies.md.

State transition table (DP026–DP031)

IDSeverityWhen
DP026ErrorDuplicate (from state, trigger) edge
DP027Error[Transition] state value is not a declared enum member
DP028Error[Transition] trigger value is not a declared enum member
DP029Error[StateMachine] Initial is not a declared state enum member
DP030ErrorHolder class is not static partial
DP031InfoState enum member never appears as a [Transition] source (terminal/reserved hint)

See State transition table.

Code fixes

DesignPatterns.CodeFixes ships inside the Skymly.DesignPatterns meta package (analyzers/dotnet/cs). Selected diagnostics offer one-click fixes in the IDE (requires C# Workspaces):

DiagnosticCode fix (summary)
DP006Add [RegisterStrategy("key", typeof(TContract))]
DP023Add [RegisterFactory("key", typeof(TContract))]
DP024Add [HandlerOrder(order, typeof(TContext))]
DP025Replace literal with nearest registered key
DP001Add partial modifier
DP015Add [CompositeBuildable]
DP004 / DP013 / DP017 / DP021Add contract implementation
DP007 / DP009 / DP014 / DP019 / DP022Add parameterless constructor

Generator errors (DP001–DP005, DP007–DP022) are fixed by correcting attributes or types; no CodeFix is provided for duplicate-key errors.

Category prefix: DesignPatterns.

Released under the MIT License.