Skip to content
This repository was archived by the owner on Oct 26, 2025. It is now read-only.
This repository was archived by the owner on Oct 26, 2025. It is now read-only.

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

@benmcevoy

Description

@benmcevoy

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions