-
Notifications
You must be signed in to change notification settings - Fork 92
Open
Description
Describe the bug
The standard does not specify what becomes the default value of a parameter decorated with CallerMemberAttribute when the parameter is on a constructor of an attribute, and a property or an indexer is decorated with this attribute. (The standard specifies this if an accessor of a property or indexer is so decorated.)
C# 9 draft section 23.5.6.4 The CallerMemberName attribute.
Example
using System;
using System.Runtime.CompilerServices;
public class MAttribute : Attribute {
public MAttribute(
[CallerMemberName]string? name = null) {
}
}
class C {
[M] object o = new MAttribute();
[M] object P {
[M] get => new MAttribute();
}
[M] object this[[M]int index] {
[M] get => new MAttribute();
}
[M] delegate void D<[M]T>();
}Expected behavior
Should be equivalent to:
class C {
[M(null)] object o = new MAttribute("o");
[M("P")] object P {
[M("P")] get => new MAttribute("P");
}
[M("Item")] object this[[M("Item")]int index] {
[M("Item")] get => new MAttribute("Item");
}
[M(null)] delegate void D<[M(null)]T>();
}Additional context
Noticed from #1548.
Metadata
Metadata
Assignees
Labels
No labels