This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
OpenCode is a .NET utility library providing extension methods for common types (string, bool, int, decimal, DateTime, Guid). It is published as a NuGet package targeting .NET 8, .NET 9, and .NET 10.
# Build
dotnet build
dotnet build --configuration Release
# Run all tests
dotnet test
# Run tests for a specific framework
dotnet test --framework net9.0
# Run a single test class
dotnet test --filter "FullyQualifiedName~OpenCode.Tests.StringExtension.StringExtensionCoreTests"
# Run a single test method
dotnet test --filter "FullyQualifiedName~MethodName"
# Pack NuGet package
dotnet pack --configuration Release --output ./nupkgNo separate lint command — code style is enforced via .editorconfig.
The solution has two projects:
- OpenCode/ — The library. Each type's extensions live in a subfolder (e.g.,
StringExtension/,IntegerExtension/). StringExtension is split across multiple files usingpartial class(e.g.,StringExtension.Core.cs,StringExtension.Hash.cs,StringExtension.Bool.cs). - OpenCode.Tests/ — xUnit tests mirroring the source folder structure 1:1.
All extension classes are public static in the namespace OpenCode; (file-scoped). StringExtension classes are partial; other type extensions are sealed.
- Null safety: Extension methods handle null inputs gracefully (return defaults, empty strings, etc.) — they never throw on null. Nullable reference types are enabled.
- Culture: Use
CultureInfo.InvariantCulturefor all parsing and formatting. - Conditional compilation: .NET 7+ uses source-generated regex via
[GeneratedRegex]attributes onprivate static partial Regexmethods. Older targets usestatic readonly Regexfields withRegexOptions.Compiled. - XML docs: All public members have
<summary>,<param>,<returns>documentation. - Tests: xUnit with
[Theory]/[InlineData]for parameterized tests. Test class naming:{ClassName}Tests.
GitHub Actions workflow (.github/workflows/nuget-publish.yml) triggers on push to release/* branches or v* tags. It tests on .NET 8, 9, and 10, then packs and publishes to nuget.org from the .NET 10 matrix run using OIDC authentication.
Release branches follow the pattern release/{version} (e.g., release/3.2). The current main development branch is release/3.2.