You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the IFieldRenderingString interface we have three methods, WithAttribute, DisableWebEdit, and DefaultValueIfEmpty.
These methods return IFieldRenderingString (the this), and were intended to be builder methods to let the user build up the desired behaviour, e.g.
When you use these methods you are coerced to IFieldRenderingString which can be annoying if your field was more derived, such as LinkFieldRenderingString.
These methods would be better as extension methods, that use a generic parameter constrained to IFieldRenderingString. i.e.
public static T DisableWebEdit<T>(this T field) where T : IFieldRenderingString
This would allow the builder pattern on any of the field rendering types that derive from IFieldRenderingString, without the coercion, e.g. after using DisableWebEdit() the field is still a LinkFieldRenderingString and not a boring old IFieldRenderingString.
Changing the interface is a breaking change. Adding equivalent extension methods would help, but any code that references Atlas would have to be recompiled.
The text was updated successfully, but these errors were encountered:
In the IFieldRenderingString interface we have three methods, WithAttribute, DisableWebEdit, and DefaultValueIfEmpty.
These methods return IFieldRenderingString (the
this
), and were intended to be builder methods to let the user build up the desired behaviour, e.g.MyField.DisableWebEdit().DefaultValueIfEmpty("I'm empty!");
When you use these methods you are coerced to
IFieldRenderingString
which can be annoying if your field was more derived, such asLinkFieldRenderingString
.These methods would be better as extension methods, that use a generic parameter constrained to IFieldRenderingString. i.e.
public static T DisableWebEdit<T>(this T field) where T : IFieldRenderingString
This would allow the builder pattern on any of the field rendering types that derive from
IFieldRenderingString
, without the coercion, e.g. after usingDisableWebEdit()
the field is still a LinkFieldRenderingString and not a boring old IFieldRenderingString.Changing the interface is a breaking change. Adding equivalent extension methods would help, but any code that references Atlas would have to be recompiled.
The text was updated successfully, but these errors were encountered: