…te-type Try-methods
PR #642 annotated all Try* out-parameters with [MaybeNullWhen(false)] on a
non-nullable T, which is the correct pattern for unconstrained generic type
parameters (as in Dictionary<TKey,TValue>.TryGetValue) but not for concrete
reference types. For concrete types, the BCL convention (e.g. Uri.TryCreate)
is [NotNullWhen(true)] out T? - this also gives callers a compiler warning
if they dereference the out value without checking the return value first,
which MaybeNullWhen(false) on non-nullable T silently allows.
Updates IHelperResolver, IObjectDescriptorProvider (and implementers),
IFormatterProvider (and implementers), TypeExtensions.IsAssignableToGenericType,
and BlockAccumulatorContext.IsDetachedClosingElement. Generic-TValue Try-methods
(LookupSlim, DictionarySlim, FixedSizeDictionary, CascadeIndex, ObservableIndex)
are left as-is since they correctly mirror the BCL generic pattern.
Fixes #654
Summary
PR #642 annotated all Try* out-parameters with [MaybeNullWhen(false)] out T value (non-nullable T), regardless of whether T was an unconstrained generic type parameter or a concrete reference type. That pattern is only correct for the generic case (mirroring Dictionary<TKey,TValue>.TryGetValue, which can't write TValue? without a class constraint). For concrete reference types, the BCL's own convention (e.g. Uri.TryCreate) is [NotNullWhen(true)] out T? - which also gives a stronger compiler guarantee: dereferencing the out value without checking the return value first now correctly warns, whereas MaybeNullWhen(false) on a non-nullable T silently allowed it.
This is a compile-time-only change (nullable annotations erase to metadata, not IL), so it's not binary breaking, and normal if (TryX(..., out var x)) call sites are unaffected.
Left unchanged: the generic-TValue collection Try-methods (LookupSlim, DictionarySlim, FixedSizeDictionary, CascadeIndex, ObservableIndex) - these correctly mirror the BCL's own generic pattern already.
Fixes #654
Test plan