Skip to content

CMTK0005: report CollectionsMarshal.SetCount on a list of value objects #229

Closed

Description

@CaffeinatedCoder

Found beside the CMTK0005 misses of the 2.3.1 hand check, in a scratch consumer at d573eef.

CollectionsMarshal.SetCount(list, 3) on a List<Plain> adds three default value objects, as new Plain[3] does, and nothing reports it. CMTK0005 is defined over "an array or span ... created with a length", so a list is outside it today: this widens the rule, which is why it is 2.4.0 work and not a 2.3.1 fix.

Proposal

CMTK0005 reports CollectionsMarshal.SetCount<T> where T is a value object, Option, Result or [RequireCustomInitialization] struct, unless the count is a constant zero; the README's row says "an array, span or list". A Warning reporting more needs no exception to decision 34.

Test

A CMTK0005 row for SetCount, a zero control, across TypeArgumentKinds.

Activity

  1. added this to the 2.4.0 milestone on Oct 31, 2026
  2. CaffeinatedCoder commented on Oct 31, 2026

    @CaffeinatedCoder
    OwnerAuthor

    Landed on release/2.4.0 by #271 (merge commit 09ec900): CMTK0005 reports CollectionsMarshal.SetCount on a list of value objects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/value-objectsValue-object contracts and what the aspects generate for themenhancementNew feature or requestpackage/analyzersAffects CodoMetis.TypeKit.Analyzers

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions