From 109f623701e5366997c1f978ad5e99afa44c1ef7 Mon Sep 17 00:00:00 2001 From: Gerald Versluis Date: Mon, 16 Mar 2026 12:39:19 +0100 Subject: [PATCH 1/9] Add maui-coding-guardrails and maui-current-apis skills Add two always-on guardrail skills for .NET MAUI development: - maui-coding-guardrails: Prevents use of obsolete controls (ListView, TableView, Frame), deprecated patterns (renderers, BackgroundColor), and common architectural mistakes (ScrollView inside StackLayout, mixing Shell with NavigationPage). Includes control reference tables, compiled bindings guidance, and handler customization patterns. - maui-current-apis: Prevents use of deprecated APIs across .NET MAUI versions. Includes a reasoning framework for detecting project TFM and library versions, comprehensive deprecated API tables for .NET MAUI 10, and guidance for MauiReactor and Blazor Hybrid scenarios. Both skills include eval scenarios for validation. Sourced from dotnet/maui#34429 (RFC by jfversluis), which consolidates work from davidortinau/maui-skills and github/awesome-copilot. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- plugins/dotnet-maui/plugin.json | 2 +- .../skills/maui-coding-guardrails/SKILL.md | 244 ++++++++++++++++++ .../skills/maui-current-apis/SKILL.md | 201 +++++++++++++++ .../maui-coding-guardrails/eval.yaml | 97 +++++++ tests/dotnet-maui/maui-current-apis/eval.yaml | 129 +++++++++ 5 files changed, 672 insertions(+), 1 deletion(-) create mode 100644 plugins/dotnet-maui/skills/maui-coding-guardrails/SKILL.md create mode 100644 plugins/dotnet-maui/skills/maui-current-apis/SKILL.md create mode 100644 tests/dotnet-maui/maui-coding-guardrails/eval.yaml create mode 100644 tests/dotnet-maui/maui-current-apis/eval.yaml diff --git a/plugins/dotnet-maui/plugin.json b/plugins/dotnet-maui/plugin.json index c50869fac8..d79bf8aa3f 100644 --- a/plugins/dotnet-maui/plugin.json +++ b/plugins/dotnet-maui/plugin.json @@ -1,6 +1,6 @@ { "name": "dotnet-maui", "version": "0.1.0", - "description": "Skills for .NET MAUI development: environment setup, diagnostics, and troubleshooting.", + "description": "Skills for .NET MAUI development: environment setup, diagnostics, coding guardrails, and API currency.", "skills": ["./skills/"] } diff --git a/plugins/dotnet-maui/skills/maui-coding-guardrails/SKILL.md b/plugins/dotnet-maui/skills/maui-coding-guardrails/SKILL.md new file mode 100644 index 0000000000..fa01c3aba9 --- /dev/null +++ b/plugins/dotnet-maui/skills/maui-coding-guardrails/SKILL.md @@ -0,0 +1,244 @@ +--- +name: maui-coding-guardrails +description: >- + Always-on guardrail for .NET MAUI development. Prevents use of obsolete + controls, deprecated patterns, and common architectural mistakes. + USE FOR: any .NET MAUI code generation, review, or editing task — this skill + provides baseline rules that apply universally. + DO NOT USE FOR: API currency checks across framework versions (use + maui-current-apis instead), environment setup or workload issues (use + dotnet-maui-doctor), or non-MAUI .NET projects. +--- + +# .NET MAUI Coding Guardrails + +Always-active guardrail that prevents common .NET MAUI mistakes. These rules +apply to **every** MAUI code generation or editing task regardless of which +other skills are active. + +## When to Use + +- Any time you generate, edit, or review .NET MAUI XAML or C# code +- When scaffolding new pages, views, or controls +- When suggesting layout structures or control choices + +## When Not to Use + +- Non-MAUI .NET projects (ASP.NET, Blazor Server, WPF, WinForms) +- Checking API currency across .NET versions — use `maui-current-apis` instead +- Environment setup and workload troubleshooting — use `dotnet-maui-doctor` + +## Critical Rules (NEVER Violate) + +| Rule | Why | Use Instead | +|------|-----|-------------| +| **NEVER use `ListView`** | Obsolete — deprecated in .NET 10 | `CollectionView` | +| **NEVER use `TableView`** | Obsolete — deprecated in .NET 10 | `Grid` or `VerticalStackLayout` with individual controls | +| **NEVER use `AndExpand` layout options** | Obsolete, behavior is undefined | `Grid` with row/column definitions | +| **NEVER use `BackgroundColor`** | Deprecated property | `Background` (supports `Brush` and `Color`) | +| **NEVER place `ScrollView` or `CollectionView` inside `StackLayout`** | Breaks scrolling and virtualization | Use `Grid` as the parent container | +| **NEVER reference images as `.svg`** | SVG is only a source format for the build tooling | Reference as `.png` — the build generates PNGs from SVGs | +| **NEVER mix `Shell` with `NavigationPage` / `TabbedPage` / `FlyoutPage`** | Causes navigation corruption and undefined behavior | Choose **one** navigation paradigm | +| **NEVER use renderers** | Legacy Xamarin.Forms concept | Use **handlers** and `Mapper` / `CommandMapper` | + +### Examples of Violations + +```xml + + + + + + + + + + +``` + +```xml + + + + ... + + + + + + + ... + + +``` + +```xml + + + + + +``` + +## Control Quick Reference + +### Layout Controls + +| Control | Purpose | Notes | +|---------|---------|-------| +| `Grid` | Complex multi-row/column layouts | Preferred for most layouts | +| `VerticalStackLayout` | Simple vertical stacking | Prefer over `StackLayout` | +| `HorizontalStackLayout` | Simple horizontal stacking | Prefer over `StackLayout` | +| `FlexLayout` | CSS Flexbox-style layouts | Good for wrapping content | +| `Border` | Rounded corners, borders, clipping | **Replaces `Frame`** | +| `ContentView` | Custom control base class | Wrap reusable UI | +| `ScrollView` | Scrollable content | **Never** inside `StackLayout` | + +> **`Frame` is legacy.** Use `Frame` only when you need a drop shadow. +> For all other cases use `Border` (supports `StrokeShape` for rounded corners). + +### List & Data Display + +| Control | When to Use | Notes | +|---------|-------------|-------| +| `CollectionView` | **> 20 items** or dynamic data | Supports virtualization, selection, grouping | +| `BindableLayout` | **≤ 20 items** or static lists | Attach to any `Layout` — no virtualization | +| `CarouselView` | Swipeable card/page UI | Set `PeekAreaInsets` for peek effect | + +```xml + + + + + + + +``` + +## Best Practices + +### Compiled Bindings (8–20× Performance Improvement) + +Always declare `x:DataType` on every `DataTemplate` and page: + +```xml + + + +``` + +> Without `x:DataType`, bindings use slow runtime reflection. + +### Layout Selection + +| Scenario | Use | +|----------|-----| +| Complex multi-area layout | `Grid` | +| Simple vertical list of elements | `VerticalStackLayout` | +| Simple horizontal row of elements | `HorizontalStackLayout` | +| Wrapping content | `FlexLayout` | +| **Avoid** | `StackLayout` (use specific orientation variants) | + +### Border over Frame + +```xml + + + + + + +