From fb4d39f3b6bb04ca5d5192a01913bc3d67a7f554 Mon Sep 17 00:00:00 2001 From: Matt Date: Fri, 6 Jun 2025 00:13:35 +0100 Subject: [PATCH] Refactor checklists and radio lists to use records Converted `CheckList` and `CheckListItem` to records, adding XML documentation for clarity. Updated properties in `CheckListProps`, `RadioList`, and `RadioListItem` with similar changes. Enhanced documentation in `DropDownOptionsProviderBase` and modified `RadioListOptionsProviderBase` to reflect new functionality. Overall improvements for readability and maintainability. --- .../Shared/UIHints/CheckList/CheckList.cs | 5 +++++ .../Shared/UIHints/CheckList/CheckListItem.cs | 12 ++++-------- .../Shared/UIHints/CheckList/CheckListProps.cs | 3 +++ .../Shared/UIHints/RadioList/RadioList.cs | 5 +++++ .../Shared/UIHints/RadioList/RadioListItem.cs | 11 ++++------- .../Shared/UIHints/RadioList/RadioListProps.cs | 3 +++ .../UIHints/CheckList/CheckList.cs | 10 ++++++++++ .../UIHints/CheckList/CheckListProps.cs | 3 +++ .../UIHints/Dropdown/DropDownOptionsProviderBase.cs | 3 ++- .../UIHints/RadioList/RadioList.cs | 10 ++++++++++ .../RadioList/RadioListOptionsProviderBase.cs | 2 +- .../UIHints/RadioList/RadioListProps.cs | 3 +++ 12 files changed, 53 insertions(+), 17 deletions(-) diff --git a/src/clients/Elsa.Api.Client/Shared/UIHints/CheckList/CheckList.cs b/src/clients/Elsa.Api.Client/Shared/UIHints/CheckList/CheckList.cs index 3caba2572..ed04df0e6 100644 --- a/src/clients/Elsa.Api.Client/Shared/UIHints/CheckList/CheckList.cs +++ b/src/clients/Elsa.Api.Client/Shared/UIHints/CheckList/CheckList.cs @@ -1,3 +1,8 @@ namespace Elsa.Api.Client.Shared.UIHints.CheckList; +/// +/// Represents a list of check list items. +/// +/// The items. +/// Whether the select list represents a flags enum. public record CheckList(IEnumerable Items, bool IsFlagsEnum = false); \ No newline at end of file diff --git a/src/clients/Elsa.Api.Client/Shared/UIHints/CheckList/CheckListItem.cs b/src/clients/Elsa.Api.Client/Shared/UIHints/CheckList/CheckListItem.cs index 53cd50bd6..62d5e6bf5 100644 --- a/src/clients/Elsa.Api.Client/Shared/UIHints/CheckList/CheckListItem.cs +++ b/src/clients/Elsa.Api.Client/Shared/UIHints/CheckList/CheckListItem.cs @@ -1,10 +1,6 @@ namespace Elsa.Api.Client.Shared.UIHints.CheckList; -public class CheckListItem -{ -#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. - public string Text { get; set; } - public string Value { get; set; } -#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. - public bool IsChecked { get; set; } -} \ No newline at end of file +/// +/// Represents an item in a . +/// +public record CheckListItem(string Text, string Value, bool IsChecked); \ No newline at end of file diff --git a/src/clients/Elsa.Api.Client/Shared/UIHints/CheckList/CheckListProps.cs b/src/clients/Elsa.Api.Client/Shared/UIHints/CheckList/CheckListProps.cs index 431e9263d..4ef203dc7 100644 --- a/src/clients/Elsa.Api.Client/Shared/UIHints/CheckList/CheckListProps.cs +++ b/src/clients/Elsa.Api.Client/Shared/UIHints/CheckList/CheckListProps.cs @@ -1,5 +1,8 @@ namespace Elsa.Api.Client.Shared.UIHints.CheckList; +/// +/// Provides properties for the checklist UI hint. +/// public class CheckListProps { /// diff --git a/src/clients/Elsa.Api.Client/Shared/UIHints/RadioList/RadioList.cs b/src/clients/Elsa.Api.Client/Shared/UIHints/RadioList/RadioList.cs index 3075e7be8..b17e00f1e 100644 --- a/src/clients/Elsa.Api.Client/Shared/UIHints/RadioList/RadioList.cs +++ b/src/clients/Elsa.Api.Client/Shared/UIHints/RadioList/RadioList.cs @@ -1,3 +1,8 @@ namespace Elsa.Api.Client.Shared.UIHints.RadioList; +/// +/// Represents a list of radio list items. +/// +/// The items. +/// Whether the select list represents a flags enum. public record RadioList(IEnumerable Items, bool IsFlagsEnum = false); \ No newline at end of file diff --git a/src/clients/Elsa.Api.Client/Shared/UIHints/RadioList/RadioListItem.cs b/src/clients/Elsa.Api.Client/Shared/UIHints/RadioList/RadioListItem.cs index 45ba5d2e2..3e7722287 100644 --- a/src/clients/Elsa.Api.Client/Shared/UIHints/RadioList/RadioListItem.cs +++ b/src/clients/Elsa.Api.Client/Shared/UIHints/RadioList/RadioListItem.cs @@ -1,9 +1,6 @@ namespace Elsa.Api.Client.Shared.UIHints.RadioList; -public class RadioListItem -{ -#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. - public string Text { get; set; } - public string Value { get; set; } -#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. -} \ No newline at end of file +/// +/// Represents an item in a . +/// +public record RadioListItem(string Text, string Value); \ No newline at end of file diff --git a/src/clients/Elsa.Api.Client/Shared/UIHints/RadioList/RadioListProps.cs b/src/clients/Elsa.Api.Client/Shared/UIHints/RadioList/RadioListProps.cs index a4441a15f..be100b644 100644 --- a/src/clients/Elsa.Api.Client/Shared/UIHints/RadioList/RadioListProps.cs +++ b/src/clients/Elsa.Api.Client/Shared/UIHints/RadioList/RadioListProps.cs @@ -1,5 +1,8 @@ namespace Elsa.Api.Client.Shared.UIHints.RadioList; +/// +/// Provides properties for the radiolist UI hint. +/// public class RadioListProps { /// diff --git a/src/modules/Elsa.Workflows.Core/UIHints/CheckList/CheckList.cs b/src/modules/Elsa.Workflows.Core/UIHints/CheckList/CheckList.cs index dcb697d7e..4380ecae1 100644 --- a/src/modules/Elsa.Workflows.Core/UIHints/CheckList/CheckList.cs +++ b/src/modules/Elsa.Workflows.Core/UIHints/CheckList/CheckList.cs @@ -1,7 +1,17 @@ namespace Elsa.Workflows.UIHints.CheckList; +/// +/// Provides properties for the UI hint. +/// public class CheckList { + /// + /// The radio list. + /// public IEnumerable Items { get; set; } + + /// + /// The name of the provider that will provide the select list. + /// public bool IsFlagsEnum { get; set; } } \ No newline at end of file diff --git a/src/modules/Elsa.Workflows.Core/UIHints/CheckList/CheckListProps.cs b/src/modules/Elsa.Workflows.Core/UIHints/CheckList/CheckListProps.cs index 4d3d6e8df..f2dda59aa 100644 --- a/src/modules/Elsa.Workflows.Core/UIHints/CheckList/CheckListProps.cs +++ b/src/modules/Elsa.Workflows.Core/UIHints/CheckList/CheckListProps.cs @@ -1,5 +1,8 @@ namespace Elsa.Workflows.UIHints.CheckList; +/// +/// Provides properties for the UI hint. +/// public class CheckListProps { /// diff --git a/src/modules/Elsa.Workflows.Core/UIHints/Dropdown/DropDownOptionsProviderBase.cs b/src/modules/Elsa.Workflows.Core/UIHints/Dropdown/DropDownOptionsProviderBase.cs index e248cb557..5ee12af51 100644 --- a/src/modules/Elsa.Workflows.Core/UIHints/Dropdown/DropDownOptionsProviderBase.cs +++ b/src/modules/Elsa.Workflows.Core/UIHints/Dropdown/DropDownOptionsProviderBase.cs @@ -4,7 +4,8 @@ using Elsa.Extensions; namespace Elsa.Workflows.UIHints.Dropdown; /// -/// +/// A base class for providing options to populate a dropdown UI component. This class is intended to be inherited to implement +/// custom dropdown data logic by overriding the `GetItemsAsync` method. /// public abstract class DropDownOptionsProviderBase : IPropertyUIHandler { diff --git a/src/modules/Elsa.Workflows.Core/UIHints/RadioList/RadioList.cs b/src/modules/Elsa.Workflows.Core/UIHints/RadioList/RadioList.cs index 0dd5e25ec..ace833be9 100644 --- a/src/modules/Elsa.Workflows.Core/UIHints/RadioList/RadioList.cs +++ b/src/modules/Elsa.Workflows.Core/UIHints/RadioList/RadioList.cs @@ -1,7 +1,17 @@ namespace Elsa.Workflows.UIHints.RadioList; +/// +/// Provides properties for the UI hint. +/// public class RadioList { + /// + /// The radio list. + /// public IEnumerable Items { get; set; } + + /// + /// The name of the provider that will provide the select list. + /// public bool IsFlagsEnum { get; set; } } \ No newline at end of file diff --git a/src/modules/Elsa.Workflows.Core/UIHints/RadioList/RadioListOptionsProviderBase.cs b/src/modules/Elsa.Workflows.Core/UIHints/RadioList/RadioListOptionsProviderBase.cs index aa09266cb..70bae9a45 100644 --- a/src/modules/Elsa.Workflows.Core/UIHints/RadioList/RadioListOptionsProviderBase.cs +++ b/src/modules/Elsa.Workflows.Core/UIHints/RadioList/RadioListOptionsProviderBase.cs @@ -34,7 +34,7 @@ public abstract class RadioListOptionsProviderBase : PropertyUIHandlerBase } /// - /// Implement this to provide items to the dropdown list. + /// Implement this to provide items to the radio list. /// protected abstract ValueTask> GetItemsAsync(PropertyInfo propertyInfo, object? context, CancellationToken cancellationToken); diff --git a/src/modules/Elsa.Workflows.Core/UIHints/RadioList/RadioListProps.cs b/src/modules/Elsa.Workflows.Core/UIHints/RadioList/RadioListProps.cs index 2465cdda5..bdb15084a 100644 --- a/src/modules/Elsa.Workflows.Core/UIHints/RadioList/RadioListProps.cs +++ b/src/modules/Elsa.Workflows.Core/UIHints/RadioList/RadioListProps.cs @@ -1,5 +1,8 @@ namespace Elsa.Workflows.UIHints.RadioList; +/// +/// Provides properties for the UI hint. +/// public class RadioListProps { ///