Repository navigation
Commit d9133b6
authored
fix: support .NET Core in winforms activation design mode check (#4358)
## 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
- [X] I have read the [Contribute
guide](https://www.reactiveui.net/contribute/index.html)
- [ ] Tests have been added or updated (for bug fixes / features)
- [ ] Docs have been added or updated (for bug fixes / features)
- [X] Changes target the `main` branch
- [X] PR title follows [Conventional
Commits](https://www.conventionalcommits.org/)
## 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.1 parent bd27fbc commit d9133b6
2 files changed
Lines changed: 42 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
| 30 | + | |
29 | 31 | | |
30 | 32 | | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | 33 | | |
37 | 34 | | |
38 | 35 | | |
| |||
48 | 45 | | |
49 | 46 | | |
50 | 47 | | |
51 | | - | |
52 | | - | |
| 48 | + | |
53 | 49 | | |
54 | 50 | | |
55 | 51 | | |
| |||
61 | 57 | | |
62 | 58 | | |
63 | 59 | | |
64 | | - | |
65 | | - | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
66 | 66 | | |
67 | 67 | | |
68 | | - | |
| 68 | + | |
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | 89 | | |
93 | 90 | | |
94 | | - | |
| 91 | + | |
95 | 92 | | |
96 | 93 | | |
97 | 94 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
0 commit comments