dotnet / dotnet/csharpstandard
IndexerNameAttribute should affect reserved member names
- Dominant language
- C#
- Stars
- 815
- Forks
- 99
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 16
Description
**Describe the bug**
C# 7 §15.3.10.4 (Member names reserved for indexers) says that specific signatures of get_Item and set_Item are reserved, and that Item is a reserved member name, when the class has an indexer. However, if the indexer has an IndexerNameAttribute, then the name given in that attribute should be reserved instead of Item.
**Example**
```csharp
using System.Runtime.CompilerServices;
public class C {
[IndexerName("Slot")]
int this[int i] => 0;
// The standard says that get_Item is a reserved member name,
// and that declaring it here causes a compile-time error.
// It should not be reserved in this case.
int get_Item(int i) => 1;
// Instead, get_Slot should be reserved.
//int get_Slot(int i) => 2;
}
```
**Expected behavior**
The example should not cause a compile-time error.
§15.3.10.4 (Member names reserved for indexers) should say that IndexerNameAttribute has this effect.
**Additional context**
Inspired by .
IndexerNameAttribute is referenced under §22.5.5.4 (The CallerMemberName attribute):
And in §C.2 (Standard Library Types defined in ISO/IEC 23271):
Contributor guide
Assessment
This issue has not been assessed yet.