Skip to content

Add AdaptiveRemote.Contracts shared library for layout DTOs#137

Merged
jodavis merged 2 commits intofeature/ADR-161-cusrtomization-servicefrom
claude/implement-layout-customization-rgZP2
Apr 7, 2026
Merged

Add AdaptiveRemote.Contracts shared library for layout DTOs#137
jodavis merged 2 commits intofeature/ADR-161-cusrtomization-servicefrom
claude/implement-layout-customization-rgZP2

Conversation

@jodavis
Copy link
Copy Markdown
Owner

@jodavis jodavis commented Apr 7, 2026

Summary

Introduces a new AdaptiveRemote.Contracts class library containing shared data transfer objects (DTOs), enums, and interfaces for layout definitions. This library serves as the contract layer between the client application and backend services, enabling consistent serialization and type safety across platform boundaries.

Key Changes

  • New Project: AdaptiveRemote.Contracts targeting net10.0 with no platform-specific dependencies

    • Pure data types (records, enums, interfaces) with no behavior
    • Included in both client.slnf and backend.slnf solution filters
  • Layout Definition DTOs:

    • RawLayoutElementDto (abstract) — base type for editor-editable layout elements with authoring properties (grid position, CSS overrides)
    • RawCommandDefinitionDto — command element with behavioral properties (type, name, label, glyph, speak phrase, reverse)
    • RawLayoutGroupDefinitionDto — container element with child elements
    • LayoutElementDto (abstract) — compiled variant stripped of authoring properties
    • CommandDefinitionDto and LayoutGroupDefinitionDto — compiled variants for client consumption
  • Top-Level Layout Records:

    • RawLayout — administrator-editable source format with validation results
    • CompiledLayout — client-consumable format with compiled CSS and element definitions
    • PreviewLayout — editor preview format with rendered HTML/CSS
  • Supporting Types:

    • CommandType enum — identifies runtime command type (Lifecycle, TiVo, IR, Action)
    • ICommandProperties interface — shared behavioral contract preventing drift between raw and compiled command types
    • ValidationResult and ValidationIssue records — validation reporting
  • JSON Serialization:

    • LayoutContractsJsonContext — source-generated JSON context for Native AOT compatibility
    • Polymorphic JSON serialization using type discriminators for element hierarchies
  • Project References:

    • Updated AdaptiveRemote.App.csproj to reference the new contracts library

Implementation Details

  • Uses C# 13 record types with inheritance for type-safe polymorphic serialization
  • Employs [JsonPolymorphic] and [JsonDerivedType] attributes for compile-time JSON schema generation
  • Grid layout properties (row, column, span) are authoring-only and compiled into CSS definitions
  • ICommandProperties interface ensures behavioral properties remain synchronized between raw and compiled variants

https://claude.ai/code/session_01T3tonn7C9F6TYbqH23KmG1

…ters

- Add AdaptiveRemote.Contracts project (net10.0, no platform-specific dependencies)
  containing all layout definition DTOs, enums, and LayoutContractsJsonContext
  from the spec's Shared Contracts section:
  CommandType enum, ICommandProperties interface, LayoutElementDto hierarchy
  (compiled), RawLayoutElementDto hierarchy (raw), RawLayout/CompiledLayout/
  PreviewLayout top-level records, ValidationIssue/ValidationResult records,
  and source-generated LayoutContractsJsonContext for consistent serialization
  across all consumers including Native AOT Lambda functions.
- Add AdaptiveRemote.Contracts to AdaptiveRemote.sln with full build configurations.
- Reference AdaptiveRemote.Contracts from AdaptiveRemote.App.
- Add client.slnf and backend.slnf solution filters.
- Update _doc_Projects.md to document the new shared contracts project.

https://claude.ai/code/session_01T3tonn7C9F6TYbqH23KmG1
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 7, 2026

Test Results

401 tests   401 ✅  2m 14s ⏱️
 10 suites    0 💤
 10 files      0 ❌

Results for commit 46ebd1d.

♻️ This comment has been updated with latest results.

Copy link
Copy Markdown
Owner Author

@jodavis jodavis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few changes to make

// TiVo — CommandId = Name.ToUpperInvariant() (existing convention)
// IR — payload programmed via remote, stored in ProgrammaticSettings
// Others — keyed by Name
public enum CommandType { Lifecycle, TiVo, IR, Action }
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove Action, that's not a Command type, it's a WPF adapter (which maybe doesn't belong in Models, but that's a problem for another day.)

// compiled into CssDefinitions and are not needed by the client.
// ---------------------------------------------------------------------------

[JsonPolymorphic(TypeDiscriminatorPropertyName = "type")]
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's a naming conflict between this type discriminator and the Type property on CommandDefinitionDto.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to put the RawLayout class in the file with RawLayoutElementDto and friends, and CompiledLayout with LayoutElementDto and friends. PreviewLayout can be in its own file. That keeps the related types together better.

- Remove Action from CommandType enum (it's a WPF adapter, not a command type)
- Change type discriminator from "type" to "\$type" on both LayoutElementDto and
  RawLayoutElementDto to avoid conflict with the behavioral Type property on
  CommandDefinitionDto and RawCommandDefinitionDto
- Move RawLayout into RawLayoutElementDto.cs, CompiledLayout into LayoutElementDto.cs,
  PreviewLayout into its own PreviewLayout.cs; delete Layouts.cs

https://claude.ai/code/session_01T3tonn7C9F6TYbqH23KmG1
@jodavis jodavis merged commit 65e373f into feature/ADR-161-cusrtomization-service Apr 7, 2026
2 checks passed
@jodavis jodavis deleted the claude/implement-layout-customization-rgZP2 branch April 7, 2026 23:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants