Skip to content

Validate Kind Override Compatibility #20

@j-d-ha

Description

@j-d-ha

Priority: P2 - Important
Tier: 3 - Advanced Features
Effort: Medium (4-6 hours)

Already In Codebase

  • [DynamoField(Kind = ...)] is already parsed and threaded into generated calls.
    • Parsing: src/LayeredCraft.DynamoMapper.Generators/MapperSyntaxProvider.cs
    • Strategy selection + kind threading: src/LayeredCraft.DynamoMapper.Generators/PropertyMapping/TypeMappingStrategyResolver.cs and src/LayeredCraft.DynamoMapper.Generators/PropertyMapping/PropertyMappingSpecBuilder.cs
  • The generator currently rejects Phase-2 collection kinds (L/M/SS/NS/BS) with DM0001 (CannotConvertFromAttributeValue).
  • There is a snapshot test demonstrating kind override usage: test/LayeredCraft.DynamoMapper.Generators.Tests/DynamoFieldVerifyTests.cs.

Goal

Add compatibility validation and diagnostics for Kind overrides.

Today kind overrides are effectively "pass-through" (codegen compiles) but can lead to runtime NotImplementedException (e.g., DynamoKind.B) or confusing parsing behavior.

Scope

  • Validate that Kind overrides are compatible with the CLR property type and the runtime extension methods.
  • Emit generator diagnostics (rather than letting invalid combinations fail at runtime).

Examples

  • string + DynamoKind.S is valid.
  • string + DynamoKind.B should emit a diagnostic until binary support is implemented.
  • Guid + DynamoKind.S and Guid + DynamoKind.N may be allowed, but should be intentionally validated.

Implementation notes

  • Add a validator (e.g., KindValidator) that runs after type strategy resolution.
  • Expand diagnostics beyond DM0001 for invalid kind override combinations.
  • Keep the current behavior of rejecting L/M/SS/NS/BS until Story 5.1 (collections) is implemented.

Acceptance criteria

  • Invalid kind overrides produce clear compile-time diagnostics.
  • Valid kind overrides continue to generate correct code.
  • Tests cover at least one valid and one invalid kind override.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions