AsmResolver icon indicating copy to clipboard operation
AsmResolver copied to clipboard

Method analyzer doesn't locate override implementations when layered

Open 0xInception opened this issue 4 years ago • 0 comments

Describe the bug

Using feature/workspaces DotNetWorkspace to analyze an abstract method should find all of the direct implementations, but only looks for types that implement the abstract method's declaring type.

To Reproduce

using System;
using System.Linq;
using AsmResolver.DotNet;
using AsmResolver.Workspaces.DotNet;

var path = "Issue.dll";
var module = ModuleDefinition.FromFile(path);

var workspace = new DotNetWorkspace();
workspace.Assemblies.Add(module.Assembly);
workspace.Analyze();

var type = module.TopLevelTypes.First(d=>d.Name == "TestAbstractClass");
var method = type.Methods.First(d => d.Name == "TestAbstractBool");
            
var node = workspace.Index.GetOrCreateNode(method);
var impls = node.BackwardRelations.GetObjects(DotNetRelations.ImplementationMethod).ToArray();
foreach (var impl in impls)
{
   Console.WriteLine(impl.DeclaringType.Name);
}
Console.WriteLine(impls.Length == 3);

Issue.zip

Proposal

Should perhaps look recursively for the types that implement the abstract method's declaring type

Screenshots

2021-09-02_23-15

Platform

  • OS: Linux
  • AsmResolver Version: feature/workspaces branch

0xInception avatar Sep 02 '21 20:09 0xInception