From 95e7d0c90bf76b23fa0794be6da4272fba2da3f4 Mon Sep 17 00:00:00 2001 From: Dave Friedel Date: Thu, 1 Jan 2026 17:48:18 -0500 Subject: [PATCH] Add CLAUDE.md for XAML reconstruction project MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Documents the plan to reconstruct XAML files from decompiled sample apps: - ShellDemo: 12 files (App, AppShell, 10 pages) - TodoApp: 4 files (App, 3 pages) - XamlBrowser: 2 files (App, MainPage) Includes: - Color values extracted from decompiled code - Style definitions - AppShell structure with FlyoutItems - Key patterns for converting decompiled C# to XAML - Workflow and tracking checklist 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- CLAUDE.md | 435 +++++++++++++++++++++++++++++------------------------- 1 file changed, 238 insertions(+), 197 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 31f9b89..b6160ba 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -1,202 +1,228 @@ -# CLAUDE.md - OpenMaui Linux Recovery Instructions +# CLAUDE.md - OpenMaui XAML Reconstruction -## READ THIS FIRST +## CURRENT TASK: Reconstruct XAML from Decompiled Code -This file contains critical instructions for restoring lost production code. **Read this entire file before doing ANY work.** +The sample applications (ShellDemo, TodoApp, XamlBrowser) were recovered from decompiled DLLs. The XAML files were compiled away - we have only the generated `InitializeComponent()` code. **Screenshots will be provided** to help verify visual accuracy. --- -## Background - -Production code was lost. The only surviving copy was recovered by decompiling production DLLs. The decompiled code has ugly syntax but represents the **actual working production code**. - ---- - -## The Core Rule - -**DECOMPILED CODE = SOURCE OF TRUTH** - -The decompiled code in the `recovered` folder is what was actually running in production. Your job is to: - -1. Read the decompiled file -2. Understand the LOGIC (ignore ugly syntax) -3. Write that same logic in clean, maintainable C# -4. Save it to the `final` branch - -**Do NOT:** -- Skip files because "main looks fine" -- Assume main is correct -- Change the logic from decompiled -- Stub out code with comments - ---- - -## File Locations +## Project Locations | What | Path | |------|------| -| **Target (write here)** | `/Users/nible/Documents/GitHub/maui-linux-main/` | -| **Decompiled Views** | `/Users/nible/Documents/GitHub/recovered/source/OpenMaui/Microsoft.Maui.Platform/` | -| **Decompiled Handlers** | `/Users/nible/Documents/GitHub/recovered/source/OpenMaui/Microsoft.Maui.Platform.Linux.Handlers/` | -| **Decompiled Services** | `/Users/nible/Documents/GitHub/recovered/source/OpenMaui/Microsoft.Maui.Platform.Linux.Services/` | -| **Decompiled Hosting** | `/Users/nible/Documents/GitHub/recovered/source/OpenMaui/Microsoft.Maui.Platform.Linux.Hosting/` | +| **Main codebase** | `/Users/nible/Documents/GitHub/maui-linux-main/` | +| **Samples (target)** | `/Users/nible/Documents/GitHub/maui-linux-main/samples_temp/` | +| **Decompiled samples** | `/Users/nible/Documents/GitHub/recovered/source/` | --- -## Branch +## Git Branch -**Work on `final` branch ONLY.** +**Work on `final` branch.** Commit frequently. -The user will review all changes before merging to main. Always verify you're on `final`: ```bash -git branch # Should show * final +git branch # Should show: * final ``` --- -## How to Process Each File +## XAML Reconstruction Overview -### Step 1: Read the decompiled version -``` -Read /Users/nible/Documents/GitHub/recovered/source/OpenMaui/[path]/[FileName].cs -``` +### ShellDemo (10 pages + shell + app) -### Step 2: Read the current main version -``` -Read /Users/nible/Documents/GitHub/maui-linux-main/[path]/[FileName].cs -``` +| File | Status | Notes | +|------|--------|-------| +| App.xaml | [ ] | Colors, Styles (ThemedEntry, TitleLabel, etc.) | +| AppShell.xaml | [ ] | Shell with FlyoutHeader, 9 FlyoutItems | +| HomePage.xaml | [ ] | Welcome screen with logo | +| ButtonsPage.xaml | [ ] | Button demos | +| TextInputPage.xaml | [ ] | Entry/Editor demos | +| SelectionPage.xaml | [ ] | CheckBox, Switch, RadioButton demos | +| PickersPage.xaml | [ ] | DatePicker, TimePicker, Picker demos | +| ListsPage.xaml | [ ] | CollectionView demos | +| ProgressPage.xaml | [ ] | ProgressBar, ActivityIndicator demos | +| GridsPage.xaml | [ ] | Grid layout demos | +| AboutPage.xaml | [ ] | About information | +| DetailPage.xaml | [ ] | Navigation detail page | -### Step 3: Compare the LOGIC -- Ignore syntax differences (decompiler artifacts) -- Look for: missing methods, different behavior, missing properties, different logic flow +### TodoApp (app + 3 pages) -### Step 4: If logic differs, update main with clean version -Write the decompiled logic using clean C# syntax. +| File | Status | Notes | +|------|--------|-------| +| App.xaml | [ ] | Colors, Icon strings | +| TodoListPage.xaml | [ ] | Main list with swipe actions | +| NewTodoPage.xaml | [ ] | Add new todo form | +| TodoDetailPage.xaml | [ ] | Edit todo details | -### Step 5: Build and verify -```bash -dotnet build -``` +### XamlBrowser (app + 1 page) -### Step 6: Report what changed -Tell the user specifically what was different, not just "looks equivalent." +| File | Status | Notes | +|------|--------|-------| +| BrowserApp.xaml | [ ] | Basic app setup | +| MainPage.xaml | [ ] | WebView browser | --- -## Cleaning Decompiled Code +## How to Reconstruct XAML -### Decompiler artifacts to fix: +### Step 1: Read the decompiled InitializeComponent() -| Ugly (decompiled) | Clean (what you write) | -|-------------------|------------------------| -| `((ViewHandler)(object)handler).PlatformView` | `handler.PlatformView` | -| `((BindableObject)this).GetValue(X)` | `GetValue(X)` | -| `(Type)(object)((x is Type) ? x : null)` | `x as Type` or `x is Type t ? t : null` | -| `//IL_xxxx: Unknown result type` | Delete these comments | -| `_002Ector` | Constructor call | -| `(BindingMode)2` | `BindingMode.TwoWay` | -| `(WebNavigationEvent)3` | `WebNavigationEvent.NewPage` | -| `((Thickness)(ref padding)).Left` | `padding.Left` | -| `((SKRect)(ref bounds)).Width` | `bounds.Width` | +Look for patterns like: +```csharp +// Setting a property +((BindableObject)val8).SetValue(Label.TextProperty, (object)"OpenMaui"); ---- +// AppThemeBinding (light/dark mode) +val7.Light = "White"; +val7.Dark = "#E0E0E0"; -## Using Agents (Task Tool) +// StaticResource +val.Key = "PrimaryColor"; -Agents work fine IF you give them the right instructions. Previous failures happened because the agent prompts didn't include the critical rules. - -### Required Agent Prompt Template - -When spawning an agent, ALWAYS include this in the prompt: - -``` -## CRITICAL RULES - READ FIRST - -1. DECOMPILED CODE = PRODUCTION (source of truth) -2. MAIN BRANCH = OUTDATED (needs to be updated) -3. Do NOT skip files -4. Do NOT assume main is correct -5. Do NOT say "equivalent" or "no changes needed" without listing every method/property you compared - -## Your Task - -Compare these two files: -- DECOMPILED (truth): [full path to decompiled file] -- MAIN (to update): [full path to main file] - -For each method/property in decompiled: -1. Check if it exists in main -2. Check if the LOGIC is the same (ignore syntax differences) -3. Report: "METHOD X: [exists/missing] [logic same/different]" - -If ANY logic differs or methods are missing, write the clean version to main. - -## Decompiler Syntax to Clean Up -- `((ViewHandler)(object)handler).PlatformView` → `handler.PlatformView` -- `//IL_xxxx:` comments → delete -- `(BindingMode)2` → `BindingMode.TwoWay` -- `((Thickness)(ref x)).Left` → `x.Left` +// Layout hierarchy +((Layout)val12).Children.Add((IView)(object)val6); ``` -### Example Agent Call - -``` -Task tool prompt: -"Compare ButtonHandler files. - -CRITICAL RULES: -1. DECOMPILED = PRODUCTION (truth) -2. MAIN = OUTDATED -3. Do NOT skip or say 'equivalent' without proof - -DECOMPILED: /Users/nible/Documents/GitHub/recovered/source/OpenMaui/Microsoft.Maui.Platform.Linux.Handlers/ButtonHandler.cs -MAIN: /Users/nible/Documents/GitHub/maui-linux-main/Handlers/ButtonHandler.cs - -List every method in decompiled. For each one, confirm it exists in main with same logic. If different, write the fix." -``` - -### Why Previous Agents Failed - -The prompts said things like "compare these files" without: -- Stating which file is the source of truth -- Requiring method-by-method comparison -- Forbidding "no changes needed" shortcuts - -Agents took shortcuts because the prompts allowed it. - ---- - -## Event Args - Use MAUI's Directly - -**Do NOT create custom event args that duplicate MAUI's types.** - -The codebase currently has custom `WebNavigatingEventArgs` and `WebNavigatedEventArgs` at the bottom of `Views/SkiaWebView.cs`. These are unnecessary and should be removed. Use MAUI's versions directly: +### Step 2: Convert to XAML ```csharp -// WRONG - custom event args (remove these) -public class WebNavigatingEventArgs : EventArgs { ... } // in SkiaWebView.cs - -// RIGHT - use MAUI's directly -Microsoft.Maui.Controls.WebNavigatingEventArgs -Microsoft.Maui.Controls.WebNavigatedEventArgs +// This C#: +((BindableObject)val8).SetValue(Label.TextProperty, (object)"OpenMaui"); +((BindableObject)val8).SetValue(Label.FontSizeProperty, (object)22.0); +((BindableObject)val8).SetValue(Label.FontAttributesProperty, (object)(FontAttributes)1); +val7.Light = "White"; +val7.Dark = "#E0E0E0"; +((BindableObject)val8).SetBinding(Label.TextColorProperty, val74); ``` -### TODO: Cleanup needed +```xml + +