Repository navigation
Description
Summary
Class property metadata includes public indexers even though its getter delegate accepts no index arguments. Generated metadata emits ordinary property access for an indexer, which cannot compile; the reflection metadata implementation in PR #7550 invokes it without arguments and throws. Both discovery modes should handle indexers consistently.
Reproduction
Add a test fixture with a public indexer:
public class IndexerTests
{
public string this[int index] => index.ToString();
[Test]
public void Example() { }
}MetadataGenerationHelper.WritePropertyMetadataArray includes every declared public property, while GetPropertyAccessor emits ((IndexerTests)o).this[] instead of an indexed access. PR #7550 (closing #7522) adds reflection class metadata using p.GetValue(instance) without index arguments. Current main still leaves that reflection property array empty. This follows directly from the source; a dedicated compiler regression is still needed.
Expected and actual
Exclude indexers from class property metadata in both discovery modes; the existing getter API accepts no index arguments. Currently the metadata getter contract cannot represent them.
Environment
Inspected main at 10a0af7; .NET SDK 10.0.403. Source: https://github.com/thomhurst/TUnit/blob/10a0af7272/src/TUnit.Core.SourceGenerator/Utilities/MetadataGenerationHelper.cs#L347 and #L494.
Please add consistent indexer handling and regression coverage. Discovered while reviewing #7550.
Acceptance criteria
- Exclude public indexers from generated and reflection class property metadata while preserving ordinary public instance and static properties.
- Add a generator compiler/snapshot regression for a class with a public indexer.
- Verify metadata and ordinary property getters in both discovery modes, including a generic class, and preserve AOT compatibility.
Triage at main 4891fce71adee5d0d66e19c9fc20a367b9cca1e9: the generator still includes indexers. Complete this follow-up after #7522 so regression coverage exercises the populated reflection metadata introduced by #7550.
Activity