Skip to content

Code fix: implement Create for an IValidatedValue that lacks it #82

Closed

Description

@CaffeinatedCoder

A validated value object has one hand-written member, Create. Declaring IValidatedValue<TSelf, T, TFault> without it fails the build on the missing static member, and nothing helps the user write it: the analyzers' two code fixes cover positional Match arguments and a required parameterless constructor.

Proposal

A code fix, offered where a type declares IValidatedValue<TSelf, T, TFault> and lacks Create, that inserts:

public static Result<TSelf, TFault> Create(T value)
{
    // your rules: if (...) return Result.Error(TFault.Member);
    return Result.Success(new TSelf(value));
}

with the type arguments filled in from the declaration (the shape of the Generators README's Email). Optionally the same for a plain IValue<T> turned into a validated one.

Done when

  • The fix is offered on the diagnostic the missing Create raises, for a struct and a class value object, a nested and a generic-containing one (the TypeArgumentSites and TypeArgumentKinds catalogues where they apply), and the fixed code compiles and generates.
  • No new diagnostic at Error severity (a minor release); the Generators README mentions the fix where it explains Create.

Activity

  1. added this to the 2.3.0 milestone on Oct 28, 2026
  2. CaffeinatedCoder commented on Oct 29, 2026

    @CaffeinatedCoder
    OwnerAuthor

    Done in PR #110 as Add Create, the code fix for CS0535 (open into release/2.3.0). The optional part, the same fix for a plain IValue<T> turned into a validated value object, is left out. A plain IValue<T> raises no CS0535 to hang it on, so it is no part of this fix and would be an issue of its own.

  3. CaffeinatedCoder commented on Oct 29, 2026

    @CaffeinatedCoder
    OwnerAuthor

    Done in PR #110, merged into release/2.3.0.

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

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions