Repository navigation
Description
Summary
Public indexers on test classes are included in generated property metadata even though its getter accepts only an instance and no index arguments. This emits an invalid named-property access for closed classes and can make overloaded indexers ambiguous during metadata initialization. Test classes should be able to declare indexers without breaking discovery.
Reproduction
Add a test class to a TUnit test project:
public class IndexerTests
{
public string this[int index] => index.ToString();
[Test]
public void Runs() { }
}Build the project and inspect the generated property metadata getter. Also cover generic classes with indexers and two overloaded indexers.
Expected and actual
Expected: omit indexers from property metadata, or define deliberate supported behavior that supplies index arguments. Actual: both property enumeration paths select all public IPropertySymbol members without checking IsIndexer, and GetPropertyAccessor emits a named access without arguments. ReflectionInfo also resolves by name (and sometimes return type) without index parameter types.
Source: MetadataGenerationHelper.cs. The same enumeration is present on main as checked on 2026-11-03. This predates #7524 and was identified while dispositioning its non-blocking review.
Environment
Source commit 60669d5; confirmed by source inspection, reproduction not run locally.
Please handle indexers consistently across metadata collection modes and add generator regression coverage.
Acceptance criteria
- Exclude indexers from both generated property-metadata enumeration paths while preserving ordinary public property metadata and its counts.
- Add generator regression snapshots for non-generic classes, generic classes, and overloaded indexers; generated code must compile and metadata initialization must not throw an ambiguous-property exception.
- Verify the regression fixtures discover and execute in both source-generated and reflection modes.
Triage clarification
Confirmed by source inspection on main at ed2b2ab2366c6e7d8eaaf5b0d48307340ebc0140: both enumeration paths still include indexers. #7524 changes generic getter generation but does not filter indexers, so it does not supersede this issue. Reflection discovery's broader missing class-property metadata is tracked separately in #7522; fixing that gap is not a prerequisite for filtering generated indexers here. No reproduction was run during triage.
Activity
Exclude indexers from generated class property metadata (#7531) (#7560)