Skip to content

feat: Skip LSP server startup for non-SDK projects#79

Open
daviburg wants to merge 9 commits into
Azure:mainfrom
daviburg:feature/scope-activation
Open

feat: Skip LSP server startup for non-SDK projects#79
daviburg wants to merge 9 commits into
Azure:mainfrom
daviburg:feature/scope-activation

Conversation

@daviburg
Copy link
Copy Markdown
Member

Closes #32

Problem

The extension activates on every C# workspace, starting the LSP server even for projects that don't use the Connector SDK. This wastes resources for the majority of C# developers who have the extension installed.

Fix

Added an early-exit guard in activate() that scans workspace .csproj files for a PackageReference to Azure.Connectors.Sdk or Microsoft.Azure.Connectors.Sdk before starting the LSP server.

Behavior

  • No SDK reference found: logs 'extension inactive', returns early (commands still registered)
  • SDK reference found: proceeds with normal LSP server startup
  • connectorSdk.lspServerPath explicitly set: always activates (dev mode override)

What's unchanged

  • package.json activation events (onLanguage:csharp, workspaceContains:**/*.csproj)
  • LSP server C# code
  • Command registrations (restart, connection view)

Additional cleanup

  • SDK_PACKAGE_NAME constant replaced with SDK_PACKAGE_NAMES array to support both current and legacy package names in the existing findSdkFromProjectAssets logic as well

Copilot AI review requested due to automatic review settings May 11, 2026 21:09
@daviburg daviburg requested a review from a team as a code owner May 11, 2026 21:09
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Reduces unnecessary resource usage by preventing the extension from starting the Connector SDK LSP server in C# workspaces that don’t reference the Connector SDK packages, while preserving a developer override via explicit LSP path configuration.

Changes:

  • Add an activation-time guard that scans workspace .csproj files for Connector SDK PackageReferences before starting the LSP server.
  • Support both current and legacy NuGet package names by switching from a single constant to an array.
  • Reuse the package-name list in existing project.assets.json lookup logic.

Comment thread vscode-extension/src/extension.ts Outdated
Comment thread vscode-extension/src/extension.ts Outdated
Comment thread vscode-extension/src/extension.ts Outdated
- Use vscode.workspace.fs.readFile for virtual workspace compat
- Log and fail-open on .csproj read errors instead of silently skipping
- Exclude bin/obj/.git/.vs from findFiles glob
@daviburg daviburg requested a review from Copilot May 11, 2026 22:32
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 4 comments.

Comment thread vscode-extension/src/extension.ts
Comment thread vscode-extension/src/extension.ts Outdated
Comment thread vscode-extension/src/extension.ts Outdated
Comment thread vscode-extension/src/extension.ts Outdated
- Log message now says 'Connector SDK' instead of specific package name
- Use TextDecoder instead of Buffer.from for VS Code API compat
- Log and continue on .csproj read errors instead of fail-open
- Precompute lowercased package prefixes in findSdkFromProjectAssets
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.

Comment thread vscode-extension/src/extension.ts
Comment thread vscode-extension/src/extension.ts Outdated
Comment thread vscode-extension/src/extension.ts
- Use case-insensitive regex matching PackageReference Include/Update attributes
- Avoids false positives from substring matches in comments/metadata
- Handles case-insensitive NuGet package IDs
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 4 comments.

Comment thread vscode-extension/src/extension.ts Outdated
Comment thread vscode-extension/src/extension.ts Outdated
Comment thread vscode-extension/src/extension.ts
Comment thread vscode-extension/src/extension.ts Outdated
- Add guidance message when inactive (restart command / reload)
- Cap findFiles to maxResults=50 for large monorepos
- Make SDK_PACKAGE_NAMES immutable with as const
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.

Comment thread vscode-extension/src/extension.ts Outdated
Comment thread vscode-extension/src/extension.ts Outdated
Comment thread vscode-extension/src/extension.ts
- Fail-open when maxResults cap (50) is reached in findFiles
- Support single-quoted XML attribute values in PackageReference regex
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment thread vscode-extension/src/extension.ts Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment thread vscode-extension/src/extension.ts Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment thread vscode-extension/src/extension.ts Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

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.

Scope extension activation to projects referencing Connector SDK

2 participants