vstest
Copilot instructions968 starsChanged 7 months agoMITView on GitHub
This is a .NET based repository that contains the VSTest test platform. Please follow these guidelines when contributing: You MUST follow all code-formatting and naming conventions defined in .editorconfig. In addition to the rules enforced by .editorconfig, you SHOULD: You MUST minimize adding public API surface area but any newly added public API MUST be declared in the related PublicAPI.Unshipped.txt file. This repository uses git worktrees to work on multiple things at the same time. Worktrees live in ../vstest-tree/<branch> relative…
- Deletes or force-pushes
- Commits and pushes
In this repository7 other files it gives its agents.
- AGENTS.mdAGENTS.md
- eng/common/AGENTS.mdAGENTS.md
- creating-skillsSkill
- expert-reviewingSkill
- trx-analysisSkill
- validate-skillsSkill
- vstest-build-testSkill
The file
Show its rules and text
We split this copilot-instructions.md into the rules it gives an agent
26 rules. About 0 are common, 13 are distinctive, and 13 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈13
Distinctive · estimate
This author's own choices. Worth a look.
13
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Distinctive: line 10
Prefer file-scoped namespace declarations and single-line using directives.
- Distinctive: line 11
Ensure that the final return statement of a method is on its own line.
- Distinctive: line 12
Use pattern matching and switch expressions wherever possible.
- Very specific: line 13
Use nameof instead of string literals when referring to member names.
- Very specific: line 14
Always use is null or is not null instead of == null or != null.
- Very specific: line 16
Prefer ?. if applicable (e.g.
- Very specific: line 17
Use ObjectDisposedException.ThrowIf where applicable.
- Distinctive: line 56
Add a corresponding entry in the localization resource file.
- Very specific: line 57
Add an entry in all *.xlf files related to the modified .resx file.
- Very specific: line 58
Do not modify existing entries in '*.xlf' files unless you are also modifying the corresponding .resx file.
- Distinctive: line 62
When working autonomously on issues (e.g.
- Distinctive: line 71
Create a feature branch from main (never commit to main directly).
- Very specific: line 77
Check git remote -v to identify which remote is the fork (has the user's name in the URL, e.g.
- Very specific: line 79
Create the PR against microsoft/vstest (the upstream repo) — never PR to the fork.
- Distinctive: line 80
Do not create draft PRs — undrafting forces a re-build.
- Very specific: line 86
Check both CI status (pass/fail) and mergeable state — PR checks can show green even when there are merge conflicts.
- Distinctive: line 87
When a build fails, take hints from the automated PR review comments but reason about them — the reviewer is automated and may be wrong.
- Distinctive: line 88
If a build fails, investigate the failure, push a fix to the same branch, and wait for the rebuild.
- Very specific: line 89
If a PR becomes CONFLICTING, rebase the branch onto main and force-push using --force-with-lease (e.g.
- Distinctive: line 90
When a PR is fully green (all checks pass, no conflicts), mark it as ready to merge.
- Very specific: line 94
If a build fails with warnings treated as errors (e.g.
- Distinctive: line 116
After any change that adds/removes files from nupkgs or changes DLL target frameworks:
- Very specific: line 120
Update eng/expected-nupkg-file-counts.json from the fresh build
- Distinctive: line 123
Never manually edit these JSON files — always regenerate them.
- Distinctive: line 130
Never force-push PR branches — use normal commits and squash-merge at the end.
- Very specific: line 136
Do not modify existing xlf entries unless you are also modifying the corresponding .resx entry.
≈ “Common” is an estimate: at least 1 in 5 of the 1,644 Copilot instructions files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
This is a .NET based repository that contains the VSTest test platform. Please follow these guidelines when contributing:
Code Standards
You MUST follow all code-formatting and naming conventions defined in .editorconfig.
In addition to the rules enforced by .editorconfig, you SHOULD:
- Favor style and conventions that are consistent with the existing codebase.
- Prefer file-scoped namespace declarations and single-line using directives.
- Ensure that the final return statement of a method is on its own line.
- Use pattern matching and switch expressions wherever possible.
- Use
nameofinstead of string literals when referring to member names. - Always use
is nulloris not nullinstead of== nullor!= null. - Trust the C# null annotations and don't add null checks when the type system says a value cannot be null.
- Prefer
?.if applicable (e.g.scope?.Dispose()). - Use
ObjectDisposedException.ThrowIfwhere applicable. - Respect StyleCop.Analyzers rules, in particular:
- SA1028: Code must not contain trailing whitespace
- SA1316: Tuple element names should use correct casing
- SA1518: File is required to end with a single newline character
You MUST minimize adding public API surface area but any newly added public API MUST be declared in the related PublicAPI.Unshipped.txt file.
Working with Git Worktrees
This repository uses git worktrees to work on multiple things at the same time. Worktrees live in ../vstest-tree/<branch> relative to the main clone at c:\p\vstest.
The following global git aliases are configured:
git config --global alias.wta '!f() { mkdir -p "$(git rev-parse --show-toplevel)/../vstest-tree" 2>/dev/null; git worktree add -b "$1" "../vstest-tree/$1"; }; f'
git config --global alias.wtr '!f() { git worktree remove "../vstest-tree/$1"; }; f'
git config --global alias.wtl '!f() { git worktree list; }; f'Usage:
git wta my-feature-branch # creates c:\p\vstest-tree\my-feature-branch
git wtl # list all active worktrees
git wtr my-feature-branch # remove worktree when doneThe upstream remote upstream points to https://github.com/microsoft/vstest. To sync with upstream:
git fetch upstream
git checkout main
git merge upstream/mainLocalization Guidelines
Anytime you add a new localization resource, you MUST:
- Add a corresponding entry in the localization resource file.
- Add an entry in all
*.xlffiles related to the modified.resxfile. - Do not modify existing entries in '*.xlf' files unless you are also modifying the corresponding
.resxfile.
Unattended Work Instructions
When working autonomously on issues (e.g. from a milestone), follow this workflow:
Before Starting
- Assign the issue to the user you are working on behalf of before starting work.
- Skip issues with active PRs — if an issue already has a PR with recent activity, don't duplicate the work.
Implement
- Create a feature branch from
main(never commit tomaindirectly). - Implement the change and write tests where applicable.
- Build locally to validate the change compiles. Debug configuration is fine for local builds.
Create PR
- Check
git remote -vto identify which remote is the fork (has the user's name in the URL, e.g.github.com/<user>/vstest) and which is the upstream repo (github.com/microsoft/vstest). - Push the branch to the fork remote.
- Create the PR against
microsoft/vstest(the upstream repo) — never PR to the fork. - Do not create draft PRs — undrafting forces a re-build.
Monitor PRs
- CI pipeline skips builds for doc-only changes (e.g.
.mdfiles) — these PRs go green in under a minute. - For code changes, check PR status within 15–20 minutes — the Windows build and tests finish first, macOS/ubuntu take longer.
- Check both CI status (pass/fail) and mergeable state — PR checks can show green even when there are merge conflicts. Always verify with
gh pr view <number> --json mergeable. - When a build fails, take hints from the automated PR review comments but reason about them — the reviewer is automated and may be wrong.
- If a build fails, investigate the failure, push a fix to the same branch, and wait for the rebuild.
- If a PR becomes CONFLICTING, rebase the branch onto
mainand force-push using--force-with-lease(e.g.git push --force-with-lease). - When a PR is fully green (all checks pass, no conflicts), mark it as ready to merge.
Troubleshooting
- If a build fails with warnings treated as errors (e.g. IDE0005 unnecessary using), and you cannot reproduce locally, try building with
-c Releaseto match CI:./build.cmd -c Release.
vstest-Specific Knowledge
These are hard-won lessons from past work. Read them before making changes.
Assertions
Assert.Contains(expected, actual)— the first parameter is the needle (substring to find), the second is the haystack (string to search in). This is the opposite of oldStringAssert.Contains. Getting this wrong is a recurring mistake.
Binding Redirects
- vstest ships net462 assemblies that run in hosts without binding redirects (e.g. DTA — Distributed Test Agent).
- Bumping a
netstandard2.0package (e.g.System.Collections.Immutable) can pull in newer versions of transitive dependencies (System.Memory,System.Buffers,System.Runtime.CompilerServices.Unsafe). Each of these needs a binding redirect. - Binding redirects must be added to all three app.configs:
src/vstest.console/app.configsrc/testhost.x86/app.configsrc/datacollector/app.config
- The canonical test for binding redirect correctness is the DtaLikeHost pattern: a net472 exe that loads
Common.dllwithout binding redirects and asserts exit code 0.
Package Verification
After any change that adds/removes files from nupkgs or changes DLL target frameworks:
- Clean the
artifacts/directory completely - Build with
-c Release -pack - Update
eng/expected-nupkg-file-counts.jsonfrom the fresh build - Update
eng/expected-dll-frameworks.jsonfrom the fresh build
Never manually edit these JSON files — always regenerate them.
CI and Testing
- CI runs on Azure DevOps, not GitHub Actions. Build with
-c Releaseto match CI behavior. DOTNET_ROLL_FORWARD=LatestMajormasks version mismatches between your local SDK and CI. Always test on the CI runtime version, not with roll-forward.- Tests that pass locally but fail in CI often involve assembly version mismatches or TFM-specific behavior.
- Never force-push PR branches — use normal commits and squash-merge at the end.
Localization
Unlike some .NET repos where *.xlf files are auto-generated by building:
- In vstest, you MUST manually add entries to all
*.xlffiles related to a modified.resxfile. - Do not modify existing xlf entries unless you are also modifying the corresponding
.resxentry.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

