-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.cursorrules
63 lines (60 loc) · 4.75 KB
/
.cursorrules
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
You are an expert AI code generator specializing in .NET 8 ASP.NET Blazor Server web applications using Radzen Blazor as the UI library. Your primary goal is to produce high-quality, efficient, and maintainable code that adheres to best practices and modern development standards.
- Always attempt to use existing Nuget packages before generating custom code.
- Generate concise, clean, and minimalistic code.
- Use meaningful and descriptive names for variables, methods, and classes.
- Use minimum Javascript and instead prefer .Net, C# for interactive functionality.
- Use .Net and C# for all server-side code, and for client-side code that must run on the browser.
- Generate detailed in-line code comments explaining the purpose and functionality of each code block.
- Use XML documentation comments for public APIs and important methods.
- Provide summary comments for classes and interfaces.
- When generating HTML, prioritize the use of built-in Radzen Blazor classes.
- Minimize custom CSS code; use it only when absolutely necessary.
- Store css rules in WhisperFyiWebApp/css/app.css and import them in the main layout page (App.razor).
- Generate comments explaining the purpose and effect of each Radzen Blazor class used.
- Ensure responsive design principles are applied consistently. The generated code must display correctly on all devices, including desktops, tablets, and mobile phones.
- Address nullability issues proactively; use nullable reference types and null checks appropriately.
- Implement proper input validation and data sanitization.
- Follow OWASP security guidelines for web applications.
- Use Clean Architecture principles to structure the codebase.
- Use MediatR package for all business logic, which should be encapsulated in handlers.
- Minimize the C# code inside Razor components, and instead add it to the appropriate handlers. When a UI component needs data or perform an action, fire a Mediator message instead of putting logic inside the component.
- Use MediatR Behaviors to handle cross-cutting concerns such as validation, caching, unhandled exception handling and logging.
- When using constructor injection, the readonly fields most not have an underscore prefix. For example, use "private readonly INlpService nlpService;" instead of "private readonly INlpService _nlpService;"
- In every Behavior class, add detailed documentation comments describing what the behavior is doing. Describe the difference between IRequestPreProcessor and IPipelineBehavior.
- When adding a new command or query, always add Response class and fluent validation rules in the same file as the command or query. Here is an example of what the class should look like:
```
public sealed record AskQuestionFromDocsQry : IRequest<AskQuestionFromDocsQryResult>
{
public string Question { get; set; }
public string Industry { get; set; }
public string Product { get; set; }
}
public sealed record AskQuestionFromDocsQryResult: BaseResponse
{
public string Answer { get; init; }
}
public sealed class AskQuestionFromDocsQryValidator : AbstractValidator<AskQuestionFromDocsQry>
{
public AskQuestionFromDocsQryValidator()
{
RuleFor(x => x.Question).NotEmpty().NotNull();
RuleFor(x => x.Industry).NotNull().NotEmpty();
RuleFor(x => x.Product).NotNull().NotEmpty();
}
}
```
- In Handler classes, import the relevant namespaces at the top of the file for all the classes, interfaces, services and records used in the file.
- For Data Transfer Objects (DTOs), always use record structs, and store them in the Common/DTOs folder.
- When generating record types, do not include the "init" keyword for the properties. Use {get; set;} instead of {get; init;}
- When adding a new command or query, always generate a series of tests for the new command or query in the WhisperFyiWebApp.Tests project.
- In the class names for queries and commands, Suffix the Query/Command with "Qry" or "Cmd" respectively. Use this same suffix for the handler classes.
- Use the IAppRequest interface for all requests, which ensures that all responses inherit from BaseResponse.
- For all result classes for all commands and queries, always inherit from BaseResponse.
- Implement lazy loading for components and resources when appropriate.
- Use asynchronous programming patterns for I/O-bound operations.
- Ensure generated code and UI components are accessible (WCAG compliant).
- Protect against common web vulnerabilities (XSS, CSRF, etc.).
- Always generate detailed comments in the code describing in detail what the code is doing.
- Match the code comments with the code, and keep the comments current with the code
- Use "@rendermode InteractiveServer" for all pages and components
- Put new Pages and Components in the Components/Pages folder