|
| 1 | +# Akka.NET Agent Guidelines |
| 2 | + |
| 3 | +## Build/Test Commands |
| 4 | +- Build solution: `dotnet build` |
| 5 | +- Build with warnings as errors: `dotnet build -warnaserror` |
| 6 | +- Run all tests: `dotnet test -c Release` |
| 7 | +- Run specific test: `dotnet test -c Release --filter DisplayName="TestName"` or `dotnet test path/to/project.csproj` |
| 8 | +- Format check: `dotnet format --verify-no-changes` |
| 9 | + |
| 10 | +## Git Repository Management |
| 11 | +- Setup remotes: |
| 12 | + - `git remote add upstream https://github.com/akkadotnet/akka.net.git` (main repository) |
| 13 | + - `git remote add origin https://github.com/yourusername/akka.net.git` (your fork) |
| 14 | +- Sync with upstream: |
| 15 | + - `git fetch upstream` (get latest changes from main repo) |
| 16 | + - `git checkout dev` (switch to dev branch) |
| 17 | + - `git merge upstream/dev` (merge changes from upstream) |
| 18 | + - `git push origin dev` (update your fork) |
| 19 | +- Create feature branch: |
| 20 | + - `git checkout -b feature/your-feature-name` (create and switch to new branch) |
| 21 | + - `git push -u origin feature/your-feature-name` (push branch to your fork) |
| 22 | + |
| 23 | +## Code Style Guidelines |
| 24 | +- Use Allman style brackets for C# code (opening brace on new line) |
| 25 | +- 4 spaces for indentation |
| 26 | +- Prefer "var" everywhere when type is apparent |
| 27 | +- Private fields start with `_` (underscore), PascalCase for public/protected members |
| 28 | +- No "this." qualifier when unnecessary |
| 29 | +- Use exceptions for error handling (IllegalStateException for invalid states) |
| 30 | +- Sort using statements with System.* appearing first |
| 31 | +- XML comments for public APIs |
| 32 | +- Name tests with descriptive `DisplayName=` attributes |
| 33 | +- Default to `sealed` classes and records for data objects |
| 34 | +- Enable nullability in new/modified files with `#nullable enable` |
| 35 | +- Never use `async void`, `.Result`, or `.Wait()` - these cause deadlocks |
| 36 | +- Always pass `CancellationToken` in async methods |
| 37 | + |
| 38 | +## API Approvals |
| 39 | +- Run API approval tests when making public API changes: `dotnet test -c Release src/core/Akka.API.Tests` |
| 40 | +- Approval files are located at `src/core/Akka.API.Tests/CoreAPISpec.ApproveCore.approved.txt` |
| 41 | +- Install a diff viewer like WinMerge or TortoiseMerge to approve API changes |
| 42 | +- Follow extend-only design principles - don't modify existing public APIs, only extend them |
| 43 | +- Mark deprecated APIs with `[Obsolete("Obsolete since v{current-akka-version}")]` |
| 44 | + |
| 45 | +## Conventions |
| 46 | +- Stay close to JVM Akka where applicable but be .NET idiomatic |
| 47 | +- Use Task<T> instead of Future, TimeSpan instead of Duration |
| 48 | +- Include unit tests with changes |
| 49 | +- Preserve public API and wire compatibility |
| 50 | +- Keep pull requests small and focused (<300 lines when possible) |
| 51 | +- Fix warnings instead of suppressing them |
| 52 | +- Treat TBD comments as action items to be resolved |
| 53 | +- Benchmark performance-critical code changes with BenchmarkDotNet |
| 54 | +- Avoid adding new dependencies without license/security checks |
| 55 | + |
| 56 | +## Akka.NET TestKit Guidelines |
| 57 | +- Actor tests should derive from `AkkaSpec` or `TestKit` to access actor testing facilities |
| 58 | +- Pass `ITestOutputHelper output` to the constructor and base constructor: `public MySpec(ITestOutputHelper output) : base(config, output)` |
| 59 | +- Use the `ITestOutputHelper` output for debugging: it captures all test output including actor system logs |
| 60 | +- Configure proper logging in tests: `akka.loglevel = DEBUG` or `akka.loglevel = INFO` |
| 61 | +- Use `EventFilter` to assert on log messages (e.g., `EventFilter.Error().ExpectOne(() => { /* test code */ });`) |
| 62 | +- For testing deadletters, use `EventFilter.DeadLetter().Expect(1, () => { /* code that should produce dead letter */ });` |
| 63 | +- Test message assertions using `ExpectMsg<T>()`, `ExpectNoMsg()`, or `FishForMessage<T>()` |
| 64 | +- Set explicit timeouts for message expectations to avoid long-running tests |
| 65 | +- Use `TestProbe` to create lightweight test actors to verify interactions |
| 66 | +- Tests should clean up after themselves (stop created actors, reset state) |
| 67 | +- To test specialized message types, verify the type wrapper in logs: `wrapped in [$TypeName]` |
| 68 | + |
| 69 | +## Repository Landmarks |
| 70 | +- `src/` - All runtime / library code |
| 71 | +- `src/benchmark/` - Micro-benchmarks (BenchmarkDotNet) |
| 72 | +- `src/…Tests/` - xUnit test projects |
| 73 | +- `docs/community/contributing/` - Contributor policies & style guides |
| 74 | +- `docs/` - Public facing documentation |
0 commit comments