Skip to content

[Feature]: C#: interface dispatch stops at the interface when there is more than one implementer, and property access through an interface is not linked #3800

Closed

Description

@ThatAblaze

Problem or use case

Related to #3003. Once a call has reached an interface member, a walk only continues to the
implementation when the interface has exactly one implementer. With two or more, the graph
stops at the interface, which is where most interfaces in practice sit. Reading a property through
an interface-typed receiver produces no edge at all.

Repro, one file, Conn.cs:

namespace Demo
{
    public interface IConnecter { void Read(); int Count { get; } }

    public class Effect : IConnecter
    {
        public void Read() { }
        public int Count => 0;
    }

    public class Property : IConnecter
    {
        public void Read() { }
        public int Count => 1;
    }

    public class User
    {
        public void Go(IConnecter c)
        {
            c.Read();
            int n = c.Count;
        }
    }
}

Actual:

conn_demo_user_go --references--> conn_demo_iconnecter
conn_demo_user_go --calls-->      conn_demo_iconnecter_read

No dispatches_to from IConnecter.Read() to either implementation, and nothing for c.Count.

Proposed solution

  1. dispatches_to from an interface member to the same-named member of every implementing
    type (and subclasses of one), explicit implementations included, with confidence: INFERRED
    and perhaps a score that falls with the implementer count. C#: a call through an interface dead-ends at the interface method, so injected dependencies cut every chain #3003's reasoning ("guessing among
    several implementers would not" mirror the runtime) is right for a single call site, but for a
    static structural graph the question is "what can this call reach", and the answer is all of
    them. Stopping at the interface answers "nothing".
  2. A calls edge (or a distinct relation such as accesses) from a method to an interface
    property it reads or writes through an interface-typed receiver. Property getters are method
    calls, and in interface-heavy code they are a large share of the traffic across the seam.
    Limiting this to interface receivers would keep it from flooding the graph with every
    obj.Name read.

Alternatives considered

No response

Area

Graph building or querying

Additional context

in a Unity codebase whose editor assembly may only reach the runtime through interfaces,
the busiest seam interface has three implementers and much of the editor's traffic through it is
property reads (Ed.DataOwner, Ed.EditorLayouts). A local post-pass doing exactly (1) and (2)
added about 170 member-level dispatch edges and 190 property-access edges to a ~120-file graph,
and made editor-to-implementation paths two hops long.

Activity

  1. added
    enhancement
    on Sep 24, 2026
  2. added a commit that references this issue on Oct 13, 2026
    e7395e6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions