[Repo Assist] fix: skip auto test discovery on workspace load when no test projects exist#2153
Draft
github-actions[bot] wants to merge 2 commits intomainfrom
Conversation
… exist Fixes #2111 When a workspace is loaded and contains no test projects (e.g. a solution with only non-test projects, or an empty solution), Ionide previously attempted auto-discovery unconditionally, triggering a 'No test projects found' error notification from FsAutoComplete even though this was expected. This change adds a guard in the workspaceLoaded handler so that discoverTests_WithLanguageServer is only called when at least one test project (identified by a Microsoft.NET.Test.Sdk or Microsoft.TestPlatform.TestHost package reference) is present in the loaded workspace. The existing explicit refresh flow (via the refresh button or command) is unaffected and still discovers tests on demand. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
39 tasks
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.
🤖 This PR was created by Repo Assist, an automated AI assistant.
Summary
Closes #2111
Prevents a spurious "No test projects found. Make sure you've restored your projects" error when opening a workspace that contains no F# test projects (e.g., an empty solution or a solution with only non-test projects).
Root Cause
When the workspace finishes loading and
FSharp.TestExplorer.AutoDiscoverTestsOnLoadistrue(the default), Ionide callsdiscoverTests_WithLanguageServerunconditionally. This causes FsAutoComplete to run its test discovery pipeline even when there are zero test projects in the workspace, which results in a misleading error notification.Fix
In the
workspaceLoadedhandler for the language-server discovery path, check whether any test projects are present (using the sameProjectExt.isTestProjectpredicate used elsewhere inTestExplorer.fs) before initiating discovery. If no test projects exist, the call is silently skipped.The on-demand refresh flow (via the refresh button or F# commands) is unaffected — it still runs discovery unconditionally, which is correct since the user explicitly requested it.
Trade-offs
workspaceLoadedfires, they could be missed. However,Project.workspaceLoadedfires after projects are loaded, soProject.getLoaded()should be accurate at that point. This matches the same assumption made in the existingrefreshHandlerpath at line 2109.Test Status
✅ Build succeeded (
dotnet run --project build -- -t Build). No test failures introduced.