From 7f3cfe06e8c470bb0f4198f2415bfbe10047b548 Mon Sep 17 00:00:00 2001 From: Indraneel Rajeevan <105813454+indraneel12@users.noreply.github.com> Date: Tue, 14 Oct 2025 00:31:42 +0530 Subject: [PATCH 1/7] refactor: Created `OptionResolutionData` To capture significant information during the Option Resolution stage. Note: - no additions or removal from the existing `OptionResolution` - publicly exported --- packages/config/lib/src/config/config.dart | 1 + .../lib/src/config/option_resolution.dart | 23 +++++++++---------- .../src/config/option_resolution_data.dart | 17 ++++++++++++++ 3 files changed, 29 insertions(+), 12 deletions(-) create mode 100644 packages/config/lib/src/config/option_resolution_data.dart diff --git a/packages/config/lib/src/config/config.dart b/packages/config/lib/src/config/config.dart index 66bcc38..cf86657 100644 --- a/packages/config/lib/src/config/config.dart +++ b/packages/config/lib/src/config/config.dart @@ -8,6 +8,7 @@ export 'exceptions.dart'; export 'file_system_options.dart'; export 'multi_config_source.dart'; export 'option_groups.dart'; +export 'option_resolution_data.dart'; export 'option_types.dart'; export 'options.dart'; export 'output_formatting.dart' show formatConfigError; diff --git a/packages/config/lib/src/config/option_resolution.dart b/packages/config/lib/src/config/option_resolution.dart index bba7af4..237370a 100644 --- a/packages/config/lib/src/config/option_resolution.dart +++ b/packages/config/lib/src/config/option_resolution.dart @@ -1,11 +1,7 @@ +import 'option_resolution_data.dart'; import 'source_type.dart'; -final class OptionResolution { - final String? stringValue; - final V? value; - final String? error; - final ValueSourceType source; - +final class OptionResolution with OptionResolutionData { const OptionResolution._({ required this.source, this.stringValue, @@ -44,12 +40,15 @@ final class OptionResolution { error: error, ); - /// Whether the option has a proper value (without errors). - bool get hasValue => source != ValueSourceType.noValue && error == null; + @override + final String? stringValue; - /// Whether the option has a value that was specified explicitly (not default). - bool get isSpecified => hasValue && source != ValueSourceType.defaultValue; + @override + final V? value; - /// Whether the option has the default value. - bool get isDefault => hasValue && source == ValueSourceType.defaultValue; + @override + final String? error; + + @override + final ValueSourceType source; } diff --git a/packages/config/lib/src/config/option_resolution_data.dart b/packages/config/lib/src/config/option_resolution_data.dart new file mode 100644 index 0000000..8bc1b2c --- /dev/null +++ b/packages/config/lib/src/config/option_resolution_data.dart @@ -0,0 +1,17 @@ +import 'source_type.dart'; + +base mixin OptionResolutionData { + String? get stringValue; + V? get value; + String? get error; + ValueSourceType get source; + + /// Whether the option has a proper value (without errors). + bool get hasValue => source != ValueSourceType.noValue && error == null; + + /// Whether the option has a value that was specified explicitly (not default). + bool get isSpecified => hasValue && source != ValueSourceType.defaultValue; + + /// Whether the option has the default value. + bool get isDefault => hasValue && source == ValueSourceType.defaultValue; +} From 251547f16542dbdea0366705e560535bee2329da Mon Sep 17 00:00:00 2001 From: Indraneel Rajeevan <105813454+indraneel12@users.noreply.github.com> Date: Tue, 14 Oct 2025 00:36:24 +0530 Subject: [PATCH 2/7] refactor(`OptionResolutionData`): Derived Attribute added Simplifies certain error-checks. --- packages/config/lib/src/config/option_resolution_data.dart | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/config/lib/src/config/option_resolution_data.dart b/packages/config/lib/src/config/option_resolution_data.dart index 8bc1b2c..fbe0feb 100644 --- a/packages/config/lib/src/config/option_resolution_data.dart +++ b/packages/config/lib/src/config/option_resolution_data.dart @@ -6,8 +6,11 @@ base mixin OptionResolutionData { String? get error; ValueSourceType get source; + /// Whether there was an error during resolving this Option. + bool get hasError => error != null; + /// Whether the option has a proper value (without errors). - bool get hasValue => source != ValueSourceType.noValue && error == null; + bool get hasValue => !hasError && source != ValueSourceType.noValue; /// Whether the option has a value that was specified explicitly (not default). bool get isSpecified => hasValue && source != ValueSourceType.defaultValue; From 6303854ba52c0f46de4fbb950cafb646b6974057 Mon Sep 17 00:00:00 2001 From: Indraneel Rajeevan <105813454+indraneel12@users.noreply.github.com> Date: Tue, 14 Oct 2025 00:40:48 +0530 Subject: [PATCH 3/7] fix(`OptionResolutionData`): Proper boolean condition Typo correction. --- packages/config/lib/src/config/option_resolution_data.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/config/lib/src/config/option_resolution_data.dart b/packages/config/lib/src/config/option_resolution_data.dart index fbe0feb..2983d0d 100644 --- a/packages/config/lib/src/config/option_resolution_data.dart +++ b/packages/config/lib/src/config/option_resolution_data.dart @@ -7,7 +7,7 @@ base mixin OptionResolutionData { ValueSourceType get source; /// Whether there was an error during resolving this Option. - bool get hasError => error != null; + bool get hasError => error == null; /// Whether the option has a proper value (without errors). bool get hasValue => !hasError && source != ValueSourceType.noValue; From 52145afe0ccc2dd06ba980e2d5039e198a24e540 Mon Sep 17 00:00:00 2001 From: Indraneel Rajeevan <105813454+indraneel12@users.noreply.github.com> Date: Tue, 14 Oct 2025 00:45:52 +0530 Subject: [PATCH 4/7] fix(`OptionResolutionData`): Accidental fix reverted --- packages/config/lib/src/config/option_resolution_data.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/config/lib/src/config/option_resolution_data.dart b/packages/config/lib/src/config/option_resolution_data.dart index 2983d0d..fbe0feb 100644 --- a/packages/config/lib/src/config/option_resolution_data.dart +++ b/packages/config/lib/src/config/option_resolution_data.dart @@ -7,7 +7,7 @@ base mixin OptionResolutionData { ValueSourceType get source; /// Whether there was an error during resolving this Option. - bool get hasError => error == null; + bool get hasError => error != null; /// Whether the option has a proper value (without errors). bool get hasValue => !hasError && source != ValueSourceType.noValue; From a4999a2c57e78af6dbaba96f99dc6e7aca152872 Mon Sep 17 00:00:00 2001 From: Indraneel Rajeevan <105813454+indraneel12@users.noreply.github.com> Date: Tue, 14 Oct 2025 00:50:26 +0530 Subject: [PATCH 5/7] docs(`OptionResolutionData`): Missing docs added Comprehensively covers the purpose of this new Mixin. --- .../lib/src/config/option_resolution_data.dart | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/config/lib/src/config/option_resolution_data.dart b/packages/config/lib/src/config/option_resolution_data.dart index fbe0feb..c4753b0 100644 --- a/packages/config/lib/src/config/option_resolution_data.dart +++ b/packages/config/lib/src/config/option_resolution_data.dart @@ -1,11 +1,19 @@ import 'source_type.dart'; +/// Provides significant metadata about an Option once it is resolved. base mixin OptionResolutionData { - String? get stringValue; + /// The resolved value of this Option. V? get value; - String? get error; + + /// The source from where this Option has been resolved. ValueSourceType get source; + /// A string representation of this Option's value. + String? get stringValue; + + /// An Error that may have been encountered during Option Resolution. + String? get error; + /// Whether there was an error during resolving this Option. bool get hasError => error != null; From 604b638339c2e0f09adad5cb6309df07a2e9ed9d Mon Sep 17 00:00:00 2001 From: Indraneel Rajeevan <105813454+indraneel12@users.noreply.github.com> Date: Tue, 14 Oct 2025 00:59:46 +0530 Subject: [PATCH 6/7] fix: Put `OptionResolutionData` instead of `OptionResolution` in `validateValues` - all instances replaced (only two found tho) - not a breaking change (rather, a fix) because `OptionResolution` was/is Private - ensures that the Package Client can override `validateValues` as intended --- packages/config/lib/src/config/option_groups.dart | 4 ++-- packages/config/lib/src/config/options.dart | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/config/lib/src/config/option_groups.dart b/packages/config/lib/src/config/option_groups.dart index 7681896..4854466 100644 --- a/packages/config/lib/src/config/option_groups.dart +++ b/packages/config/lib/src/config/option_groups.dart @@ -1,5 +1,5 @@ import 'exceptions.dart'; -import 'option_resolution.dart'; +import 'option_resolution_data.dart'; import 'options.dart'; enum MutuallyExclusiveMode { @@ -49,7 +49,7 @@ class MutuallyExclusive extends OptionGroup { @override String? validateValues( - final Map optionResolutions, + final Map optionResolutions, ) { final allowDefaults = mode == MutuallyExclusiveMode.allowDefaults; final providedCount = optionResolutions.values diff --git a/packages/config/lib/src/config/options.dart b/packages/config/lib/src/config/options.dart index 83b7e6b..6cb7517 100644 --- a/packages/config/lib/src/config/options.dart +++ b/packages/config/lib/src/config/options.dart @@ -7,6 +7,7 @@ import 'configuration.dart'; import 'configuration_broker.dart'; import 'exceptions.dart'; import 'option_resolution.dart'; +import 'option_resolution_data.dart'; import 'source_type.dart'; /// Common interface to enable same treatment for [ConfigOptionBase] @@ -64,7 +65,7 @@ class OptionGroup { /// /// Subclasses may override this method to perform specific validations. String? validateValues( - final Map optionResolutions, + final Map optionResolutions, ) { return null; } From d1e55669edaf23b7416f4d5231c677ee29487607 Mon Sep 17 00:00:00 2001 From: Indraneel Rajeevan <105813454+indraneel12@users.noreply.github.com> Date: Fri, 17 Oct 2025 21:11:41 +0530 Subject: [PATCH 7/7] style: Consistent documentation language Updated the newly added comments to follow existing documentation styles. --- .../lib/src/config/option_resolution_data.dart | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/config/lib/src/config/option_resolution_data.dart b/packages/config/lib/src/config/option_resolution_data.dart index c4753b0..e896ad2 100644 --- a/packages/config/lib/src/config/option_resolution_data.dart +++ b/packages/config/lib/src/config/option_resolution_data.dart @@ -1,20 +1,20 @@ import 'source_type.dart'; -/// Provides significant metadata about an Option once it is resolved. +/// Provides significant metadata about an option once it is resolved. base mixin OptionResolutionData { - /// The resolved value of this Option. + /// The resolved value of the option. V? get value; - /// The source from where this Option has been resolved. + /// The source from where the option has been resolved. ValueSourceType get source; - /// A string representation of this Option's value. + /// The string value of the option. String? get stringValue; - /// An Error that may have been encountered during Option Resolution. + /// Error message, if any, apropos of option resolution. String? get error; - /// Whether there was an error during resolving this Option. + /// Whether there was an error during resolving the option. bool get hasError => error != null; /// Whether the option has a proper value (without errors).