microsoft/typespec/csharp-spector-coverage-gaps
Claude Code and agent skill by microsoft/typespec
- vendor
Checking that the SKILL.md file is still in the repository.
Discovers and implements gaps in Spector test coverage for the C# HTTP client emitter. Use when asked to find missing Spector scenarios, add Spector test coverage, or implement a specific Spector spec for the C# emitter.
Install
npx vskill@latest install microsoft/typespec/csharp-spector-coverage-gapsSKILL.md
The same SKILL.md was published earlier as microsoft/typespec/csharp-spector-coverage-gaps.
Discovering and implementing Spector coverage gaps for http-client-csharp
Overview
This skill discovers which Spector scenarios the C# emitter (@typespec/http-client-csharp) does not yet cover, then implements the missing test(s). Spector scenarios are defined in @typespec/http-specs and @azure-tools/azure-http-specs. The coverage dashboard is at <https://typespec.io/can-i-use/http/>.
Note:{PKG}refers to<repo-root>/packages/http-client-csharpthroughout this document.
Inputs
You may receive one of:
- "Find coverage gaps" — discover all missing scenarios and present them.
- Spector spec link — a link to a specific spec under
packages/http-specs/specs/...orpackages/azure-http-specs/specs/.... - Spec name — e.g.,
http/encode/duration,http/type/model/flatten,http/type/union/discriminated.
Output
- A report of coverage gaps (when discovering).
- New or updated C# NUnit test file(s) under
{PKG}/generator/TestProjects/Spector.Tests/Http/. - Updated
{PKG}/generator/TestProjects/Spector.Tests/TestProjects.Spector.Tests.csprojif a new project reference is needed. - Regenerated client code (via
Generate.ps1).
Workflow
- [ ] Ensure prerequisites are met (npm ci, npm run build)
- [ ] Discover coverage gaps or identify the target spec
- [ ] Verify the spec is not in the failing specs list
- [ ] Generate the C# client for the target spec (unstubbed with
-Stubbed $false, or use Test-Spector.ps1) - [ ] Read the generated client to understand the API surface
- [ ] Read the TypeSpec scenario file to understand expected behavior
- [ ] Find or create the test file
- [ ] Implement the test(s) following existing conventions
- [ ] Run the tests using
Test-Spector.ps1 -filter "<spec-path>" - [ ] Validate all tests pass
Prerequisites — Environment setup
Before starting, ensure the build environment is ready. These instructions supersede the repo-root pnpm instructions.
- Install dependencies (from
{PKG}):
``powershell cd {PKG} npm ci ``
- Build the package:
``powershell npm run build ``
⚠️ Do NOT runpnpm installorpnpm buildat the repo root — only the http-client-csharp package build is needed.
Step 1 — Discover coverage gaps
How specs are filtered
The file {PKG}/eng/scripts/Spector-Helper.psm1 defines which specs are included/excluded:
Failing specs are defined in {PKG}/eng/scripts/Spector-Helper.psm1 in the $failingSpecs array. Always check that file for the current list — do not hardcode specs here.
Azure allow-list (only these Azure specs are tested):
http/client/structure/client-operation-grouphttp/client/structure/defaulthttp/client/structure/multi-clienthttp/client/structure/renamed-operationhttp/client/structure/two-operation-grouphttp/resiliency/srv-driven
All other specs from @typespec/http-specs are included by default.
Discovering gaps programmatically
Compare available specs against existing tests. Run this from {PKG}:
Alternatively, manually compare the list of specs against existing test files:
Existing test coverage (test directories under Spector.Tests/Http/):
Accurate gap detection
The naive approach of matching spec paths to test directory names can produce false positives because:
- C# reserved words get underscore-prefixed in test dirs (e.g.,
type/→_Type/,array→_Array,enum→_Enum) - kebab-case gets converted to PascalCase (e.g.,
content-negotiation→ContentNegotiation) - Some test files cover a parent spec but not sub-specs (e.g.,
UnionTests.cscoverstype/unionbut NOTtype/union/discriminated)
To find real gaps, verify each candidate by checking whether a test _directory_ exists for the spec's exact path, including sub-paths. A test file at a parent level does NOT cover child specs.
Known failing specs are tracked in $failingSpecs in {PKG}/eng/scripts/Spector-Helper.psm1. Always read that file for the current list.
Important: The gap list evolves over time. Always re-run the comparison to get current gaps. All committed Spector libraries are stubbed —[SpectorTest]will auto-skip tests unless you regenerate with-Stubbed $falseor useTest-Spector.ps1.
Understanding stubbed vs unstubbed generation
All Spector libraries committed to the repository are stubbed. Generate.ps1 defaults to $Stubbed = $true, which passes --option @typespec/http-client-csharp.generator-name=StubLibraryGenerator to the emitter. Stubbed clients use expression-bodied constructors (=>) instead of block bodies ({ }), and the [SpectorTest] attribute automatically skips tests for stubbed clients.
To generate unstubbed code (for local testing), pass -Stubbed $false:
However, the recommended way to test is via Test-Spector.ps1 (see Step 7), which handles the unstubbed regeneration, test execution, and directory restoration automatically.
Step 2 — Read the spec to understand expected behavior
Spec files live in {PKG}/node_modules/@typespec/http-specs/specs/ (or @azure-tools/azure-http-specs/specs/ for Azure specs).
If node_modules is not installed, read from the source at <repo-root>/packages/http-specs/specs/.
Each spec contains:
- `main.tsp` — the TypeSpec definition with
@scenarioand@scenarioDocdecorators - `client.tsp` (optional) — client-level customizations; takes priority over
main.tspduring generation - `tspconfig.yaml` (optional in the Spector test project) — C#-specific generation options
Read the @scenarioDoc decorators to understand:
- The HTTP method, path, and expected parameters
- The expected request body shape
- The expected response status code and body
- Any special behavior (e.g., "should return 204", "should send header X")
Step 3 — Generate the C# client for the target spec
Use Generate.ps1 with a filter to generate only the specific spec. By default, Generate.ps1 generates stubbed code (same as what is committed to the repo). To generate unstubbed code for local testing, pass -Stubbed $false:
Examples:
The generated code lands in {PKG}/generator/TestProjects/Spector/<spec-path>/src/Generated/.
Verify generation succeeded
Note: All committed Spector libraries are stubbed. The[SpectorTest]attribute automatically skips tests for stubbed clients. UseTest-Spector.ps1(Step 7) to regenerate unstubbed, run tests, and restore automatically.
Step 4 — Read the generated client API surface
Browse the generated code to understand:
- Client class(es):
*Client.cs— the entry point(s) - Sub-clients: accessed via
Get*Client()methods - Operations: async methods like
GetAsync(),PutAsync(body),SendAsync() - Models: under
Models/— request/response shapes - Constructor signature:
new XClient(Uri endpoint, XClientOptions options)ornew XClient(Uri endpoint, KeyCredential credential, XClientOptions options)
Pay attention to:
- Method names (they map to TypeSpec operation names)
- Parameter types (models, primitives, BinaryData)
- Return types (
ClientResult,ClientResult<T>,AsyncPageable<T>)
Step 5 — Create or extend the test file
Directory and namespace conventions
The test directory structure mirrors the spec path with these transformations:
http/→Http/- kebab-case → PascalCase (e.g.,
content-negotiation→ContentNegotiation) type/→_Type/(leading underscore becauseTypeis a C# keyword)array→_Array(same reason)enum→_Enum(same reason)
Namespace pattern: TestProjects.Spector.Tests.Http.<PascalCasePath>
Example mappings:
| Spec path | Test directory | Namespace | |
|---|---|---|---|
http/encode/duration | Http/Encode/Duration/ | TestProjects.Spector.Tests.Http.Encode.Duration | |
http/type/union/discriminated | Http/_Type/Union/Discriminated/ | TestProjects.Spector.Tests.Http._Type.Union.Discriminated | |
http/special-words | Http/SpecialWords/ | TestProjects.Spector.Tests.Http.SpecialWords |
Test file template
Common test patterns
Simple void operation (204 response):
GET with typed response:
GET with model response:
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files. Certified 1 Oct 2026.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryChecking.github/skills/csharp-spector-coverage-gaps/SKILL.md
Popularity
- Repository stars
- 5,813
- Repository forks
- 381
- 7-day trend score
- 43
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 13 May 2026, 6 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/microsoft/typespec/csharp-spector-coverage-gaps)