Skip to content

Commit f3b8402

Browse files
authored
feat(docs): add GitHub Copilot instructions (#91)
1 parent 5e3841f commit f3b8402

File tree

2 files changed

+173
-12
lines changed

2 files changed

+173
-12
lines changed

.github/copilot-instructions.md

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
# GitHub Copilot Instructions
2+
3+
## 1. Repository Context & Mission
4+
5+
**Repository:** `HttpUserAgentParser` (mycsharp)
6+
7+
**Primary Goal:**
8+
Provide a **high-performance, stable, and broadly compatible .NET library** for parsing HTTP User-Agent strings, including integrations for ASP.NET Core and MemoryCache.
9+
10+
**Core Design Principles:**
11+
- API stability over convenience
12+
- Predictable performance characteristics
13+
- Minimal allocations in hot paths
14+
- Full test coverage for all observable behavior
15+
16+
---
17+
18+
## 2. Repository Structure (Authoritative)
19+
20+
Copilot must understand and respect the architectural boundaries:
21+
22+
- `src/HttpUserAgentParser`
23+
→ Core parsing logic and public APIs
24+
25+
- `src/HttpUserAgentParser.AspNetCore`
26+
→ ASP.NET Core integration (middleware, extensions)
27+
28+
- `src/HttpUserAgentParser.MemoryCache`
29+
→ Caching extensions and cache-aware abstractions
30+
31+
- `tests/*`
32+
→ Unit tests for **all** shipped packages
33+
→ Tests define expected behavior and are the source of truth
34+
35+
- `perf/*`
36+
→ Benchmarks for performance-sensitive code paths
37+
38+
---
39+
40+
## 3. Standard .NET CLI Commands
41+
42+
Use these commands consistently:
43+
44+
- Clean:
45+
`dotnet clean --nologo`
46+
47+
- Restore:
48+
`dotnet restore`
49+
50+
- Build:
51+
`dotnet build --nologo`
52+
53+
- Test (all):
54+
`dotnet test --nologo`
55+
56+
- Test (single project):
57+
`dotnet test <path-to-csproj> --nologo`
58+
59+
---
60+
61+
## 4. Autonomous Execution Rules (Critical)
62+
63+
Copilot is expected to work **independently and end-to-end** without human intervention.
64+
65+
### Mandatory Quality Gates (Never Skip)
66+
- The solution **must compile** after every change
67+
- **All tests must pass**
68+
- New behavior **must include unit tests**
69+
- Public APIs **must not break** existing users unless explicitly intended
70+
- Changes must be **minimal, focused, and intentional**
71+
72+
If any gate fails:
73+
1. Diagnose the root cause
74+
2. Fix the issue
75+
3. Re-run the full validation cycle
76+
77+
---
78+
79+
## 5. Change Strategy & Scope Control
80+
81+
When solving a task, Copilot should:
82+
83+
1. **Analyze existing code first**
84+
- Prefer extension over modification
85+
- Reuse established patterns and helpers
86+
2. **Avoid architectural rewrites**
87+
- No refactors unless explicitly required
88+
3. **Preserve backward compatibility**
89+
- No breaking changes to public APIs
90+
- No silent behavioral changes
91+
92+
If multiple solutions are possible:
93+
- Prefer the **simplest**, **most explicit**, and **least invasive** option
94+
95+
---
96+
97+
## 6. Testing Requirements
98+
99+
Every functional change must be fully tested:
100+
101+
- Unit tests are mandatory for:
102+
- New features
103+
- Bug fixes
104+
- Edge cases and regressions
105+
- Prefer existing utilities from:
106+
`tests/HttpUserAgentParser.TestHelpers`
107+
108+
Tests define correctness. If behavior is unclear, tests take precedence over assumptions.
109+
110+
---
111+
112+
## 7. Performance Guidelines
113+
114+
- Treat parsing logic as performance-critical
115+
- Avoid unnecessary allocations and LINQ in hot paths
116+
- Prefer spans, pooling, and cached results where appropriate
117+
- Update or add benchmarks in `perf/*` for performance-relevant changes
118+
119+
---
120+
121+
## 8. Output Expectations
122+
123+
Copilot should deliver:
124+
- Compilable, production-ready code
125+
- Complete test coverage for new behavior
126+
- Clear, intentional commits without unrelated changes
127+
128+
**Do not stop early.**
129+
A task is only complete when **all quality gates pass** and the solution is fully validated.

.vscode/tasks.json

Lines changed: 44 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,45 @@
11
{
2-
"version": "2.0.0",
3-
"tasks": [
4-
{
5-
"label": "test",
6-
"type": "shell",
7-
"command": "dotnet test --nologo",
8-
"args": [],
9-
"problemMatcher": [
10-
"$msCompile"
11-
],
12-
"group": "build"
13-
}
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"label": "clean",
6+
"type": "shell",
7+
"command": "dotnet clean",
8+
"problemMatcher": "$msCompile"
9+
},
10+
{
11+
"label": "restore",
12+
"type": "shell",
13+
"command": "dotnet restore",
14+
"problemMatcher": "$msCompile"
15+
},
16+
{
17+
"label": "build",
18+
"type": "shell",
19+
"command": "dotnet build --nologo",
20+
"problemMatcher": "$msCompile",
21+
"group": "build"
22+
},
23+
{
24+
"label": "test",
25+
"type": "shell",
26+
"command": "dotnet test --nologo",
27+
"problemMatcher": "$msCompile",
28+
"group": "test"
29+
},
30+
{
31+
"label": "ci:validate",
32+
"dependsOn": [
33+
"clean",
34+
"restore",
35+
"build",
36+
"test"
37+
],
38+
"dependsOrder": "sequence",
39+
"group": {
40+
"kind": "build",
41+
"isDefault": true
42+
}
43+
}
44+
]
45+
}

0 commit comments

Comments
 (0)