Skip to content

Commit 0558fa2

Browse files
csharpfritzCopilot
andcommitted
Update copilot-instructions.md with CLI, migration toolkit, and migration rules
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 3bfe62c commit 0558fa2

2 files changed

Lines changed: 133 additions & 3 deletions

File tree

.github/copilot-instructions.md

Lines changed: 132 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Both should render:
3939
## Technology Stack
4040

4141
- **.NET Version**: .NET 10.0 (see `global.json` for SDK version)
42-
- **Framework**: Blazor (Server-Side and WebAssembly)
42+
- **Framework**: Blazor (migration target is .NET 10 static SSR; samples also include Server-Side and WebAssembly)
4343
- **Project Type**: Razor Class Library (`Microsoft.NET.Sdk.Razor`)
4444
- **Testing Framework**: xUnit with bUnit for Blazor component testing
4545
- **Assertion Library**: Shouldly
@@ -51,14 +51,32 @@ Both should render:
5151

5252
```
5353
/docs -- User documentation (MkDocs)
54-
/samples -- Usage samples
54+
/samples -- Usage samples and migration outputs
5555
BeforeWebForms/ -- Original Web Forms sample (.NET Framework)
5656
AfterBlazorServerSide/ -- Blazor Server-Side samples
57+
AfterBlazorServerSide.Tests/ -- Playwright tests for the sample app
5758
AfterBlazorClientSide/ -- Blazor WebAssembly samples
59+
AfterContosoUniversity/ -- Migrated Contoso University sample
60+
AfterDepartmentPortal/ -- Migrated department portal
61+
AfterWingtipToys/ -- Migrated WingtipToys sample
5862
SharedSampleObjects/ -- Shared models/data for samples
63+
WingtipToys/ -- Original WingtipToys Web Forms sample
64+
ContosoUniversity/ -- Original Contoso University Web Forms sample
65+
DepartmentPortal/ -- Original department portal
5966
/src
6067
BlazorWebFormsComponents/ -- Main component library
6168
BlazorWebFormsComponents.Test/ -- Unit tests with bUnit
69+
BlazorWebFormsComponents.Analyzers/ -- Roslyn analyzers
70+
BlazorWebFormsComponents.Analyzers.Test/ -- Analyzer tests
71+
BlazorWebFormsComponents.Cli/ -- Web Forms to Blazor CLI pipeline and scaffolding
72+
BlazorAjaxToolkitComponents/ -- AJAX Toolkit component library
73+
WingtipToys.AcceptanceTests/ -- WingtipToys Playwright acceptance suite
74+
ContosoUniversity.AcceptanceTests/ -- ContosoUniversity Playwright acceptance suite
75+
/tests
76+
BlazorWebFormsComponents.Cli.Tests/ -- CLI transform and pipeline tests
77+
/migration-toolkit -- Wrapper scripts, skills, methodology, and benchmark helpers
78+
scripts/ -- bwfc-migrate.ps1, bwfc-scan.ps1, and compatibility wrappers
79+
skills/ -- bwfc-migration, bwfc-identity-migration, bwfc-data-migration, migration-standards, l3-performance-optimization
6280
```
6381

6482
## Component Architecture
@@ -288,6 +306,17 @@ When testing component properties or state, use `FindComponent<T>()`:
288306
5. **No ViewState**: Store state in private fields or session (ViewState property exists but is syntax-only)
289307
6. **PostBack Compatibility**: `WebFormsPageBase` provides `IsPostBack`, `PostBack` event, and `__doPostBack()` JS interop bridge
290308

309+
## Migration Rules
310+
311+
These are hard rules for migration work in this repository:
312+
313+
1. **Use the toolkit entry point**: Start project migrations with `migration-toolkit/scripts/bwfc-migrate.ps1` or the `webforms-to-blazor migrate` CLI it forwards to. Do not invent ad hoc regex converters or one-off migration scripts.
314+
2. **Always target Blazor static SSR**: Generated apps target .NET 10 static server-side rendering. Do not switch the whole app to interactive Blazor Server; only opt into interactive render modes deliberately and per page.
315+
3. **Trust the shims**: `WebFormsPageBase` preserves `Page.Request`, `Page.Response`, `Page.Session`, `Page.Server`, `Page.Cache`, `Page.ClientScript`, `IsPostBack`, and `ViewState`. Keep migrated code-behind compiling against those shims instead of rewriting to native ASP.NET Core services during Layer 1 or Layer 2 work.
316+
4. **Preserve BWFC data controls**: Never replace `ListView`, `FormView`, `GridView`, `DataList`, or `Repeater` with manual HTML tables or divs. Fix the generated BWFC markup, templates, item types, or child components instead.
317+
5. **Register transforms twice**: Every new CLI transform must be registered in both `src/BlazorWebFormsComponents.Cli/Program.cs` DI and `tests/BlazorWebFormsComponents.Cli.Tests/TestHelpers.cs` so the runtime pipeline and isolated test pipeline stay aligned.
318+
6. **Respect quarantine boundaries**: `PageQuarantineDetector` should quarantine non-essential `Account/`, `Admin/`, `Checkout/`, mobile, payment, or compile-surface blocker pages, but benchmark-critical home, about, contact, product, catalog, and cart flows stay on the runnable path whenever possible.
319+
291320
## Migration Shims
292321

293322
The library provides compile-compatibility shims on `WebFormsPageBase` so migrated code-behind compiles unchanged:
@@ -314,6 +343,81 @@ When adding new components:
314343
4. Add sample page in `/samples/AfterBlazorServerSide/Pages/ControlSamples/`
315344
5. Document in `/docs/` folder (see Documentation Requirements below)
316345

346+
## Migration CLI & Toolkit
347+
348+
### Primary Entry Points
349+
350+
- `src/BlazorWebFormsComponents.Cli/Program.cs` defines the `webforms-to-blazor` CLI entry point and command surface (`migrate`, `convert`, `prescan`, `scan`, `assets extract`, `edmx convert`).
351+
- `migration-toolkit/scripts/bwfc-migrate.ps1` is the supported migration-toolkit wrapper. It resolves the CLI project and forwards to `migrate` or `prescan` instead of maintaining a separate regex pipeline.
352+
- The migration-toolkit skill set currently includes `bwfc-migration`, `bwfc-identity-migration`, `bwfc-data-migration`, `migration-standards`, and `l3-performance-optimization`.
353+
354+
### Pipeline Overview
355+
356+
`MigrationPipeline` orchestrates the full migration sequence:
357+
358+
1. `ProjectScaffolder` generates the .NET 10 Blazor static SSR scaffold unless `--skip-scaffold` is used.
359+
2. `WebConfigTransformer` converts `Web.config` settings into `appsettings.json`.
360+
3. Ordered markup transforms run first.
361+
4. Ordered code-behind transforms run second.
362+
5. `SemanticPatternCatalog` applies higher-level page rewrites.
363+
6. `PageQuarantineDetector` performs a late compile-surface pass and writes `migration-artifacts/quarantine-manifest.json` when pages must be stubbed.
364+
7. Static assets, source files, App_Start artifacts, NuGet assets, EDMX output, and redirect annotations are copied or generated.
365+
366+
The CLI currently has **24 core markup transforms plus directive/infrastructure markup passes** and **27 code-behind transforms** wired through `Program.cs`.
367+
368+
### Transform Registration Pattern
369+
370+
When adding a transform:
371+
372+
1. Create the transform class in `src/BlazorWebFormsComponents.Cli/Transforms/`.
373+
2. Register it in `BuildServiceProvider()` in `src/BlazorWebFormsComponents.Cli/Program.cs`.
374+
3. Add it to `CreateDefaultPipeline()` in `tests/BlazorWebFormsComponents.Cli.Tests/TestHelpers.cs`.
375+
4. Add or update focused transform tests and pipeline coverage.
376+
377+
```csharp
378+
// Program.cs
379+
services.AddSingleton<IMarkupTransform, MyNewTransform>();
380+
381+
// TestHelpers.cs
382+
var markupTransforms = new List<IMarkupTransform>
383+
{
384+
new MyNewTransform(),
385+
};
386+
```
387+
388+
### Scaffolding System
389+
390+
- `RuntimeDetector` aggregates runtime signal detectors for Entity Framework, session, identity, and `Global.asax` usage.
391+
- `ProjectScaffolder` generates the project file, `_Imports.razor`, `Components/App.razor`, `Components/Routes.razor`, `Components/Layout/MainLayout.razor`, and launch settings.
392+
- `ProgramCsEmitter` generates `Program.cs` for .NET 10 static SSR, including `AddRazorComponents()`, `AddBlazorWebFormsComponents()`, `UseStaticFiles()`, and `UseAntiforgery()`.
393+
- `DatabaseProviderDetector` and `WebConfigTransformer` carry forward database provider and connection-string wiring.
394+
395+
### Quarantine System
396+
397+
- `PageQuarantineDetector` creates build-safe placeholder pages for compile-surface blockers and emits a manifest under `migration-artifacts/quarantine-manifest.json`.
398+
- Essential benchmark pages (home, about, contact, product, catalog, shopping cart, add-to-cart flows) are exempt from incidental quarantine signals.
399+
- Quarantined pages keep stub `.razor` and `.razor.cs` files plus the transformed original code-behind as an artifact for later Layer 2 or Layer 3 repair.
400+
401+
### Acceptance Test Suites
402+
403+
Use these suites as the migration quality gate for benchmark apps:
404+
405+
```bash
406+
# WingtipToys migrated app
407+
# Set WINGTIPTOYS_BASE_URL first if the app is not on https://localhost:5001
408+
409+
dotnet build src/WingtipToys.AcceptanceTests
410+
pwsh src/WingtipToys.AcceptanceTests/bin/Debug/net10.0/playwright.ps1 install chromium
411+
dotnet test src/WingtipToys.AcceptanceTests
412+
413+
# ContosoUniversity benchmark/original app
414+
# Set CONTOSO_BASE_URL first if the app is not on http://localhost:44380
415+
416+
dotnet build src/ContosoUniversity.AcceptanceTests
417+
pwsh src/ContosoUniversity.AcceptanceTests/bin/Debug/net10.0/playwright.ps1 install chromium
418+
dotnet test src/ContosoUniversity.AcceptanceTests
419+
```
420+
317421
## Documentation Requirements
318422

319423
**IMPORTANT**: All features, fixes, and new components MUST include documentation updates.
@@ -372,10 +476,33 @@ dotnet build
372476
# Run tests
373477
dotnet test
374478

479+
# Run CLI tests
480+
dotnet test tests/BlazorWebFormsComponents.Cli.Tests
481+
482+
# Prescan a Web Forms app
483+
dotnet run --project src/BlazorWebFormsComponents.Cli -- prescan -i samples/WingtipToys
484+
485+
# Run the migration CLI
486+
dotnet run --project src/BlazorWebFormsComponents.Cli -- migrate -i samples/WingtipToys -o samples/AfterWingtipToys
487+
375488
# Run server-side samples
376489
dotnet run --project samples/AfterBlazorServerSide
377490
```
378491

492+
### Acceptance Test Commands
493+
494+
```bash
495+
# WingtipToys migrated app (set WINGTIPTOYS_BASE_URL first if needed)
496+
dotnet build src/WingtipToys.AcceptanceTests
497+
pwsh src/WingtipToys.AcceptanceTests/bin/Debug/net10.0/playwright.ps1 install chromium
498+
dotnet test src/WingtipToys.AcceptanceTests
499+
500+
# ContosoUniversity benchmark/original app (set CONTOSO_BASE_URL first if needed)
501+
dotnet build src/ContosoUniversity.AcceptanceTests
502+
pwsh src/ContosoUniversity.AcceptanceTests/bin/Debug/net10.0/playwright.ps1 install chromium
503+
dotnet test src/ContosoUniversity.AcceptanceTests
504+
```
505+
379506
## Key Interfaces
380507

381508
- `IStyle` - Styling properties (BackColor, ForeColor, CssClass, etc.)
@@ -544,7 +671,9 @@ When making changes, ensure all related files are updated:
544671
| **Existing component modified** | Unit tests in `src/BlazorWebFormsComponents.Test/ComponentName/`, sample page if behavior changed, `docs/Category/ComponentName.md` if API changed |
545672
| **New migration shim added** | Shim class in `src/BlazorWebFormsComponents/`, register in `ServiceCollectionExtensions.cs` via `AddBlazorWebFormsComponents()`, update `docs/Migration/` guide, update `copilot-instructions.md` Migration Shims section |
546673
| **Base class changed** (`BaseWebFormsComponent`, `BaseStyledComponent`, `DataBoundComponent`) | Check all components inheriting from it — changes cascade to every component. Run full test suite. |
547-
| **CLI transform added** | Transform in `src/BlazorWebFormsComponents.Cli/`, test in `tests/BlazorWebFormsComponents.Cli.Tests/`, update `docs/cli/transforms.md`, update `docs/cli/index.md` transform count |
674+
| **CLI transform added** | Transform in `src/BlazorWebFormsComponents.Cli/Transforms/`, register it in `src/BlazorWebFormsComponents.Cli/Program.cs` and `tests/BlazorWebFormsComponents.Cli.Tests/TestHelpers.cs`, add or update transform tests, update `docs/cli/transforms.md`, update `docs/cli/index.md` transform count |
675+
| **CLI scaffolding/runtime changed** | Files in `src/BlazorWebFormsComponents.Cli/Scaffolding/` or `Pipeline/`, matching tests in `tests/BlazorWebFormsComponents.Cli.Tests/`, `migration-toolkit/README.md` or methodology docs if operator workflow changes, and `.github/copilot-instructions.md` if migration guidance changes |
676+
| **Migration toolkit wrapper or skill changed** | Matching files in `migration-toolkit/scripts/` or `migration-toolkit/skills/`, relevant `docs/Migration/` or `docs/cli/` pages, and `.github/copilot-instructions.md` when the recommended migration workflow changes |
548677
| **Analyzer rule added** | Rule in `src/BlazorWebFormsComponents.Analyzers/`, test in `src/BlazorWebFormsComponents.Analyzers.Test/`, update `docs/Analyzers/` |
549678
| **Target framework changed** | `Directory.Build.props` (version properties), all `.csproj` files (`TargetFrameworks`), `global.json`, `.github/workflows/build.yml` (dotnet-version), `.github/copilot-setup-steps.yml` |
550679
| **Documentation added/changed** | `docs/` markdown file, `mkdocs.yml` (`nav:` entry if new), verify local build passes with `docker run --rm -v "$(pwd):/docs" mkdocs build --strict` |

.squad/agents/bishop/history.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
- NEVER replace ListView/FormView/GridView — must use BWFC components (2026-05-07T09:24)
3838

3939
## Learnings
40+
- **2026-05-08T10:00:31-04:00:** `copilot-instructions.md` now needs explicit migration-tooling guidance: start from the CLI wrapper, preserve BWFC data controls, trust `WebFormsPageBase` shims, and keep transform registration instructions paired across `Program.cs` and `TestHelpers.CreateDefaultPipeline()` so future agents can repair WingtipToys-class migrations without outside help.
4041
- **2026-05-07T13:17:32-04:00:** ListView `GroupTemplate` and `LayoutTemplate` emission is more reliable when the CLI emits explicit `Context` names (`items`, `groups`) instead of leaving raw `@context` placeholders. That keeps generated placeholder markup readable and removes one common manual repair step on Wingtip fixtures.
4142
- **2026-05-07T13:17:32-04:00:** Typed `GridView` columns must inherit the parent grid `ItemType`; leaving `TemplateField` at `ItemType="object"` breaks migrated template expressions like `@Item.Quantity`. A dedicated post-attribute-strip pass that rewrites child BWFC column generics to the grid row type fixes this deterministically.
4243
- **2026-05-07T13:58:11-04:00:** Compile-surface quarantine works best as a post-semantic pipeline decision, not just a code-behind transform. Letting semantic patterns normalize login/action pages first avoids quarantining pages the CLI can already turn into SSR-safe stubs.

0 commit comments

Comments
 (0)