| 1 | # .NET Roslyn and Debug Playbook v1 |
| 2 | |
| 3 | ## Related |
| 4 | |
| 5 | - Обязательный чеклист агента Cursor (Roslyn MCP, `file_path` по каждому затронутому `.cs`): [`playbook-csharp-roslyn-mcp-diagnostics-v1.md`](playbook-csharp-roslyn-mcp-diagnostics-v1.md). |
| 6 | |
| 7 | ## Purpose |
| 8 | Specialized playbook for C# diagnostics, refactorings, and debug workflows in .NET projects. |
| 9 | |
| 10 | ## Scope |
| 11 | - Roslyn-first diagnostics and code actions |
| 12 | - Structured build/test validation |
| 13 | - Debug session orchestration and evidence capture |
| 14 | - Fast root-cause isolation for C# runtime and logic failures |
| 15 | |
| 16 | ## Evidence-Based Working Format |
| 17 | - Fact: capture the exact failing diagnostic, test, or runtime symptom. |
| 18 | - Hypothesis: define the minimal likely cause. |
| 19 | - Check: apply smallest fix and re-run the shortest validating loop. |
| 20 | - Decision criterion: predefine close/escalate threshold. |
| 21 | - Confidence mark: explicit certainty tag and unresolved risk. |
| 22 | |
| 23 | ## Roslyn-First Contracts |
| 24 | - Use Roslyn diagnostics as primary source for C# errors/warnings. |
| 25 | - Prefer `get_code_actions` + `apply_code_action` over manual edits when available. |
| 26 | - Use symbol-aware navigation (`go_to_definition`, `find_usages`) for refactoring. |
| 27 | - Use semantic rename (`roslyn_rename`) for identifier-safe renames. |
| 28 | |
| 29 | ## Diagnostic Loop |
| 30 | - Scope diagnostic pass: file -> project -> solution. |
| 31 | - Fix highest-severity issues first, then warnings with behavior risk. |
| 32 | - Re-run diagnostics after each meaningful batch. |
| 33 | - Track recurring warning classes into checklist updates. |
| 34 | |
| 35 | ## Debug Session Contracts |
| 36 | - Always make target and arguments explicit before launch. |
| 37 | - Keep breakpoints tied to current target artifact. |
| 38 | - Use continue/step/inspect cycle with explicit assumption checks. |
| 39 | - End session with concise root cause + fix verification note. |
| 40 | |
| 41 | ## Build/Test Validation Contracts |
| 42 | - Run build after structural refactors. |
| 43 | - Run impacted tests before broad test suites. |
| 44 | - Treat flaky tests as defects in feedback reliability. |
| 45 | - Keep local loop aligned with CI contracts. |
| 46 | |
| 47 | ## Common Failure Patterns |
| 48 | - Symbol rename without usage sweep -> semantic drift. |
| 49 | - Manual fix bypassing code action -> hidden style/semantic inconsistency. |
| 50 | - Debug without stable repro -> misleading observations. |
| 51 | - Multi-fix commit without intermediate checks -> unclear causality. |
| 52 | |
| 53 | ## Metrics |
| 54 | - Time to first valid diagnosis. |
| 55 | - Time to green build after first failure. |
| 56 | - Ratio of code-action fixes vs manual fixes. |
| 57 | - Reopen rate for fixed debug incidents. |
| 58 | |
| 59 | ## Revisit Triggers |
| 60 | - Repeat diagnostic classes over multiple cycles. |
| 61 | - High debug time with weak reproducibility. |
| 62 | - Frequent mismatch between local and CI outcomes. |
| 63 | - Rising regressions after refactors. |
| 64 | |
| 65 | |