[Repo Assist] fix: resolve implementation assembly when decompiling reference assemblies#1490
Draft
github-actions[bot] wants to merge 4 commits intomainfrom
Draft
Conversation
…blies When go-to-definition resolves a symbol to a .NET reference assembly (e.g. from packs/Microsoft.NETCore.App.Ref/*/ref/*/), ILSpy decompiles stub bodies as `throw null` because reference assemblies only contain metadata signatures. This change adds implementation assembly lookup before decompiling: 1. NuGet ref->lib: if the assembly is in a `ref` folder, try the corresponding `lib` folder (used by some NuGet packages that ship both reference and implementation assemblies). 2. Targeting pack->shared SDK: maps .../packs/[packName]/[version]/ref/[tfm]/[dll] to .../shared/[sdkName]/[version]/[dll] by reading the pack's FrameworkList.xml to get the SDK name. This covers all .NET SDK targeting packs (Microsoft.NETCore.App.Ref, Microsoft.AspNetCore.App.Ref, etc.). If no implementation assembly is found the original path is used, so there is no regression for assemblies that don't have a counterpart. Closes #486 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Member
|
/repo-assist can you add tests for it please |
10 tests covering: - NuGet ref→lib heuristic (4 cases: no ref segment, lib absent, lib present, ref in package name) - Targeting-pack → shared-SDK heuristic (5 cases: not in packs, missing xml, empty FrameworkName, impl absent, impl present) - Priority: NuGet lib preferred over shared-SDK when both exist Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
Author
|
Commit pushed:
|
Contributor
Author
|
🤖 This is an automated response from Repo Assist. Done! I've added 10 unit tests for Tests added:
All 10 tests pass (
|
Member
|
@baronfel what do you think about this? |
14 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 is an automated PR from Repo Assist.
Summary
Fixes the
throw nullstub bodies shown in go-to-definition decompiled output for .NET reference assemblies. Reference assemblies (found in the SDKpacks/*/ref/directories) only contain metadata signatures — ILSpy faithfully decompiles them withthrow nullas each method body.Root cause:
tryFindExternalDeclarationinDecompiler.fsused the assembly path returned by FCS directly. For .NET SDK symbols, FCS resolves to the reference assembly (e.g.packs/Microsoft.NETCore.App.Ref/8.0.6/ref/net8.0/System.Runtime.dll), not the implementation assembly.Fix
Added two path-based heuristics (following Roslyn's
ImplementationAssemblyLookupService) to find the actual implementation assembly before decompiling:1. NuGet ref→lib (
tryNugetLibFromRef)For NuGet packages that ship separate reference and implementation assemblies: replaces the
refpath segment withlib.This covers
Microsoft.NETCore.App.Ref,Microsoft.AspNetCore.App.Ref, and any other targeting packs following the standard layout.If no implementation assembly is found the original path is used unchanged — no regression for assemblies without a counterpart.
Changes
src/FsAutoComplete.Core/Decompiler.fs: AddedtryNugetLibFromRef,trySharedSdkFromTargetingPack, andtryFindImplementationAssemblyhelper functions; modifiedtryFindExternalDeclarationto resolve to the implementation assembly.Test Status
dotnet build src/FsAutoComplete.Core/FsAutoComplete.Core.fsproj -c Release— succeeds, 0 warnings, 0 errors/usr/share/dotnet/packs/Microsoft.NETCore.App.Ref/8.0.6/ref/net8.0/System.Runtime.dll→/usr/share/dotnet/shared/Microsoft.NETCore.App/8.0.6/System.Runtime.dll✓Closes #486