Skip to content

ReplOptionAttribute.CaseSensitivity is unsettable (nullable enum) — per-option case override is dead via attribute #57

Description

@carldebilly

Summary

ReplOptionAttribute.CaseSensitivity is typed ReplCaseSensitivity? (nullable enum). A nullable enum cannot be a named attribute argument in C#, so any attempt to set it fails to compile:

[ReplOption(CaseSensitivity = ReplCaseSensitivity.CaseInsensitive)] string? channel
// error CS0655: 'CaseSensitivity' is not a valid named attribute argument
// because it is not a valid attribute parameter type

The property therefore always resolves to null through the attribute path. OptionSchemaBuilder feeds it into every option entry as CaseSensitivity: optionAttribute?.CaseSensitivity, so the per-option case-sensitivity override the property is meant to provide is effectively dead code for options declared via [ReplOption].

(The OptionSchemaEntry.CaseSensitivity field itself works — it is exercised by direct-schema tests and by value-alias / enum-flag configuration, which carry their own CaseSensitivity. Only the option-level override via the attribute is unreachable.)

Impact

  • Users cannot make a single option case-insensitive (or case-sensitive) independently of the global ParsingOptions.OptionCaseSensitivity.
  • Discovered while reviewing fix(autocomplete): option-value & option-region completion parity edges #55: the "ambiguous pending option token" scenario (a token matching both a CaseInsensitive --Foo and a --foo) is not reachable precisely because this override cannot be set.

Options

  1. Make it settable. Attribute-legal alternatives:
    • Replace the nullable enum with two bool flags (e.g. CaseInsensitive / and rely on absence for "inherit"), or a non-nullable enum with an explicit Inherit member (ReplCaseSensitivity would need such a member, or a dedicated ReplOptionCaseSensitivity { Inherit, CaseSensitive, CaseInsensitive }).
    • Expose the override through a fluent builder API instead of (or in addition to) the attribute.
  2. Remove it. If per-option case override is not a supported feature, drop the property and the optionAttribute?.CaseSensitivity plumbing so the API does not advertise a knob that cannot be used.

Either way, add a test that actually sets the override and asserts a differently-cased token resolves (or does not) accordingly — today no test can exercise the attribute path.

Context

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Fields

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions