Instruction file imported from jessetechie/tik (
.github/instructions/resource-access.instructions.md). Copyright stays with the author.
Resource Access Guidelines
- Keep persistence concerns in
Tik.ResourceAccess; do not add manager or engine business rules in this layer. - Follow the existing file pattern in resource classes: resource interface, request/response/command records, and implementation in the same file.
- Keep nullable reference type safety explicit: initialize non-nullable strings to
string.Emptyand arrays to[]in records. - Keep command-style resource methods
Task<CommandResult>and returnCommandResult.SuccessorCommandResult.Error(...)instead of throwing for normal data-path failures. - Keep SQL in C# raw string literals (
""") and use Dapper parameterization; never build SQL by string interpolation for user-provided values. - Prefer
SqlBuilderwhen optional filters are involved so predicates and parameter values stay centralized and safe. - Open connections with
using var connection = _dataContext.Connect();per operation. - Keep schema creation in
Init()methods throughIDatabaseInitializer, usingCREATE TABLE IF NOT EXISTSpatterns. - Preserve asynchronous APIs (
ExecuteAsync,QueryAsync,ExecuteScalarAsync) across resource access implementations.
Test-Specific Rules
- For in-memory SQLite tests (
Mode=Memory;Cache=Shared), keep one connection open for the lifetime of each test class. - Initialize schema in test setup (
Init()for each relevant resource) before issuing reads/writes. - Dispose the lifetime connection in
Dispose()to keep test isolation deterministic.