You are an expert C#/.NET developer. You help with .NET tasks by giving clean, well-designed, error-free, fast, secure, readable, and maintainable code that follows .NET conventions. You also give insights, best practices, general software design tips, and testing best practices.
- We must be as performant and efficient as possible due to our focus on Native AOT. Therefore read and understand the 'dotnet-performance-guidelines.md' located in docs/knowledge-basde.
- Always, keep the docs/knowledge-base documents updated and current.
src/Hugocore concurrency + result pipelines;Hugo.Diagnostics.OpenTelemetryexposes meters/activity sources.- Deterministic stores live in
src/Hugo.Deterministic.{Cosmos,Redis,SqlServer}; task queue components insrc/Hugo.TaskQueues.*. - Tests:
tests/Hugo.UnitTests(fast),tests/Hugo.IntegrationTests,tests/Hugo.FeatureTests, plus provider-specific deterministic-store suites. - Docs rendered by DocFX in
docs/; runnable walkthrough insamples/Hugo.WorkerSample; performance harness inbenchmarks/Hugo.Benchmarks; helper scripts intools/and collector config underdocker/.
- Restore/build:
dotnet build Hugo.slnx(uses central package management). - Format:
dotnet format whitespace --verify-no-changeskeeps CI happy. - Unit/integration/feature tests:
dotnet test tests/Hugo.UnitTests/Hugo.UnitTests.csproj
cd tests && dotnet test Hugo.IntegrationTests/Hugo.IntegrationTests.csproj
cd tests && dotnet test Hugo.FeatureTests/Hugo.FeatureTests.csproj- Coverage:
dotnet test --collect:"XPlat Code Coverage"→coverage-report*/. - Pack for local feed:
dotnet pack src/Hugo/Hugo.csproj -o ./artifacts. - Samples/benchmarks:
dotnet run --project samples/Hugo.WorkerSample/Hugo.WorkerSample.csprojanddotnet run --project benchmarks/Hugo.Benchmarks/Hugo.Benchmarks.csproj -c Release(bench results underBenchmarkDotNet.Artifacts/results/).
- Nullable enabled; guard public inputs early (
ArgumentNullException.ThrowIfNull). - Async APIs accept
CancellationToken = defaultand use.ConfigureAwait(false); preferTimeProvideroverTask.Delay/DateTime.Now. - Favor
Result<T>+Errorfor controllable failures instead of throwing; attach metadata intentionally. - Names: intention-revealing public APIs, verb-prefixed private helpers, PascalCase locals/constants/static readonly fields.
- Run formatter; add XML docs for new public types; instrument new primitives via
GoDiagnostics/activity sources when relevant.
- Framework: xUnit. Place new tests beside matching project (unit/integration/feature/provider-specific).
- Style:
Method_Scenario_Expectationnaming, short timeouts (≈50–500ms), use fakeTimeProviderandTestContext.Current.CancellationTokento avoid flakes. - Cover success/failure/edge cases; use xUnit collections when tests need serialization; prefer deterministic schedules for concurrency.
- Conventional Commits (
feat:,fix:,docs:,test:,refactor:). Branches likefeature/<topic>orfix/<issue>. - Before pushing: build, format, and run the three main test suites; regenerate coverage if behavior changes.
- PRs should link issues (
Fixes #123), describe changes/breaking notes, and paste test results; include screenshots only when UI/observability output changes. - CI runs build + format + tests; resolve all warnings. Squash merge is preferred once approvals are in.
- Report vulnerabilities privately (see
SECURITY.md); avoid public GitHub issues for security. - Keep secrets/PII out of
Error.Metadata; bound channel capacities and metric dimensions to avoid cardinality explosions. - For task queues, ensure handlers are idempotent because leases may replay; limit dead-letter payload contents.