Skip to content

A base record's public implementation of a generated member is kept as the value object's, or crashes the aspect #197

Closed

Description

@CaffeinatedCoder

Package

CodoMetis.TypeKit.Generators

Version

2.3.0, and every release that generates these members

How does it fail?

Silently for IMinMaxValue; for the others a Metalama error (LAMA0500) naming nothing you wrote

What you ran

A base record implements a member the generators implement, publicly:

public abstract record LocalBoundedBase<TSelf> : IMinMaxValue<TSelf> where TSelf : LocalBoundedBase<TSelf>, IMinMaxValue<TSelf>
{
    public static TSelf MaxValue => throw new NotSupportedException("base");
    public static TSelf MinValue => throw new NotSupportedException("base");
}
public sealed partial record LocalLevel : LocalBoundedBase<LocalLevel>, IValue<int>;

LocalLevel.MaxValue;   // throws "base": the generated MaxValue is not there
Max<LocalLevel>();     // throws "base"

public abstract record FormattingBase : IFormattable
{
    public string ToString(string? format, IFormatProvider? formatProvider) => "base";
}
public sealed partial record Shown : FormattingBase, IValue<int>;   // LAMA0500

What you got

Measured on release/2.4.0 at 97c87c1, 2026-10-30, the base in the same project:

  • IMinMaxValue: the base's public static MaxValue and MinValue are the value object's; no MaxValue is generated and nothing is reported. A hand-written MaxValue on the value object itself is CMTK1011.
  • IFormattable.ToString(string?, IFormatProvider?), IComparable.CompareTo(object), IParsable<TSelf>.Parse/TryParse: LAMA0500, "cannot introduce member ... because it is already defined in type ...".

From another project, the base's public static members are refused already, but described as "the explicit implementation of ...": the compiler records any implementation of a static abstract member as explicit in metadata. A closed set's base class from another project with an explicit IClosedSet<TSelf> implementation is #191's case, refused by #193.

What you expected

CMTK1011 (CMTK1008 for comparison) naming the base's member, as a base record's members count as the value object's own (decision 28), and an error that says "BoundedPublicBase.MaxValue in its base type ...", not "explicit implementation". Found by variant analysis while checking an outside review of #193.

Environment

.NET SDK 10.0.4xx, Metalama 2026.1; any consumer.

Scope as fixed in #193 (38b316f)

Measured beyond the report: a base record's public Value, From and TryFormat failed the aspect the same way (LAMA0500), and its static MinValue/MaxValue without IMinMaxValue were the value object's as well. All are CMTK1011 now (CMTK1008 for CompareTo(object)), naming the base's member by its own name, including a public static one from another project, which no longer reads "the explicit implementation of …". The interface mapping refuses a base's public implementation of a generated interface's member, and the names and signatures checked on the value object are checked on each base record. A base's TryFrom, a seam, is #194's. Decision 124 records it.

Activity

  1. added this to the 2.4.0 milestone on Oct 30, 2026
  2. added
    bugSomething isn't working
    silentCompiles or answers and does less than it appears to
    severity/mediumInconsistency or failure in a narrow scenario
    package/generatorsAffects CodoMetis.TypeKit.Generators
    area/value-objectsValue-object contracts and what the aspects generate for them
    on Oct 30, 2026
  3. modified the milestones: 2.4.0, 2.3.1 on Oct 30, 2026
  4. CaffeinatedCoder commented on Oct 30, 2026

    @CaffeinatedCoder
    OwnerAuthor

    Fixed by #201, merged into release/2.3.1 as 8fac39b; ships in 2.3.1.

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 thembugSomething isn't workingpackage/generatorsAffects CodoMetis.TypeKit.Generatorsseverity/mediumInconsistency or failure in a narrow scenariosilentCompiles or answers and does less than it appears to

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions