Skip missing session assemblies when navigating on launch - #3790
Merged
Conversation
Navigating to a target on startup first eagerly loads every relevant assembly's metadata so the entity search that follows can resolve it. That pre-load used the throwing GetMetadataFileAsync, so a restored session that still referenced an assembly whose file had since been deleted or moved crashed startup with an unhandled DirectoryNotFoundException instead of simply skipping the gone entry. Use GetMetadataFileOrNullAsync there: a missing or unreadable assembly now resolves to null and is skipped, which the entity search already tolerates (it uses the OrNull variant too). Assisted-by: Claude:claude-opus-4-8:Claude Code
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.
Problem
Launching ILSpy with a navigation target (
--navigateto/-n, or the VS add-in IPC path) crashes at startup with an unhandledDirectoryNotFoundExceptionwhen the restored session still references an assembly whose file has since been deleted or moved:NavigateOnLaunchAsynceagerly pre-loads every relevant assembly's metadata before resolving the target. When no assembly is passed positionally, "relevant" is the whole restored session list, so a single gone file aborts the entire launch. (Passing an assembly on the command line masks it, because then only that one assembly is relevant.)Fix
Use the non-throwing
GetMetadataFileOrNullAsync()in the pre-load loop (both theN:namespace branch and the type/member branch). A missing or unreadable assembly now resolves tonulland is skipped; the subsequent entity search already toleratesnull(it usesGetMetadataFileOrNull()), so a still-present navigation target resolves as before.Test
Adds a headless regression test that injects a session assembly whose file does not exist, then navigates on launch and asserts the launch completes without throwing and the present target (
System.Linq.Enumerable) is still selected. The test fails (reproducing theDirectoryNotFoundException) before the fix and passes after. FullILSpy.Testssuite green.🤖 Generated with Claude Code