|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Best Practices |
| 6 | + |
| 7 | +When working with this codebase, always follow modern .NET and C# best practices: |
| 8 | + |
| 9 | +- Use latest C# language features (records, pattern matching, nullable reference types, file-scoped namespaces) |
| 10 | +- Follow .NET naming conventions and coding standards |
| 11 | +- Leverage modern async/await patterns where applicable |
| 12 | +- Use `System.Text.Json` for JSON serialization |
| 13 | +- Prefer `Span<T>` and `Memory<T>` for performance-critical code |
| 14 | +- Use collection expressions and LINQ for data manipulation |
| 15 | +- Apply proper error handling with exceptions and Result patterns |
| 16 | +- Write clean, readable code with meaningful variable names |
| 17 | +- Use nullable reference types and enable all relevant compiler warnings |
| 18 | + |
| 19 | +## Commands |
| 20 | + |
| 21 | +### Build |
| 22 | +```bash |
| 23 | +dotnet build |
| 24 | +``` |
| 25 | + |
| 26 | +### Test |
| 27 | +```bash |
| 28 | +dotnet test --no-restore |
| 29 | +``` |
| 30 | + |
| 31 | +### Run a single test |
| 32 | +```bash |
| 33 | +dotnet test --filter "FullyQualifiedName~TwoSumTest" |
| 34 | +``` |
| 35 | + |
| 36 | +### Run console application |
| 37 | +```bash |
| 38 | +cd ./LeetCode |
| 39 | +dotnet run |
| 40 | + |
| 41 | +# Run specific commands |
| 42 | +dotnet run benchmark LRUCache --csharp |
| 43 | +dotnet run info MergeTwoLists |
| 44 | +dotnet run list |
| 45 | +``` |
| 46 | + |
| 47 | +## Architecture |
| 48 | + |
| 49 | +This is a LeetCode problem solutions repository with benchmarking capabilities, structured as follows: |
| 50 | + |
| 51 | +### Three main projects: |
| 52 | +1. **LeetCode.CSharp** - C# implementations of LeetCode problems with xUnit tests and BenchmarkDotNet benchmarks |
| 53 | +2. **LeetCode.FSharp** - F# implementations of selected problems |
| 54 | +3. **LeetCode** - Console application for running benchmarks and viewing problem information |
| 55 | + |
| 56 | +### Key architectural patterns: |
| 57 | + |
| 58 | +**Problem Organization**: All C# problems are implemented as static methods in the `Problem` partial class, decorated with `[LeetCode]` attributes containing metadata (description, difficulty, category, NeetCode video link). Each problem includes inline xUnit tests using `[Fact]` attributes. |
| 59 | + |
| 60 | +**Benchmark Structure**: Each problem has a corresponding benchmark class in the Benchmarks folder that inherits from a base `Benchmark` class. Benchmarks use BenchmarkDotNet with GlobalSetup/GlobalCleanup for test data preparation. |
| 61 | + |
| 62 | +**Console Application**: Built with Spectre.Console, provides an interactive menu system and CLI commands (app, benchmark, info, list, workflow) for running benchmarks and viewing problem information. |
| 63 | + |
| 64 | +**Testing**: Uses xUnit with FluentAssertions for test assertions. Tests are co-located with problem implementations for easy access. |
| 65 | + |
| 66 | +**Package Management**: Uses Directory.Packages.props for centralized NuGet package version management across all projects. |
0 commit comments