-
Notifications
You must be signed in to change notification settings - Fork 66
Description
Trying to eliminate some redundancy (and work) when declaring expanded properties. I propose that given this declaration:
Property P As T
Get
End Get
Set(value As T)
End Set
End PropertyThere is an implicit backing field named _P of type T that is property scoped (see #195).
- It is only created if no field of that name exists already.
- It is only emitted if it's referred to in either the getter or the setter.
So nothing would change about existing property declarations today but this broken code (assuming no field _P actually exists):
Property P As T
Get
Return _P
End Get
Set(value As T)
_P = value
End Set
End PropertyWould compile under this proposal. This eliminates repeating the name P and the type T which makes changing both much easier. We could use a magic keyword to mean "the implicit backing field" like Field or _Value but why go through all of that when the convention for backing fields is pretty well known. Also, we want the maintain the convention that we use for auto-prop backing fields for binary serialization reasons. Convention over Configuration FTW!