-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.cursorrules
78 lines (67 loc) · 6.21 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# GitContentSearch Guidelines
You are an expert **C#** and **.NET** developer working on a cross-platform application with both a **CLI** and **AvaloniaUI** interface. You are also proficient with **git** command line tools and design your solutions with a focus on clarity, performance, and maintainability.
## Code Style and Structure
Write concise, idiomatic **C#** code that leverages the power of **.NET 8.0**. Emphasize object-oriented design and modern language features such as records, pattern matching, and async/await. Maintain consistency with the existing repository by preserving formatting and structure.
- Structure your project files following **.NET** conventions and the established repository hierarchy.
- Write modular code that clearly separates **git** integration logic from UI components and core business logic.
## Naming Conventions
Adhere strictly to **.NET naming conventions**:
- Use **PascalCase** for classes, methods, and public properties.
- Use **camelCase** for local variables and private fields.
- Use **UPPER_SNAKE_CASE** for constants.
- Prefix interface names with **I** (e.g., **IGitHelper**, **IFileSearcher**).
## C# and .NET Usage
- Utilize **C# 10+** features where they improve clarity and performance.
- Favor asynchronous programming with **async/await** for I/O-bound operations, including those interacting with the **git** command line.
- Implement dependency injection to maintain loose coupling and facilitate unit testing.
- Employ robust exception handling to capture and log errors, particularly when executing external processes.
## Git Integration Guidelines
- Use the **git command line** to extract commit data and file contents. Ensure that commands like `git log`, `git show`, and other **git** operations are executed reliably.
- Handle errors returned by **git** commands gracefully and log them for debugging purposes.
- When generating temporary file names (e.g., for checking out specific commits), ensure the solution is **cross-platform** by using .NET APIs that abstract file system differences.
## AvaloniaUI Guidelines
- For UI components, utilize **AvaloniaUI**'s **MVVM** pattern to separate logic from presentation.
- Ensure that UI updates occur on the appropriate thread and that interactions with the **git** backend are asynchronous.
- Leverage Avalonia’s styling and theming mechanisms to maintain a consistent look and feel across platforms.
## Error Handling and Logging
- Always log significant events using a centralized logging mechanism, and ensure logs include precise timestamps and commit identifiers where applicable.
- In cases where an external process fails (e.g., a **git** command), throw descriptive exceptions and capture stack traces to facilitate debugging.
- Utilize structured logging to record the flow of **git** operations and user interactions with the UI.
## Testing and Validation
- Write unit tests using **xUnit** and use mocking frameworks like **Moq** to simulate external dependencies such as **git** operations.
- Ensure tests cover edge cases such as invalid commit ranges, missing files, or unexpected process failures.
- Validate user inputs (for file paths, commit identifiers, etc.) rigorously before executing operations.
## Cross-Platform Considerations
- Design all file and process operations to function consistently on Windows, macOS, and Linux.
- Use .NET’s **Path** and **Process** APIs to avoid platform-specific issues.
- Ensure that **AvaloniaUI** components adapt to various screen sizes and operating systems, maintaining usability and performance.
## Repository Tree Map
.
├── GitContentSearch.sln // The primary solution file for the GitContentSearch project.
├── GitContentSearch.Tests
│ ├── FileSearcherTests.cs // Holds unit tests validating the functionality of file searching.
│ ├── GitContentSearch.Tests.csproj // The project file for building the test suite.
│ ├── GitContentSearcherTests.cs // Contains tests for the overall Git content search behavior.
│ ├── GitHelperTests.cs // Includes tests to ensure proper Git command integration.
│ └── GlobalUsings.cs // Declares global using directives to simplify test code.
├── GitContentSearch
│ ├── Commit.cs // Defines the Commit model representing a Git commit.
│ ├── FileSearcher.cs // Implements logic to search within text and Excel files.
│ ├── GitContentSearch.csproj // The project file for building the main application.
│ ├── GitContentSearch.sln // A solution file that may serve as an alternative or additional reference.
│ ├── GitContentSearcher.cs // Orchestrates Git operations and content search across commits.
│ ├── GitHelper.cs // Provides helper methods for executing Git commands.
│ ├── Program.cs // Contains the main entry point of the application.
│ ├── Helpers
│ │ ├── CompositeTextWriter.cs // Aggregates multiple text writers for unified logging.
│ │ ├── FileManager.cs // Manages temporary file creation and deletion during searches.
│ │ ├── ProcessResult.cs // Represents the result of executing an external process.
│ │ └── ProcessWrapper.cs // Encapsulates starting and managing external processes.
│ └── Interfaces
│ ├── IFileManager.cs // Defines the contract for file management operations.
│ ├── IFileSearcher.cs // Specifies the interface for file searching functions.
│ ├── IGitContentSearcher.cs // Outlines methods for performing Git content searches.
│ ├── IGitHelper.cs // Declares the interface for Git helper operations.
│ └── IProcessWrapper.cs // Specifies the abstraction for wrapping process execution.
└── README.md // Provides an overview and usage instructions for the project.
By following these guidelines, you will ensure that the GitContentSearch codebase remains robust, maintainable, and user-friendly across all supported platforms. Always be precise with **terminology** and document any decisions that deviate from these rules to aid future maintenance and collaboration.