λ0003: Member is not intended for direct usage
A member that only exists to support a C# syntax feature is used directly.
Cause
A property marked with [SyntaxSupportOnly] is accessed directly instead of through the syntax it supports.
Currently this applies to Option<T>.Count and the indexer Option<T>[int], which exist solely so that
list patterns work on Option<T>.
Reason for rule
C# list patterns require a Count (or Length) property and an indexer on the matched type.
These members are implementation details of the pattern support and have no meaningful contract on their own:
the indexer throws for any index on None, and the Count is never anything other than 0 or 1.
Using them directly re-introduces the "check then extract" style of programming that Option<T> is designed to avoid.
This rule is not configurable and is reported as an error, because the members are hidden from IntelliSense and their behavior is not part of the public contract.
How to fix violations
Use a list pattern, or one of the regular Option<T> methods such as Match, Select, SelectMany or GetOrElse.
Examples
Disallowed
static string Example(Option<string> option)
=> option.Count == 1
? option[0]
: "fallback";
Allowed
List pattern
static string Example(Option<string> option)
=> option is [var value]
? value
: "fallback";
Regular API
static string Example(Option<string> option)
=> option.GetOrElse("fallback");