feat: Skip LSP server startup for non-SDK projects#79
Open
daviburg wants to merge 9 commits into
Open
Conversation
There was a problem hiding this comment.
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
.csprojfiles for Connector SDKPackageReferences 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.jsonlookup logic.
- 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
- 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
- Use case-insensitive regex matching PackageReference Include/Update attributes - Avoids false positives from substring matches in comments/metadata - Handles case-insensitive NuGet package IDs
- Add guidance message when inactive (restart command / reload) - Cap findFiles to maxResults=50 for large monorepos - Make SDK_PACKAGE_NAMES immutable with as const
- Fail-open when maxResults cap (50) is reached in findFiles - Support single-quoted XML attribute values in PackageReference regex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.csprojfiles for aPackageReferencetoAzure.Connectors.SdkorMicrosoft.Azure.Connectors.Sdkbefore starting the LSP server.Behavior
connectorSdk.lspServerPathexplicitly set: always activates (dev mode override)What's unchanged
package.jsonactivation events (onLanguage:csharp,workspaceContains:**/*.csproj)Additional cleanup
SDK_PACKAGE_NAMEconstant replaced withSDK_PACKAGE_NAMESarray to support both current and legacy package names in the existingfindSdkFromProjectAssetslogic as well