Skip to content

fix: CMTK0005 and CMTK0006 report a new()-constrained value-object parameter, as CMTK0001 does - #216

Merged
CaffeinatedCoder merged 1 commit into
release/2.3.1from
fix/no-default-new-constrained-parameter-2-3-1
Oct 31, 2026
Merged

CaffeinatedCoder merged 1 commit into
release/2.3.1from
fix/no-default-new-constrained-parameter-2-3-1

Conversation

@CaffeinatedCoder

Copy link
Copy Markdown
Owner

Closes #207

Problem

CMTK0005 and CMTK0006 decided "no default" with TypeKitSymbols.IsNoDefaultStruct, which admitted a type parameter only beside struct. CMTK0001 and CMTK0009 use DefaultRestriction, which also admits a parameter bound by the marker beside new(): a generated class has no public parameterless constructor, so such a T is a struct value object. For where T : IEntityId<T>, new(), new T() was CMTK0001 while new T[3] and an unassigned T field reported nothing, although the Analyzers README defines both rules over CMTK0001's list.

Change

IsNoDefaultStruct is DefaultRestriction(type) is not null, the predicate CMTK0001 reads. Both rules are Warnings, which the README lets learn forms in a minor version, so no exception to decision 34. Changelog line under 2.3.1.

Tests

Found by a sweep of release/2.3.1 @ dbdd44e for the defect class of #191-#197.

🤖 Generated with Claude Code

…rameter, as CMTK0001 does

CMTK0005 and CMTK0006 decided "no default" with IsNoDefaultStruct,
which admitted a type parameter only beside struct. CMTK0001 and
CMTK0009 use DefaultRestriction, which also admits a parameter bound by
the marker beside new() and no class bound: a generated class has no
public parameterless constructor, so such a T is a struct value object.
So for where T : IEntityId<T>, new(), new T() was CMTK0001 while
new T[3] and an unassigned T field reported nothing, although the
README defines both rules over CMTK0001's list.

IsNoDefaultStruct is now DefaultRestriction(type) is not null, the
predicate CMTK0001 reads. Both rules are Warnings, which the README
lets learn forms in a minor version.

Input class (AIS): what the judged type is. Catalogue:
TypeArgumentKinds, 80 kinds with the one added here (a new() parameter
bound by an interface deriving from IValue<int>, the reported shape).
NoDefaultKindTests runs CMTK0001, CMTK0005 and CMTK0006 over every kind
against one oracle, the README's list; CMTK0001 agreed on all 80 before
the fix, and the two new() kinds were the only rows where the other two
did not. No other sibling: only these two rules called the narrow
predicate.

Reverting the source fails the 4 new() rows of 240.

Refs #207

Defect-Class: AIS
Found-By: CA
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/value-objects Value-object contracts and what the aspects generate for them bug Something isn't working package/analyzers Affects CodoMetis.TypeKit.Analyzers severity/low Cosmetic, message or documentation-level difference silent Compiles or answers and does less than it appears to

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant