Current syntax for extensions on a reference type...
public static class PersonExtensionClass
{
public string FullName(this Person person)
{
return $"{person.FirstName} {person.MiddleName} {person.LastName}";
}
}
Current proposed syntax for extensions on a reference type...
public extension PersonExtensionClass extends Person
{
public string FullName()
{
return $"{this.FirstName} {this.MiddleName} {this.LastName}";
}
}
My proposed syntax for extensions on a reference type is mainly around the class declaration itself, not the logic being suggested within the class definition itself. My main gripe is that the proposal is for extensions to become their own classes in itself, as they would also maintain their own state, aren't following the syntax of normal classes. If extensions should be able to extend other extensions, there is the requirement to inheir like normal classes.
public extension PersonExtensionClass<IPerson>
{
// code
}
public extension PersonExtensionClassOfExtensionClass<IPerson> : PersonExtensionClass<IPerson>, IDisposable
{
// code
}
Seems a bit more natural in this usage to me.