Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,15 @@ dotnet test DesignPatterns.slnx -c Release
| DP060 | DI captive dependency(Analyzer;`RegisterDi` registryLifetime > implementationLifetime 警告) |
| DP061 | DI lifetime wasteful(Analyzer;`RegisterDi` implementationLifetime > registryLifetime 提示) |
| DP062 | Singleton captive dependency(Analyzer;Singleton 实现构造函数依赖 Scoped/Transient 服务) |
| DP063 | Composite tree max depth exceeded(生成器;`[CompositeSchema(MaxDepth)]` 约束被超过 Warning) |
| DP064 | Composite child type not allowed(生成器;子节点实现类型不在父节点 `AllowedChildTypes` 集合中 Error) |
| DP065 | Composite node count exceeded(生成器;`[CompositeSchema(MaxNodes)]` 约束被超过 Warning) |

常量:[`DesignPatterns.Diagnostics/DiagnosticIds.cs`](DesignPatterns.Diagnostics/DiagnosticIds.cs)。规则表:[`DesignPatterns.SourceGenerators/AnalyzerReleases.Unshipped.md`](DesignPatterns.SourceGenerators/AnalyzerReleases.Unshipped.md)。

诊断 ID 规范(**本表为唯一登记源**,其他文档不得另立分类):

- 下一个可用 ID:**DP063**;ID 一经发布不复用、不改语义。
- 下一个可用 ID:**DP066**;ID 一经发布不复用、不改语义。
- 新增 / 修改诊断必须同步 [`DiagnosticIds.cs`](DesignPatterns.Diagnostics/DiagnosticIds.cs)、[`DesignPatternsDiagnosticDescriptors.cs`](DesignPatterns.Diagnostics/DesignPatternsDiagnosticDescriptors.cs)(经 Compile Link 编入 SourceGenerators / Analyzers)与 [`AnalyzerReleases.Unshipped.md`](DesignPatterns.SourceGenerators/AnalyzerReleases.Unshipped.md)。
- 归属:DP006 / DP023 / DP024 / DP025 / DP033 / DP036 / DP044 / DP060 / DP061 / DP062 属 **Analyzer**;其余属**生成器**。
- 文案:`messageFormat` 须含可操作建议;`description` 供 IDE 悬停;`helpLinkUri` 指向 [`DesignPatterns.Docs` diagnostics 页](https://skymly.github.io/DesignPatterns.Docs/diagnostics)(`#dp###` 片段,见 [`DiagnosticHelpLinks.cs`](DesignPatterns.Diagnostics/DiagnosticHelpLinks.cs))。
Expand Down
26 changes: 26 additions & 0 deletions DesignPatterns.Diagnostics/DesignPatternsDiagnosticDescriptors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,32 @@ public static class DesignPatternsDiagnosticDescriptors
DiagnosticSeverity.Warning,
AnalyzerCategory);

// Composite tree schema validation (DP063–DP065)

public static DiagnosticDescriptor CompositeTreeMaxDepthExceeded { get; } = Create(
DiagnosticIds.CompositeTreeMaxDepthExceeded,
"Composite tree max depth exceeded",
"Composite tree for contract '{0}' has depth {1}, exceeding the maximum depth of {2} declared by [CompositeSchema]. Consider flattening the tree structure or increasing MaxDepth.",
"Excessively deep composite trees can cause stack overflows in recursive traversal. Review the tree structure or adjust the MaxDepth constraint.",
DiagnosticSeverity.Warning,
GeneratorCategory);

public static DiagnosticDescriptor CompositeChildTypeNotAllowed { get; } = Create(
DiagnosticIds.CompositeChildTypeNotAllowed,
"Composite child type not allowed by parent",
"Composite part '{0}' (type '{1}') is not in the AllowedChildTypes of its parent '{2}' (type '{3}'). Add '{1}' to the parent's AllowedChildTypes or change the ParentKey to a compatible parent.",
"Parent-child type compatibility is enforced at compile time when AllowedChildTypes is specified. Ensure child implementation types are declared in the parent's AllowedChildTypes array.",
DiagnosticSeverity.Error,
GeneratorCategory);

public static DiagnosticDescriptor CompositeNodeCountExceeded { get; } = Create(
DiagnosticIds.CompositeNodeCountExceeded,
"Composite node count exceeds limit",
"Composite contract '{0}' has {1} parts, exceeding the maximum of {2} declared by [CompositeSchema]. Consider splitting into multiple contracts or increasing MaxNodes.",
"Excessive node counts may indicate architectural issues or cause performance problems in tree assembly and traversal.",
DiagnosticSeverity.Warning,
GeneratorCategory);

public static DiagnosticDescriptor RegistryKeyNotRegistered { get; } = Create(
DiagnosticIds.RegistryKeyNotRegistered,
"Registry key is not registered",
Expand Down
3 changes: 3 additions & 0 deletions DesignPatterns.Diagnostics/DiagnosticIds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,7 @@ public static class DiagnosticIds
public const string DiLifetimeCaptiveDependency = "DP060";
public const string DiLifetimeWasteful = "DP061";
public const string CaptiveDependency = "DP062";
public const string CompositeTreeMaxDepthExceeded = "DP063";
public const string CompositeChildTypeNotAllowed = "DP064";
public const string CompositeNodeCountExceeded = "DP065";
}
3 changes: 3 additions & 0 deletions DesignPatterns.SourceGenerators/AnalyzerReleases.Unshipped.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,6 @@ DP059 | DesignPatterns.Generators | Info | StateParent parent has no chil
DP060 | DesignPatterns.Analyzers | Warning | DI captive dependency: registry lifetime exceeds implementation lifetime
DP061 | DesignPatterns.Analyzers | Info | DI lifetime mismatch: implementation lifetime exceeds registry lifetime
DP062 | DesignPatterns.Analyzers | Warning | Singleton captive dependency on Scoped/Transient service
DP063 | DesignPatterns.Generators | Warning | Composite tree max depth exceeded
DP064 | DesignPatterns.Generators | Error | Composite child type not allowed by parent AllowedChildTypes
DP065 | DesignPatterns.Generators | Warning | Composite node count exceeds MaxNodes limit
Loading
Loading