Field-targetted Attributes for Auto-Properties

Topics: C# Language Design
Apr 10, 2014 at 12:01 AM
Since we're talking about extending the love to auto-properties can we add the ability to target attributes to the compiler-generated backing-field for an auto-property?
public class Foo
{
    [field:  NonSerialized]
    public int X { get; set; }
}
This would also make auto-properties more consistent with the syntax for events, which have had this capability since C# 1.0:
public class Foo
{
    [field:  NonSerialized]
    public event EventHandler Bar;
}
UserVoice
Coordinator
Apr 14, 2014 at 11:26 PM
Yes. This is actually planned. We thought it was such a small feature that we left it off the lists, but we intend to allow this.
Marked as answer by madst on 4/14/2014 at 4:26 PM