Skip to content

A value object implementing an interface derived from IValueObject<,> fails with a Metalama error naming nothing #192

Closed

Description

@CaffeinatedCoder

Package

CodoMetis.TypeKit.Generators

Version

2.3.0, and every release that generates value objects

How does it fail?

Loudly, but naming nothing you wrote: a Metalama error (LAMA0512)

What you ran

An interface of your own that derives from a contract the generators implement, to constrain generic code:

public interface IEntityId<TSelf> : IValueObject<TSelf, Guid> where TSelf : IEntityId<TSelf>;

public readonly partial record struct OrderId : IValue<Guid>, IEntityId<OrderId>;

What you got

LAMA0512: The aspect 'ValueObjectContractAspect' cannot implement interface 'IValueObject<OrderId, Guid>' in the type 'OrderId' because the type already implements it and WhenExists is set to Fail, beside CS0535 for IValueObject<OrderId, Guid>.Value. Measured on release/2.4.0 at 97c87c1, 2026-10-30.

ValueObjectDeclaration.GeneratedMembersDeclaredByHand refuses IValueObject<,>, IValueObjectMaterializer<,> and IPlainValueObject<,> declared on the value object (CMTK1011), reading ImplementedInterfaces; declared through another interface it reaches the aspect.

What you expected

Either the value object is generated (the interface is only a constraint, and the generated Value implements it), or CMTK1011 names the interface. Which one is a design question: accepting it means ImplementInterface with another strategy and a check that the user's interface adds no member the generators don't write.

Environment

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

Found by variant analysis while fixing #191 (the same "declared through an interface" axis, where IConvertible crashed with LAMA0041).

Activity

  1. added this to the 2.4.0 milestone on Oct 30, 2026
  2. added
    bugSomething isn't working
    severity/lowCosmetic, message or documentation-level difference
    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 #204, merged into release/2.3.1 as dbdd44e; 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/lowCosmetic, message or documentation-level difference

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions