Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Plan: Fix compound property serialization (Issue #20)

## Problem
`FormatPropertyValue` in `DevFlowAgentService.cs` loses detail for compound MAUI types:
- **Gradient brushes**: Only show stop count, not colors/offsets — clients can't reconstruct gradients
- **LayoutOptions**: `ToString()` doesn't distinguish `Expands` flag
- **ItemsLayout**: `ToString()` loses orientation/spacing details

## Approach
Enhance `FormatPropertyValue` switch cases to serialize compound types with full detail. Keep the human-readable string format consistent with existing patterns.

## Todos

- [ ] fix-gradient-brushes — Enhance LinearGradientBrush and RadialGradientBrush to include gradient stop colors and offsets
- [ ] add-layout-options — Add LayoutOptions formatting with Alignment + Expands
- [ ] add-items-layout — Add LinearItemsLayout and GridItemsLayout formatting
- [ ] build-and-test — Build, run tests, verify with live app
- [ ] create-pr — Create branch and PR for issue #20
14 changes: 12 additions & 2 deletions src/MauiDevFlow.Agent.Core/DevFlowAgentService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -581,13 +581,16 @@ private async Task<HttpResponse> HandleProperty(HttpRequest request)
{
Shadow shadow => FormatShadow(shadow),
SolidColorBrush scb => $"SolidColorBrush Color={scb.Color?.ToArgbHex() ?? "(null)"}",
LinearGradientBrush lgb => $"LinearGradientBrush StartPoint={lgb.StartPoint}, EndPoint={lgb.EndPoint}, Stops={lgb.GradientStops?.Count ?? 0}",
RadialGradientBrush rgb => $"RadialGradientBrush Center={rgb.Center}, Radius={rgb.Radius}, Stops={rgb.GradientStops?.Count ?? 0}",
LinearGradientBrush lgb => $"LinearGradientBrush StartPoint={lgb.StartPoint}, EndPoint={lgb.EndPoint}, Stops=[{FormatGradientStops(lgb.GradientStops)}]",
RadialGradientBrush rgb => $"RadialGradientBrush Center={rgb.Center}, Radius={rgb.Radius}, Stops=[{FormatGradientStops(rgb.GradientStops)}]",
Brush brush => brush.GetType().Name,
Microsoft.Maui.Controls.Shapes.RoundRectangle rr => $"RoundRectangle CornerRadius={FormatPropertyValue(rr.CornerRadius)}",
Microsoft.Maui.Controls.Shapes.Shape shape => shape.GetType().Name,
ColumnDefinitionCollection cols => string.Join(", ", cols.Select(c => FormatGridLength(c.Width))),
RowDefinitionCollection rows => string.Join(", ", rows.Select(r => FormatGridLength(r.Height))),
LayoutOptions lo => $"{lo.Alignment}{(lo.Expands ? ", Expands" : "")}",
LinearItemsLayout lin => $"LinearItemsLayout Orientation={lin.Orientation}, ItemSpacing={lin.ItemSpacing}",
GridItemsLayout grid => $"GridItemsLayout Span={grid.Span}, Orientation={grid.Orientation}, HorizontalSpacing={grid.HorizontalItemSpacing}, VerticalSpacing={grid.VerticalItemSpacing}",
FileImageSource fis => $"File: {fis.File}",
UriImageSource uis => $"Uri: {uis.Uri}",
FontImageSource fontIs => $"Font: {fontIs.Glyph} ({fontIs.FontFamily})",
Expand All @@ -603,6 +606,13 @@ private static string FormatGridLength(GridLength gl) => gl.IsStar
: gl.IsAbsolute ? gl.Value.ToString(System.Globalization.CultureInfo.InvariantCulture)
: "Auto";

private static string FormatGradientStops(GradientStopCollection? stops)
{
if (stops == null || stops.Count == 0) return "";
return string.Join(", ", stops.Select(s =>
$"{s.Color.ToArgbHex()} {(s.Offset * 100).ToString("0", System.Globalization.CultureInfo.InvariantCulture)}%"));
}

private static string FormatShadow(Shadow shadow)
{
var parts = new List<string>();
Expand Down
Loading