Skip to content

Interface or docu wrong #151

@holonsoftFounder

Description

@holonsoftFounder

Option A: make it tri-state

Change signature to:

Task<bool?> IsFeatureEnabledAsync(...)

Implementation:

public async Task<bool?> IsFeatureEnabledAsync(
    string featureKey,
    string distinctId,
    FeatureFlagOptions? options,
    CancellationToken cancellationToken)
{
    var result = await GetFeatureFlagAsync(featureKey, distinctId, options, cancellationToken);

    if (result is null) return null;          // undefined / not existing
    return result.IsEnabled;                  // true/false if known
}

Updated doc (clear semantics):

true = enabled
false = explicitly disabled
null = undefined / not found

This matches your “not existing is silently hidden” point and preserves information.

Option B (non-breaking): fix the doc to match behavior

Keep Task and update to something like:

true if enabled
false if disabled or undefined / not found

Example:

/// <returns>
/// <c>true</c> if the feature is enabled for the user.
/// <c>false</c> if the feature is disabled, undefined, or does not exist.
/// </returns>

This is consistent with the current implementation.

Option C (non-breaking, add) PREFERRED

If you want both without breaking callers

Add a new API and keep the old one as a convenience wrapper:

Task<bool?> TryIsFeatureEnabledAsync(...);

Task IsFeatureEnabledAsync(...) // legacy
=> (await TryIsFeatureEnabledAsync(...)) == true;

That way callers who care about “undefined” can opt in, and existing callers keep their boolean.

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