跳到正文
Skillpedia
通用编程40k · #7178

dotnet-design-pattern-review

它能做什么

这个工具会检查你的 C#/.NET 代码,看看你是否正确使用了常见的设计模式,例如命令模式(Command Pattern)或工厂模式(Factory Pattern)。它还会给出改进代码结构的建议,让代码更有条理,也更容易维护。

适用场景

  • ✓当你想知道自己在代码中是否用好了设计模式时。
  • ✓当你需要更好地组织一个 C#/.NET 项目时。
  • ✓当你想确保代码遵循编程最佳实践时。

技能链接

https://github.com/github/awesome-copilot/blob/main/skills/dotnet-design-pattern-review/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/github/awesome-copilot/blob/main/skills/dotnet-design-pattern-review/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请检查我的 C# 代码中的命令模式和工厂模式。”

每周 5 个新技能,1 分钟读完。

工作原理

你把想要分析的代码片段粘贴进来。工具会读取代码,将其与设计模式规则和最佳实践进行比对,然后告诉你哪些地方做得好,哪些地方还可以改进。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

.NET/C# Design Pattern Review

Review the C#/.NET code in ${selection} for design pattern implementation and suggest improvements for the solution/project. Do not make any changes to the code, just provide a review.

Required Design Patterns

  • Command Pattern: Generic base classes (CommandHandler<TOptions>), ICommandHandler<TOptions> interface, CommandHandlerOptions inheritance, static SetupCommand(IHost host) methods
  • Factory Pattern: Complex object creation service provider integration
  • Dependency Injection: Primary constructor syntax, ArgumentNullException null checks, interface abstractions, proper service lifetimes
  • Repository Pattern: Async data access interfaces provider abstractions for connections
  • Provider Pattern: External service abstractions (database, AI), clear contracts, configuration handling
  • Resource Pattern: ResourceManager for localized messages, separate .resx files (LogMessages, ErrorMessages)

Review Checklist

  • Design Patterns: Identify patterns used. Are Command Handler, Factory, Provider, and Repository patterns correctly implemented? Missing beneficial patterns?
  • Architecture: Follow namespace conventions ({Core|Console|App|Service}.{Feature})? Proper separation between Core/Console projects? Modular and readable?
  • .NET Best Practices: Primary constructors, async/await with Task returns, ResourceManager usage, structured logging, strongly-typed configuration?
  • GoF Patterns: Command, Factory, Template Method, Strategy patterns correctly implemented?
  • SOLID Principles: Single Responsibility, Open/Closed, Liskov Substitution, Interface Segregation, Dependency Inversion violations?
  • Performance: Proper async/await, resource disposal, ConfigureAwait(false), parallel processing opportunities?
  • Maintainability: Clear separation of concerns, consistent error handling, proper configuration usage?
  • Testability: Dependencies abstracted via interfaces, mockable components, async testability, AAA pattern compatibility?
  • Security: Input validation, secure credential handling, parameterized queries, safe exception handling?
  • Documentation: XML docs for public APIs, parameter/return descriptions, resource file organization?
  • Code Clarity: Meaningful names reflecting domain concepts, clear intent through patterns, self-explanatory structure?
  • Clean Code: Consistent style, appropriate method/class size, minimal complexity, eliminated duplication?

Improvement Focus Areas

  • Command Handlers: Validation in base class, consistent error handling, proper resource management
  • Factories: Dependency configuration, service provider integration, disposal patterns
  • Providers: Connection management, async patterns, exception handling and logging
  • Configuration: Data annotations, validation attributes, secure sensitive value handling
  • AI/ML Integration: Semantic Kernel patterns, structured output handling, model configuration

Provide specific, actionable recommendations for improvements aligned with the project's architecture and .NET best practices.

常见问题

它会检查哪些设计模式?

它会检查命令模式、工厂模式、依赖注入、仓储模式(Repository)、提供程序模式(Provider)和资源模式(Resource)等,同时也会检查 SOLID 等原则以及通用的 .NET 最佳实践。

它会修改我的代码吗?

不会。它只负责分析并提出改进建议,是否采纳以及如何采纳由你决定。

我需要很懂编程才能用吗?

不需要。这个工具的设计思路是保持简单,即使你是新手,也能借助它了解自己的代码结构是否合理。

详情

作者的原始描述

Review the C#/.NET code for design pattern implementation and suggest improvements.

repo: github/awesome-copilot

热度

GitHub 星标
40k
排名
#7178
许可证
MIT
更新时间
2026/10/15

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能