Skip to content

Commit 2f818f6

Browse files
si618claude
andauthored
Migrate from .sln to .slnx and update NuGet packages (#146)
* Migrate from .sln to .slnx and update NuGet packages - Remove LeetCode.sln and use LeetCode.slnx exclusively - Update GitHub Actions workflow to use .slnx automatically via discovery - Update NuGet packages: BenchmarkDotNet, coverlet.collector, FluentAssertions, lolcat, Nerdbank.GitVersioning, Spectre.Console packages - Fix F# project build issues by disabling GenerateProgramFile and adding explicit Program.fs entry point - Fix F# Core assembly loading by removing explicit FSharp.Core package reference - Exclude test SDK runtime assets from console app to prevent entry point conflicts - Add version.json for Nerdbank.GitVersioning configuration - Update global.json to SDK 9.0.301 * Fix Nerdbank.GitVersioning shallow clone issue in GitHub Actions - Add fetch-depth: 0 to checkout actions to enable full git history for version height calculation. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 8ecf318 commit 2f818f6

File tree

9 files changed

+99
-65
lines changed

9 files changed

+99
-65
lines changed

.github/workflows/workflow.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ jobs:
1818
steps:
1919
- name: Checkout
2020
uses: actions/checkout@main
21+
with:
22+
fetch-depth: 0
2123

2224
- name: Setup dotnet
2325
uses: actions/setup-dotnet@v4
@@ -43,6 +45,8 @@ jobs:
4345
steps:
4446
- name: Checkout
4547
uses: actions/checkout@main
48+
with:
49+
fetch-depth: 0
4650

4751
- name: Setup dotnet
4852
uses: actions/setup-dotnet@v4

CLAUDE.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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.

Directory.Packages.props

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,26 @@
33
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
44
</PropertyGroup>
55
<ItemGroup>
6-
<PackageVersion Include="BenchmarkDotNet" Version="0.14.0" />
7-
<PackageVersion Include="coverlet.collector" Version="6.0.2">
6+
<PackageVersion Include="BenchmarkDotNet" Version="0.15.2" />
7+
<PackageVersion Include="coverlet.collector" Version="6.0.4">
88
<PrivateAssets>all</PrivateAssets>
99
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1010
</PackageVersion>
11-
<PackageVersion Include="FluentAssertions" Version="6.12.1" />
11+
<PackageVersion Include="FluentAssertions" Version="7.2.0" />
1212
<PackageVersion Include="FsUnit.xUnit" Version="6.0.1" />
1313
<PackageVersion Include="FSharp.Core" Version="8.0.400" />
14-
<PackageVersion Include="lolcat" Version="1.1.64" />
14+
<PackageVersion Include="lolcat" Version="1.1.120" />
1515
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
16-
<PackageVersion Include="Nerdbank.GitVersioning" Version="3.6.143">
16+
<PackageVersion Include="Nerdbank.GitVersioning" Version="3.7.115">
1717
<PrivateAssets>all</PrivateAssets>
1818
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1919
</PackageVersion>
20-
<PackageVersion Include="Spectre.Console" Version="0.49.1" />
20+
<PackageVersion Include="Spectre.Console" Version="0.50.0" />
2121
<PackageVersion Include="Spectre.Console.Analyzer" Version="1.0.0">
2222
<PrivateAssets>all</PrivateAssets>
2323
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2424
</PackageVersion>
25-
<PackageVersion Include="Spectre.Console.Cli" Version="0.49.1" />
25+
<PackageVersion Include="Spectre.Console.Cli" Version="0.50.0" />
2626
<PackageVersion Include="xunit" Version="2.9.2" />
2727
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2">
2828
<PrivateAssets>all</PrivateAssets>

LeetCode.FSharp/LeetCode.FSharp.fsproj

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
<PropertyGroup>
44
<IsPackable>false</IsPackable>
5-
<GenerateProgramFile>true</GenerateProgramFile>
5+
<GenerateProgramFile>false</GenerateProgramFile>
66
<RootNamespace>LeetCode.FSharp</RootNamespace>
7+
<CodeAnalysisTreatWarningsAsErrors>false</CodeAnalysisTreatWarningsAsErrors>
78
</PropertyGroup>
89

910
<ItemGroup>
@@ -13,17 +14,17 @@
1314
<Compile Include="ListNode.fs" />
1415
<Compile Include="Benchmarks\ContainsDuplicateBenchmark.fs" />
1516
<Compile Include="Benchmarks\FizzBuzzBenchmark.fs" />
17+
<Compile Include="Program.fs" />
1618
</ItemGroup>
1719

1820
<ItemGroup>
1921
<PackageReference Include="BenchmarkDotNet" />
20-
<PackageReference Include="FSharp.Core" />
2122
<PackageReference Include="FsUnit.xUnit" />
2223
<PackageReference Include="Microsoft.NET.Test.Sdk" />
2324
<PackageReference Include="coverlet.collector" />
2425
<PackageReference Include="xunit" />
2526
<PackageReference Include="xunit.runner.visualstudio" />
26-
<PackageReference Remove="FSharp.Core" />
27+
<PackageReference Remove="Nerdbank.GitVersioning" />
2728
</ItemGroup>
2829

2930
<ItemGroup>

LeetCode.FSharp/Program.fs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// Entry point for F# test project
2+
[<EntryPoint>]
3+
let main argv =
4+
0

LeetCode.sln

Lines changed: 0 additions & 52 deletions
This file was deleted.

LeetCode/LeetCode.csproj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@
1818
</ItemGroup>
1919

2020
<ItemGroup>
21-
<ProjectReference Include="..\LeetCode.CSharp\LeetCode.CSharp.csproj" />
21+
<ProjectReference Include="..\LeetCode.CSharp\LeetCode.CSharp.csproj">
22+
<IncludeAssets>compile;build</IncludeAssets>
23+
<ExcludeAssets>runtime</ExcludeAssets>
24+
</ProjectReference>
2225
<ProjectReference Include="..\LeetCode.FSharp\LeetCode.FSharp.fsproj" />
2326
</ItemGroup>
2427

global.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"sdk": {
3-
"version": "9.0.0",
3+
"version": "9.0.301",
44
"rollForward": "latestMajor",
55
"allowPrerelease": true
66
}
7-
}
7+
}

version.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
3+
"version": "0.0",
4+
"publicReleaseRefSpec": [
5+
"^refs/heads/main$"
6+
],
7+
"versionHeightOffset": -1
8+
}

0 commit comments

Comments
 (0)