Files
nt8-sdk/.kilocode/rules/coding_patterns.md

34 lines
1.5 KiB
Markdown

# Coding Patterns - NT8 SDK Required Patterns
**Last Updated:** 2026-04-05
All production code must use these implementation patterns.
## Scope Discipline and Minimum Diff
- [ ] Edit only files in task scope.
- [ ] Make the smallest safe change that resolves the issue.
- [ ] Do not change interfaces/contracts unless explicitly required.
- [ ] Do not mix functional changes with style-only cleanup.
## C# 5.0 and .NET 4.8 Compatibility
- [ ] Use C# 5.0 syntax only.
- [ ] Avoid C# 6+ features (`$""`, `?.`, `nameof`, expression-bodied members, `out var`, etc.).
- [ ] Keep compatibility with .NET Framework 4.8.
- [ ] Use `string.Format` style logging/messages.
## Core Implementation Patterns
- [ ] Validate inputs at method entry.
- [ ] Wrap public method logic in `try/catch` with meaningful logging.
- [ ] Protect shared mutable collections/state with `lock (_lock)`.
- [ ] Do not raise events while holding locks.
- [ ] Keep public members documented with XML comments where required by project standards.
## NinjaScript Coding Patterns (When Applicable)
- [ ] Keep `OnStateChange` responsibilities separated by state.
- [ ] Guard `OnBarUpdate` by `BarsInProgress` and bar readiness.
- [ ] In managed order flow, set stop/target before entry on the same bar.
## Authoritative Rule References (Do Not Duplicate)
- Syntax constraints: `.kilocode/rules/csharp_50_syntax.md`
- NT8 compile and API constraints: `.kilocode/rules/nt8compilespec.md`
- Verification commands and gates: `.kilocode/rules/verification_requirements.md`