Adds dynamic NuGet package resolution via #:package directives for C# file-based apps - #199
Open
ashar-builds wants to merge 5 commits into
Open
Adds dynamic NuGet package resolution via #:package directives for C# file-based apps#199ashar-builds wants to merge 5 commits into
ashar-builds wants to merge 5 commits into
Conversation
Introduce PackageRef and extend Closure to track package references. Update DocumentClosure to parse and collect #:package directives. Enhance WorkspaceManager to resolve NuGet packages using a temp MSBuild project and dotnet restore, integrating references into Roslyn projects. Track and update package references per document on live edits. Update tests and method signatures to support root text and package handling.
Added ResolveCompletion_with_empty_span_skips_primary_edit_in_additional_edits unit test to WorkspaceManagerFeatureCoverageTests. This test verifies that when completion is triggered on an empty span (e.g., after a dot), the primary edit is skipped in AdditionalEdits, preventing redundant insertion of completion text. Ensures correct behavior for cases like "ToString" completion.
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.
TLDR
Adds dynamic NuGet package resolution via
#:packagedirectives for C# file-based apps and fixes a double-insertion bug for zero-length completion spans.Details
1. Support for
#:packageDirectives:WorkspaceManager.SingleFile.csandWorkspaceManager.cs.#:packagedirective is encountered in a C# script or file-based app, the sidecar generates a temporary.csproj, executes a backgrounddotnet restore, and extracts thePortableExecutableReferences to load into theAdhocWorkspace.UpdateProjectlessClosureAsyncto support real-time graph and package updates. As the user edits the document, new packages and included files are seamlessly resolved and injected into the active solution.2. Autocomplete Double-Insertion Fix:
ComputeCompletionEditSpanoverlap logic: ReplacedOverlapsWithwithIntersectsWithinWorkspaceManager.Helpers.cs..) were failing the overlap check, causing the primary text edit to be incorrectly appended to theAdditionalEditsarray alongside the main edit.src/semantic.rsandWorkspaceManager.Helpers.csto ensure standard LSP completion mechanisms are maintained without strippinginsert_textorfilter_text.How Do The Automated Tests Prove It Works?
ResolveCompletion_with_empty_span_skips_primary_edit_in_additional_editstoWorkspaceManagerFeatureCoverageTests.cs. This test simulates the exact bug scenario by triggering completion at a 0-length span immediately following a dot (result.). It asserts that the primary completion edit (e.g., "ToString") is successfully filtered out and does not appear in theAdditionalEditsarray.