You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
CMTK0005: report Array.Clear and Span<T>.Clear on value objects #270
Array.Clear and Span<T>.Clear() set existing slots back to default, which CMTK0001 does not see since no default is written, and CMTK0005 does not report since nothing is created:
OrderId[]ids=[..rows.Select(r =>OrderId.From(r.Id))];Array.Clear(ids);// every slot now a default OrderId, nothing reportedids.AsSpan().Clear();// the same
Array.Fill(ids, default) and span.Fill(default) are already caught by CMTK0001, since they write default.
Proposal
CMTK0005 reports Array.Clear (each overload) and Span<T>.Clear() where the element is a value object, Option, Result or [RequireCustomInitialization] struct, unless a constant length of zero is given; resolved by symbol. The README's row then names clearing beside creating. A Warning reporting more needs no exception to decision 34. Whether this belongs in CMTK0005 (whose title is a collection "filled with default instances") or in a rule of its own is part of the decision.
Test
A CMTK0005 row per overload, a zero-length control, across TypeArgumentKinds.
Activity