Skip to content

Reflection import imports indexers as an "Item" member, interface property accessors as get_/set_ functions, and drops methods inherited from base interfaces #301

Closed

Description

@matt-edmondson

What's wrong

Three problems in Schema/Models/ClrTypeImporter.cs:

  • Indexers become members. Import (~L52) enumerates type.GetProperties(Public | Instance), and that list includes indexers. A class with public string this[int i] imports a member Item : String that the type doesn't actually have as data. Regenerating then emits a real Item property.
  • Interface property accessors become functions. ImportInterface (~L263) enumerates type.GetMethods(Public | Instance). For an interface with int Count { get; }, that list includes the compiler-generated get_Count, so the schema gains a function get_Count. Regenerating emits int get_Count();, and a hand-written implementation of the original interface no longer satisfies it.
  • Inherited interface methods are dropped. Type.GetMethods on an interface doesn't return methods inherited from base interfaces. For interface IDerived : IBase, only IDerived's own methods are imported. IBase.Ping disappears and nothing reports it.

Repro

  • AddClass(typeof(Indexed)), where Indexed has Name and an indexer, gives members Name and Item.

  • AddInterface(typeof(IDerived)), where:

    • IDerived : IBase declares int Count { get; } and void Pong()
    • IBase declares void Ping()

    gives functions get_Count and Pong. Ping is missing.

Suggested fix / acceptance criteria

  • Skip properties with GetIndexParameters().Length > 0.
  • Skip accessor methods where MethodInfo.IsSpecialName is true. Whether interface properties should later be imported, for example as query functions, or refused with a diagnostic is a separate decision.
  • Walk type.GetInterfaces() to pick up inherited methods, de-duplicating by name. Two inherited methods with the same name would collide in AddFunction, so report that case.
  • Add tests for all three cases in AddClassFromTypeTests and the AddInterface tests.

Severity is moderate: this only affects hand-written types. Generated C# never emits indexers, interface properties or interface inheritance.

Activity

  1. matt-edmondson commented on Oct 19, 2026

    @matt-edmondson
    ContributorAuthor

    Triage


    Generated by Claude Code

  2. added a commit that references this issue on Oct 20, 2026
    cec7f58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions