Skip to content

feat: improve developer ergonomics - #23

Merged
roncohen merged 2 commits into
mainfrom
dx/ergonomics
Nov 28, 2026
Merged

roncohen merged 2 commits into
mainfrom
dx/ergonomics

Conversation

@roncohen

@roncohen roncohen commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Developer-ergonomics fixes from an SDK review, covering discoverability, logging, error messages, and docs.

  • Error codes: add public ReflagEvaluationErrorCodes constants (MISSING_CONTEXT_FIELD, UNSUPPORTED_ARRAY_OPERATOR, INVALID_COMPARISON, INVALID_FLAG_DEFINITION, CLIENT_NOT_INITIALIZED) so callers don't copy magic strings. The evaluator now uses them.
  • IntelliSense: ship the XML documentation file in the package (CS1591 suppressed for members that are still undocumented) and document ReflagClient, ReflagBoundClient, and every ReflagClientOptions property.
  • Loose contexts everywhere: GetFlag, GetFlag<T>, GetFlags, and GetFlagsForBootstrap accept anonymous-object/dictionary contexts, matching BindClient. The basic README example now passes one directly.
  • Logging:
    • AddReflag(...) defaults Logger to the host ILoggerFactory (category Reflag), so DI users no longer wire it by hand.
    • "Not initialized" is logged at most once per rate-limit window instead of on every read, and says to call InitializeAsync().
    • The diagnostics warning logs {FlagKey} and the joined error messages instead of a dictionary that most sinks render as its type name. Messages still omit context values.
  • Errors: a missing secret key now explains SecretKey, REFLAG_SECRET_KEY, and Offline = true. A short key says it is invalid rather than "invalid options.SecretKey specified".
  • README:
    • Replace the long testing section with a short "Overrides and tests" section modelled on the v2 Node SDK, starting with Boolean overrides.
    • Add a "Failed evaluations" note pointing to the Reflag app.
    • Add "Remote config is not supported; use multivariate flags".
    • Update the AddReflag snippet and Logger option docs, and drop the "currently"/"at the moment" wording.

Compatibility

  • A missing secret key now throws ArgumentException instead of ArgumentNullException. Callers catching ArgumentException are unaffected.
  • With the new object overloads, passing a literal null context to the flag read methods is a compile-time ambiguity. Previously it threw at runtime.
  • Diagnostics warning text changed (flag "<key>": targeting rules could not be fully evaluated: ...).

Validation

  • 201 SDK tests + 6 example tests pass on .NET 8 and .NET 10. New tests cover the AddReflag logger default, the rate-limited initialization error, loose-context overloads, the missing-key message, and check telemetry across initialization (from fix: preserve check telemetry across initialization #18).
  • dotnet build -warnaserror (Release) and dotnet format --verify-no-changes pass.
  • dotnet pack includes Reflag.xml for net10.0 and netstandard2.0.

Supersedes #18. Its fix (adding initialization state to the check-event dedupe key) is already covered on current main, because the dedupe key includes evalErrors and flagStateVersion. This PR ports its regression test, adapted to protocol v2. Removing both keys makes the test fail.

- Add public ReflagEvaluationErrorCodes constants and use them internally.
- Ship XML documentation and document the main client and option members.
- Accept anonymous-object contexts in GetFlag, GetFlag<T>, GetFlags and
  GetFlagsForBootstrap, matching BindClient.
- Default the logger to the host ILoggerFactory when registered with AddReflag.
- Rate-limit the not-initialized error and say how to fix it.
- Log evaluation diagnostics with the flag key and readable messages.
- Explain how to provide a missing or invalid secret key.
- Shorten the testing docs, note failed evaluations, and say remote config is
  not supported.
Port the regression test from #18. Current main already keeps a
pre-initialization check from suppressing the matching check after
initialization, because the dedupe key includes evalErrors and
flagStateVersion.

@reflag-review reflag-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Risk: medium

no actionable findings

@reflag-review reflag-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Risk: medium

no actionable findings

@roncohen
roncohen merged commit c30c11e into main Nov 28, 2026
4 checks passed
@roncohen
roncohen deleted the dx/ergonomics branch November 28, 2026 11:43
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

Successfully merging this pull request may close these issues.

1 participant