Technology and FriendsDustin Campbell on Support for WinForms to the Visual Studio Designer [TECHNOLOGYANDFRIENDS 644]
synopsis
Campbell, an architect in .NET tooling, argues that WinForms on .NET Core needs its Visual Studio designer, and that making it work means moving the designer out of Visual Studio's process. The designer works today; data tooling and third-party controls remain the hard part.
Why a designer. WinForms came to .NET Core 3, but unlike WPF, where many write XAML by hand, WinForms culture is drag and drop, so the designer is essential.
How it works. The designer never compiles your form. It creates the base type, turns InitializeComponent into a CodeDOM model, deserializes that into real objects by reflection, and shows a live form beneath a transparent "sneeze guard" window that captures clicks.
Out of process. Visual Studio runs on .NET Framework, so objects created there would lack new .NET Core APIs. The form is built in a separate .NET Core process and its window parented into Visual Studio, which he says invites cross-process deadlocks. Synchronous APIs from .NET 1.0 are being made asynchronous for a possible future network boundary, such as GitHub Codespaces.
What remains. The data sources window, which loads assemblies and creates instances by reflection, does not work yet, so neither does setting up data binding through it. Control vendors face significant breaking API changes: modal dialogs must stay in Visual Studio while their logic runs elsewhere. Campbell rewrote Microsoft's own dialogs, pulling thousands of lines out of click handlers.
Why bother. The host says vendors still sell far more WinForms controls than others. Campbell, about 14 years at Microsoft after DevExpress, credits skill sets from eight years as the only .NET desktop framework, legacy code, and ease for quick tools. He notes four or five .NET UI frameworks since he joined, while WinForms remained the fallback shipped with Windows.
- WinForms on .NET Core is useless without its drag-and-drop designer. Campbell, an architect in .NET tooling, says WPF developers often write XAML by hand and use the designer as a preview, but WinForms culture is built on the designer; WinForms was ported to .NET Core 3 and the designer, which works in Visual Studio today, has been brought online gradually.
- The designer builds a live, uncompiled form from InitializeComponent. It creates the form's base type, then turns the InitializeComponent code into a CodeDOM model and deserializes that again into real objects through reflection. What the user sees is a real form under a transparent window, the "sneeze guard", that captures clicks for dragging and dropping.
- The designer must run out of process on the target .NET. Visual Studio runs on .NET Framework, so objects created there would miss new .NET Core APIs; the form is created in a separate .NET Core process and its window parented into Visual Studio across processes, which he says invites deadlocks. The team is also making APIs that were synchronous since .NET 1.0 asynchronous, anticipating a possible network boundary with something like GitHub Codespaces.
- Data tooling and third-party controls are the unfinished parts. The data sources window, which loads assemblies and creates instances by reflection, does not work yet, so setting up data binding through it does not either. Control vendors face significant breaking designer API changes: modal editing dialogs must live in Visual Studio while their UI logic runs in the other process, which for Campbell meant refactoring thousands of lines out of click handlers in Microsoft's own dialogs.
- WinForms persists through skill sets, legacy code and sheer ease. Campbell cites about eight years as the only .NET desktop framework before .NET Framework 3 around 2006–2007, its simplicity for quick tools, and XAML being a "mind flip" few even at Microsoft knew. He says Microsoft has built four or five UI frameworks on .NET since he joined, about 14 years ago from DevExpress, while WinForms stayed the fallback shipped with Windows. The host says control vendors tell him they still sell far more WinForms controls than controls for other platforms.