Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IFieldRenderString methods are not as usable as they could be #27

Open
benmcevoy opened this issue May 11, 2020 · 0 comments
Open

IFieldRenderString methods are not as usable as they could be #27

benmcevoy opened this issue May 11, 2020 · 0 comments

Comments

@benmcevoy
Copy link
Contributor

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 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant