Repository navigation
Conversation
…riable A Visual Basic `Catch` without an exception variable (`Catch`, or `Catch When condition`) has no IdentifierName, and ScipVisualBasicSyntaxWalker.VisitCatchStatement read node.IdentifierName.Identifier unconditionally. The resulting NullReferenceException ended the whole index, so no project containing a bare `Catch` could be indexed. The definition occurrence is now recorded only when the Catch declares a variable. Statements.vb in the syntax snapshot gains a `Catch When` and a bare `Catch`; without the fix, the syntax snapshot test fails with the exception.
With no path given, `scip-dotnet index` takes every solution and project file in the working directory as a root, in the order Directory.GetFiles returns them, which depends on the file system. A project file in the same directory as the solution that includes it was handled in one of two ways: - After the solution (the order seen on Linux): OpenProjectAsync threw "'<name>' is already part of the workspace", which ended the whole index. - Before the solution (the order seen on macOS): opening the solution afterwards loaded the project again under a new ProjectId, which indexedProjects did not recognize, so every document of the project appeared twice in the index. FindSolutionOrProjectFile now lists solutions before project files, each in name order. IndexProject no longer opens a project file that the workspace already holds: it uses the loaded project, which indexedProjects then skips because the solution indexed it, and it skips `dotnet restore` for it. The new project-beside-solution snapshot holds ProjectBesideSolution.sln and ProjectBesideSolution.csproj in one directory. With the new order but without the IndexProject change, its test fails with "'ProjectBesideSolution(net10.0)' is already part of the workspace".
This branch has not been deployed
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 fixes two failures that came up while indexing real VB.NET repositories with scip-dotnet 0.2.14. Both are still present on main. Each fix is its own commit with its own snapshot test.
1. A
Catchwithout an exception variable crashes the Visual Basic walkerScipVisualBasicSyntaxWalker.VisitCatchStatementreadsnode.IdentifierName.Identifier. ACatchthat declares no variable (Catch, orCatch When condition) has noIdentifierName, so the walker throws and the whole index fails:A bare
Catchis common in VB code (jamesplotts/simpleide has 36, and DualBrain/bsharp usesCatch When), so such projects cannot be indexed at all. The fix records the definition occurrence only when theCatchdeclares a variable.Test:
snapshots/input/syntax/VBMain/Statements.vbgains a method with aCatch Whenand a bareCatch. On main, thesyntaxsnapshot test fails with the exception above. (The snapshot comparison only diffs.csoutputs, so for Visual Basic the test catches this through the indexer's exit code.)2. A project file beside its solution crashes the index or is indexed twice
With no path given,
scip-dotnet indextakes every.sln,.slnx,.csprojand.vbprojfile in the working directory as a root, in the orderDirectory.GetFilesreturns them. That order depends on the file system. When a solution and its project file are in the same directory (for exampleSimpleIDE.slnbesideSimpleIDE.vbproj):OpenProjectAsyncon the project file throws'SimpleIDE' is already part of the workspace.and the index fails.ProjectId.indexedProjectsdoes not recognize it, so every document of the project appears twice in the index.The fix has two parts:
FindSolutionOrProjectFilelists solutions before project files, each in name order, so the order no longer depends on the file system.IndexProjectdoes not open a project file that the workspace already holds. It uses the loaded project instead, which the existingindexedProjectscheck then skips because the solution indexed it.dotnet restoreis skipped for it as well.Test: the new
snapshots/input/project-beside-solutionholdsProjectBesideSolution.slnandProjectBesideSolution.csprojin one directory. With the new order but without theIndexProjectchange, its test fails with'ProjectBesideSolution(net10.0)' is already part of the workspace.On main, the result depends on the file system: on macOS the test passes, but the index holds every document of the project twice.Verification
On macOS (arm64), with the .NET SDKs 10.0.402, 9.0.319 and 8.0.426:
dotnet test -p:TargetFrameworks=net10.0,net9.0andnet8.0pass. The new snapshot outputs were generated with each of the three.dotnet format --verify-no-changespasses at the root, insnapshots/input/syntax, and forsnapshots/input/project-beside-solution/ProjectBesideSolution.sln.