Skip to content

fix: support .NET Core in winforms activation design mode check#4358

Merged
glennawatson merged 3 commits into
reactiveui:mainfrom
xackus:fix-winforms-designmode-check
May 17, 2026
Merged

fix: support .NET Core in winforms activation design mode check#4358
glennawatson merged 3 commits into
reactiveui:mainfrom
xackus:fix-winforms-designmode-check

Conversation

@xackus
Copy link
Copy Markdown
Contributor

@xackus xackus commented May 16, 2026

What kind of change does this PR introduce?

  1. Delay the design mode check in Winforms activation until after the control is sited.
  2. Use Control.IsAncestorSiteInDesignMode (polyfilled on older targets) to support deeply nested controls.
  3. Remove the LicenseManager.UsageMode check because it doesn't work on .NET Core and is no longer needed on .NET Framework after the other fixes.
  4. While at it, reduce nesting of RX operators if the control is a Form.

What is the current behavior?

Design mode detection is broken on .NET Core.

  1. The detection is done too early. Controls are not yet sited in their constructor, so control.Site?.DesignMode is never true.
    LicenseManager is not supported on .NET Core. LicenseManager.UsageMode == LicenseUsageMode.Designtime is always false.

  2. Design mode detection does not support deeply nested controls.
    Only the current control and its parent are checked for design mode.

What is the new behavior?

Design mode detection works both on .NET Framework and .NET Core and supports deeply nested controls.

What might this PR break?

This shouldn't change anything at runtime, only design time.

Checklist

  • I have read the Contribute guide
  • Tests have been added or updated (for bug fixes / features)
  • Docs have been added or updated (for bug fixes / features)
  • Changes target the main branch
  • PR title follows Conventional Commits

Additional information

Manually tested on net481 and net10.0-windows10.0.19041.0.

There are still more issues with the Winforms Designer.
Unless you inherit your controls from a base class that ensures ReactiveUI is initialized in its constructor, WhenActivated fails to resolve IActivationForViewFetcher.
I don't know how to fix this in a way that can be upstreamed.

xackus added 2 commits May 16, 2026 18:22
* Delay the check. Controls are not yet sited while
  their constructor is running.
* Use Control.IsAncestorSiteInDesignMode to support
  arbitrarily deeply nested controls.
Comment thread src/ReactiveUI.Winforms/ControlPolyfills.cs Outdated
@glennawatson glennawatson merged commit d9133b6 into reactiveui:main May 17, 2026
8 of 9 checks passed
@glennawatson
Copy link
Copy Markdown
Contributor

Might be about a week before we release btw. Just waiting on validation of a new code signing certificate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants