This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
OpenShock.Internal — internal shared .NET libraries for the OpenShock backend (consumed by API and other OpenShock services, not intended for third-party consumers). Contains Internal.Common (utilities, validation, crypto, geolocation), Internal.AspNet (ASP.NET Core extensions), and Internal.DynamicLinq (dynamic LINQ query builder for PostgreSQL/EF Core).
# Build
dotnet build
# Run all tests
dotnet test
# Run a single test project
dotnet test --project Internal.Common.Tests/Internal.Common.Tests.csproj
dotnet test --project Internal.DynamicLinq.Tests/Internal.DynamicLinq.Tests.csproj
# CI-style build + test
dotnet build --configuration Release && dotnet test --configuration Release --no-buildNo separate lint command — warnings are treated as errors in Debug configuration.
- Internal.Common/ — Main utility library (
OpenShock.Internal.Common) - Internal.AspNet/ — ASP.NET Core extensions (
OpenShock.Internal.AspNet) - Internal.Common.Tests/ — Unit tests for Internal.Common
- Internal.DynamicLinq/ — Dynamic LINQ expression builder targeting PostgreSQL via EF Core
- Internal.DynamicLinq.Tests/ — Tests for Internal.DynamicLinq (uses Testcontainers with PostgreSQL)
Solution file: Internal.slnx
- .NET 10.0, latest C# language version
- Nullable reference types enabled globally
- Central package management via
Directory.Packages.props Directory.Build.propsenables implicit usings, XML docs, and treats warnings as errors in Debug- Versioning is tag-driven: pushing a
v*tag triggers the publish workflow, which uses the tag name as the package version
Uses TUnit (not xUnit/NUnit). Test methods use TUnit attributes and async patterns. DynamicLinq tests use Testcontainers for real PostgreSQL instances and Bogus for test data generation.
Constants— Domain hard limits (username/password lengths, shocker limits, durations, intensities)Utils—HashingUtils(BCrypt + legacy PBKDF2, SHA-256 token hashing),CryptoUtils(cryptographic RNG),MathUtils(Haversine),LatencyEmulator(timing-safe operations with Gaussian noise)Geo—Alpha2CountryCode(value-type struct wrapping ushort),DistanceLookup(pre-computed frozen dictionary of country-to-country distances)Validation—CharsetMatchersfor detecting emojis, zalgo text, zero-width spaces, control charsJsonSerialization— Custom converters (Unix milliseconds, flag-guarded enum strings)
QueryStringTokenizer— Parses filter strings with quoted values and escape sequencesDBExpressionBuilder— Converts string filter queries into LINQ expressions (supportseq,neq,lt,gt,lte,gte,ilike; multiple filters joined withand)OrderByQueryBuilder— Dynamic OrderBy/ThenBy from string input- Properties marked with
[IgnoreDataMember]are excluded from query building for security
stackalloc/Span<T>for short-lived buffersArrayPool<byte>for temporary allocationsFrozenDictionaryfor immutable lookup tablesCollectionsMarshalfor optimized dictionary operationsGeneratedRegexfor compiled regex patterns
- Password hashing uses BCrypt with SHA-512; PBKDF2 is legacy-only
- Token hashing uses SHA-256
- Timing-safe verification via
LatencyEmulatorsliding window statistics - Expression builder hides internal structure in error messages
AGPL-3.0-or-later