Skip to content

Add single-word C# model name linter rule with AI-powered VS Code fixer#1

Draft
haiyuazhang wants to merge 1 commit into
haiyuazhang:mainfrom
m-nash:feature/csharp-model-name-fixer
Draft

Add single-word C# model name linter rule with AI-powered VS Code fixer#1
haiyuazhang wants to merge 1 commit into
haiyuazhang:mainfrom
m-nash:feature/csharp-model-name-fixer

Conversation

@haiyuazhang
Copy link
Copy Markdown
Owner

Adds a TypeSpec linter rule in @typespec/http-client-csharp that flags single-word model names (e.g. model Document) which collide with BCL or third-party types. The fix flow runs in the typespec-vscode extension:

  • Linter: detects single-word model names; also flags @@clientName overrides whose target string is a single word.
  • VS Code extension: adds a code action provider that offers two AI fixes via the lightbulb (Ctrl+.):
    1. Rename model directly (uses the language server rename provider so all references are updated).
    2. Override via @@clientName in client.tsp (creates client.tsp if missing, groups inserts after existing @@clientName lines, and auto-adds imports: - ./client.tsp to tspconfig.yaml so the compiler picks it up as a first-class source).
  • AI suggestions are fetched on demand via vscode.lm (no external SDK).
  • File watcher cleans up the tspconfig.yaml import and nudges open editors to recompile when client.tsp is deleted.
  • Adds a manual test workspace under packages/http-client-csharp/linter-test.

Adds a TypeSpec linter rule in @typespec/http-client-csharp that flags
single-word model names (e.g. `model Document`) which collide with BCL
or third-party types. The fix flow runs in the typespec-vscode extension:

- Linter: detects single-word model names; also flags `@@clientName`
  overrides whose target string is a single word.
- VS Code extension: adds a code action provider that offers two AI fixes
  via the lightbulb (Ctrl+.):
    1. Rename model directly (uses the language server rename provider so
       all references are updated).
    2. Override via `@@clientName` in client.tsp (creates client.tsp if
       missing, groups inserts after existing @@clientName lines, and
       auto-adds `imports: - ./client.tsp` to tspconfig.yaml so the
       compiler picks it up as a first-class source).
- AI suggestions are fetched on demand via vscode.lm (no external SDK).
- File watcher cleans up the tspconfig.yaml import and nudges open
  editors to recompile when client.tsp is deleted.
- Adds a manual test workspace under packages/http-client-csharp/linter-test.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown

❌ There is undocummented changes. Run chronus add to add a changeset or click here.

The following packages have changes but are not documented.

  • typespec-vscode
Show changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants