Skip to content

Conversation

@berkansasmaz
Copy link
Member

Resolves #7957

@berkansasmaz berkansasmaz added this to the 10.1-final milestone Jan 19, 2026
@berkansasmaz berkansasmaz requested a review from ebicoglu January 19, 2026 14:24
Copilot AI review requested due to automatic review settings January 19, 2026 14:24
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a comprehensive collection of AI development rules (in Cursor .mdc format) for ABP Framework projects. The rules provide AI assistants with ABP-specific context to help generate code that follows ABP conventions and best practices.

Changes:

  • Added 19 markdown rule files covering DDD patterns, application layer, UI frameworks, data access, testing, and template-specific guidance
  • Created organized folder structure (common, ui, data, testing, template-specific)
  • Included comprehensive README explaining the purpose, structure, and contribution guidelines

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 17 comments.

Show a summary per file
File Description
ai-rules/README.md Main documentation explaining the AI rules system, file structure, and contribution guidelines
ai-rules/common/abp-core.mdc Core ABP conventions including module system, DI, and base classes (always applied)
ai-rules/common/ddd-patterns.mdc DDD patterns for entities, aggregate roots, repositories, and domain services
ai-rules/common/application-layer.mdc Application service patterns, DTOs, validation, and error handling
ai-rules/common/authorization.mdc Permission system and authorization patterns
ai-rules/common/multi-tenancy.mdc Multi-tenant entities, data isolation, and tenant switching
ai-rules/common/infrastructure.mdc Settings, features, caching, events, and background jobs
ai-rules/common/dependency-rules.mdc Layer dependency rules and project structure guardrails
ai-rules/common/development-flow.mdc Complete workflow for adding new entities and features
ai-rules/common/cli-commands.mdc Reference for ABP CLI commands
ai-rules/ui/blazor.mdc Blazor UI component patterns and best practices
ai-rules/ui/angular.mdc Angular UI patterns including service proxies and components
ai-rules/ui/mvc.mdc MVC/Razor Pages patterns and ABP tag helpers
ai-rules/data/ef-core.mdc Entity Framework Core DbContext, migrations, and repositories
ai-rules/data/mongodb.mdc MongoDB patterns and repository implementations
ai-rules/testing/patterns.mdc Unit and integration testing patterns using xUnit and Shouldly
ai-rules/template-specific/app-nolayers.mdc Single-layer application template patterns
ai-rules/template-specific/module.mdc Reusable module development patterns with extensibility focus
ai-rules/template-specific/microservice.mdc Microservice template patterns including inter-service communication

Comment on lines +17 to +19
public DbSet<Book> Books { get; set; }
public DbSet<Author> Authors { get; set; }

Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment says "Not setters" for DbSet properties, but the code immediately below shows properties without setters. This is correct for EF Core, but the comment is confusing. Consider clarifying the comment to say "Aggregate roots only" or removing it entirely since the pattern is self-explanatory.

Copilot uses AI. Check for mistakes.

| Don't Use | Use Instead |
|-----------|-------------|
| Minimal APIs | ABP Controllers or Auto API Controllers |
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The guidance to "Never use Minimal APIs" contradicts modern ASP.NET Core best practices and may be too restrictive. ABP can work with Minimal APIs in certain scenarios. Consider softening this to "Prefer ABP Controllers or Auto API Controllers for consistency with ABP patterns" rather than a blanket prohibition.

Suggested change
| Minimal APIs | ABP Controllers or Auto API Controllers |
| Minimal APIs for core/business HTTP APIs | Prefer ABP Controllers or Auto API Controllers for consistency with ABP patterns (Minimal APIs are acceptable for limited scenarios, e.g. health checks or very simple endpoints). |

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,270 @@
---
description: "ABP testing patterns - unit tests and integration tests"
globs: "test/**/*.cs,tests/**/*.cs,**/*Tests*/**/*.cs,**/*Test*.cs"
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The glob pattern includes "/Test.cs" which will match files like "TestData.cs" or "TestConfiguration.cs" that are not test files. Consider using more specific patterns like "/*Tests.cs,**/*Test.cs" to avoid false positives.

Suggested change
globs: "test/**/*.cs,tests/**/*.cs,**/*Tests*/**/*.cs,**/*Test*.cs"
globs: "test/**/*.cs,tests/**/*.cs,**/*Tests*/**/*.cs,**/*Tests.cs,**/*Test.cs"

Copilot uses AI. Check for mistakes.
Comment on lines +17 to +19
public IMongoCollection<Book> Books => Collection<Book>();
public IMongoCollection<Author> Authors => Collection<Author>();

Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The example shows DbSet properties without setters, but the comment says "No setters, aggregate roots only". However, in EF Core, DbSet properties typically have both get and set. The pattern shown is valid for interface definitions but may be confusing for DbContext implementations. Consider clarifying that this is for the interface pattern specifically.

Copilot uses AI. Check for mistakes.
public string OrderNumber { get; private set; }
public Guid CustomerId { get; private set; }
public OrderStatus Status { get; private set; }
public ICollection<OrderLine> Lines { get; private set; }
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The property name "Lines" is misleading for a collection property. ABP and C# conventions typically use plural noun naming for collections without the "Collection" suffix, so "Lines" is actually correct and conventional. However, the code shows it as type ICollection which is less common - typically you'd see List or IReadOnlyCollection for better encapsulation. Consider showing it as public IReadOnlyCollection<OrderLine> Lines { get; private set; } or private readonly List<OrderLine> _lines = new(); public IReadOnlyCollection<OrderLine> Lines => _lines.AsReadOnly(); for better domain model encapsulation.

Copilot uses AI. Check for mistakes.
Comment on lines +175 to +180
private List<BookDto> Books { get; set; }

protected override async Task OnInitializedAsync()
{
var result = await BookAppService.GetListAsync(new PagedAndSortedResultRequestDto());
Books = result.Items.ToList();
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The example shows Books = result.Items.ToList(); where ToList() creates an unnecessary copy. The Items property already returns a collection, so this should be Books = result.Items; or the Books property type should match what Items returns.

Suggested change
private List<BookDto> Books { get; set; }
protected override async Task OnInitializedAsync()
{
var result = await BookAppService.GetListAsync(new PagedAndSortedResultRequestDto());
Books = result.Items.ToList();
private IReadOnlyList<BookDto> Books { get; set; }
protected override async Task OnInitializedAsync()
{
var result = await BookAppService.GetListAsync(new PagedAndSortedResultRequestDto());
Books = result.Items;

Copilot uses AI. Check for mistakes.

public Book(Guid id, string name, decimal price, Guid authorId) : base(id)
{
Name = Check.NotNullOrWhiteSpace(name, nameof(name));
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The example uses Check.NotNullOrWhiteSpace(name, nameof(name)) as a return value, but the Check class validation methods are void and throw exceptions on failure. The correct pattern is to either use Check as a statement (not assigned) or use it within the property assignment. This code will not compile.

Copilot uses AI. Check for mistakes.

**Books.razor.cs:**
```csharp
public partial class Books : BooksBase
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code example shows a partial class named "Books" inheriting from "BooksBase", but the file structure suggests this should be "BooksPage" or similar to avoid naming conflicts. Having a component class and base class both named "Books" (one partial) can be confusing. Consider using a clearer naming pattern like "BooksPage : BooksBase" or showing this as an abstract example.

Copilot uses AI. Check for mistakes.

This folder serves as a central repository for ABP-specific AI rules. The community can contribute, improve, and maintain these rules collaboratively.

When you create a new ABP solution, these rules are included in your project based on your configuration. This provides AI assistants with ABP-specific context, helping them generate code that follows ABP conventions.
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The README states these rules are included "based on your configuration" when creating a new ABP solution, but it's unclear what configuration options control which rules are included. Consider adding clarification about how developers can customize which rules are included in their projects, or if this is automatic based on template selection.

Suggested change
When you create a new ABP solution, these rules are included in your project based on your configuration. This provides AI assistants with ABP-specific context, helping them generate code that follows ABP conventions.
When you create a new ABP solution (for example, using the ABP CLI or ABP Suite), the `ai-rules` folder and a subset of these rule files are included in your project automatically. The exact set of rules that is copied depends on the template and options you choose (e.g., app vs. module vs. microservice, selected UI framework, data provider, etc.). You can further customize which rules are used by adding or removing `.mdc` files in your solution, or by adjusting their frontmatter (such as `alwaysApply` or `glob`) to control when they are applied. This provides AI assistants with ABP-specific context, helping them generate code that follows ABP conventions.

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,143 @@
# ABP AI Rules
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description says "Resolves #7957" but issue #7957 is about Docker deployment documentation, not AI development rules. This appears to be referencing the wrong issue. Please verify the correct issue number or remove the issue reference if this is a standalone contribution.

Copilot uses AI. Check for mistakes.
@ebicoglu ebicoglu merged commit fad7e8d into rel-10.1 Jan 20, 2026
2 checks passed
@ebicoglu ebicoglu deleted the berkan/ai-rules branch January 20, 2026 11:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants