dotnet / dotnet/csharpstandard
IndexerNameAttribute identifier syntax requirement
- Dominant language
- C#
- Stars
- 815
- Forks
- 99
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 16
Description
**Describe the bug**
Roslyn gives "error CS0633: The argument to the 'IndexerName' attribute must be a valid identifier" if I do `[IndexerName("0")]`. However neither ECMA-334 nor ECMA-335 seems to require that the argument of the IndexerNameAttribute constructor be a valid identifier.
**Example**
```csharp
using System.Runtime.CompilerServices;
public class C {
[IndexerName("0")]
int this[int i] => 0;
}
```
**Expected behavior**
Specify that the argument of the IndexerNameAttribute constructor must be an identifier or a keyword. For example, `[IndexerName("true")]` is valid, but `[IndexerName("@true")]` is invalid.
**Additional context**
In ECMA-335 I.8.5.1 (Valid names), CLS Rule 4 references Annex 7 of Technical Report 15 of the Unicode Standard. However, C# generally allows code that does not follow CLS rules.
Contributor guide
Assessment
This issue has not been assessed yet.