Skip to content
| Marketplace
Sign in
Visual Studio Code>Linters>CP Reuse HintsNew to Visual Studio Code? Get it now.
CP Reuse Hints

CP Reuse Hints

Prarthana R Karanth

| (0) | Free
Inline hints that show when the code you write already exists in CP.Test.Automation: constants, locators, page methods and DI registrations, with links to the existing code.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

CP Reuse Hints

Catch duplicates while you type, not in the pull request.

CP Reuse Hints watches the C# you add or change in CP.Test.Automation and shows a short hint at the end of the line when the same thing already exists in the repo. Hover the hint to see every existing location as a link that jumps to the exact line.


● What Makes It Useful

Most review comments on automation PRs read the same: "use the existing method", "this is a duplicate", "use the constant". Experienced teammates know what already exists in the codebase. Everyone else finds out after the PR is raised.

CP Reuse Hints puts that knowledge in the editor, at the moment you write the line.

await _page.GetByText("Client ID").ClickAsync();          ↳ use Constants.CLIENTID
private ILocator _x => _page.Locator("[role='alert']");    ↳ selector already used in ClientPortalDocumentsPage.cs, ClientPortalSendFilesPage.cs +16 more
public async Task EnterAccessCodeAsync(string code)        ↳ EnterAccessCodeAsync also exists in ClientPortalFolderDropOffPage.cs +5 more - check before adding

● Key Features

● Constants

  • Hardcoded text that already has a constant: exact match or differing only in letter case, with a one-click replace (Ctrl+.).
  • Duplicate constants: a new constant whose value already exists under another name.

● Locators

  • Selector already used elsewhere: lists the page classes that already use it.
  • Same locator defined twice in one page: flagged on the second definition.
  • Inline locator that is already a field: suggests the existing field, with a one-click replace.

● Page methods

  • Method name already exists in other page classes.
  • Same method body: identical, or about 85% or more similar, to another page method, even under a different name.

● Dependency injection

  • Page class not registered in Startup.cs: class X : IX without a matching AddScoped<IX, X>().

● Navigation

  • Clickable locations: the hover lists every existing location and each link opens the exact line.
  • Status bar counter: Reuse hints: N for the current file. Click it, or press Ctrl+Alt+H, to list the flagged lines and jump to one.

● Stays out of your way

  • Only your changes are flagged: hints appear on lines you added or changed (git diff against HEAD), so older code does not light up.
  • Silence a line with // reuse-ignore at the end of the line or on the line above.
  • Switch rules on or off individually in Settings.

● Perfect For

  • New joiners who do not yet know what already exists in the repo
  • Anyone adding page methods, locators or constants, to reuse before writing
  • Pull-request authors who want fewer "use the existing one" review comments
  • Reviewers, who spend less time on duplicates and more on logic

● Configuration

Works out of the box. Optional settings:

{
  "reuseHints.scope": "changedLines",
  "reuseHints.rule.useConstantIgnoreCase": false,
  "reuseHints.rule.similarMethod": true
}
Setting Default Description
reuseHints.enabled true Show inline reuse hints in C# files
reuseHints.scope changedLines changedLines (recommended) or allLines (audit a whole file)
reuseHints.rule.* true One switch per rule: useConstant, useConstantIgnoreCase, duplicateConstant, duplicateLocator, duplicateLocatorInFile, useLocatorField, similarMethod, sameBodyMethod, missingRegistration

● Commands

Command Shortcut What it does
Reuse Hints: List hints in this file Ctrl+Alt+H Lists the flagged lines and jumps to the one you pick
Reuse Hints: Toggle changed lines / all lines Switches between the two scopes
Reuse Hints: Rebuild index Re-reads the repo (also happens when you save a .cs file)

● Getting Started

  1. Install CP Reuse Hints from the VS Code Marketplace: open the Extensions panel, search for CP Reuse Hints, and click Install.
  2. Open the CP.Test.Automation folder and any .cs file. The first hints can take a couple of seconds while the repo is indexed.
  3. Write or edit code as usual. Hints appear at the end of the lines you changed.
  4. Hover a hint for the existing locations, or press Ctrl+. for a quick fix.

● Requirements

  • The folder open in VS Code is the CP.Test.Automation repository.
  • git is available on your PATH (used to find the lines you changed).

● What It Does Not Do

  • It reads C# files only, not .feature files.
  • It compares names, text and code shape. It cannot tell that two methods with different names do the same job, so a human reviewer is still needed for that.
  • Hints are advice. Nothing changes unless you accept a quick fix.

● Development

  • core.js: matching logic, no VS Code dependency.
  • extension.js: editor integration.
  • node test.js <path to CP.Automation.Tests>: runs the checks against the real repo.
  • node media/make-icon.js: regenerates the icon.
  • npx @vscode/vsce package: builds the .vsix.

● Author

Built by Prarthana R Karanth.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft