Commit 61d2b5b
authored
fix: resolve builder StackOverflow, activator negative refCount, binding regression, and testing extensions (#4301)
## What's Changed
### Builder converter registration no longer causes StackOverflow
Calling `WithFallbackConverter`, `WithConverter`,
`WithSetMethodConverter`, or `WithConvertersFrom` on
`IReactiveUIBuilder` previously caused a `StackOverflowException` due to
infinite recursion. These methods now work correctly.
### ViewModelActivator no longer goes into a broken state on extra
Deactivate calls
If `Deactivate()` was called more times than `Activate()`, the internal
reference count would go negative, preventing future activations from
working. The activator now safely ignores extra deactivation calls.
### Two-way bindings work again with base types like System.Object
Two-way bindings between a view model property of a derived type (e.g.
`string`) and a view property of a base type (e.g. `object`) were
throwing `ArgumentException`. This is now permitted as expected.
### TestScheduler extensions (AdvanceByMs, AdvanceToMs, etc.) are
discoverable again
After adding the `ReactiveUI.Testing.Reactive` package, `AdvanceByMs`,
`AdvanceToMs`, `OnNextAt`, and related extensions are now available with
just `using ReactiveUI.Testing;` -- no additional namespace import
needed.
Fixes #4293
Fixes #4283
Fixes #4298
Fixes #4297
---
## Maintainer Notes
- **IReactiveUIBuilder.cs**: Added 9 converter method signatures
(`WithConverter` x4, `WithFallbackConverter` x2,
`WithSetMethodConverter` x2, `WithConvertersFrom` x1) to the interface.
These were previously only on the concrete `ReactiveUIBuilder` class,
causing the extension methods in `BuilderMixins.cs` to resolve back to
themselves instead of dispatching to the implementation.
- **ViewModelActivator.cs**: Replaced `Interlocked.Decrement` in
`Deactivate()` with a CAS (CompareExchange) loop that refuses to
decrement below zero. The `ignoreRefCount` path now explicitly resets to
0.
- **PropertyBinderImplementation.cs**: Changed the type assignability
check from `&&` (mutual) to `||` (one-directional). The existing
fallback conversion logic at lines 180-184 already handles
one-directional assignment.
- **TestSchedulerExtensions.cs**: Changed namespace from
`ReactiveUI.Testing.Reactive` to `ReactiveUI.Testing`. The
assembly/package name remains `ReactiveUI.Testing.Reactive` -- the move
to a separate package is intentional to keep `ReactiveUI.Testing` free
of the `Microsoft.Reactive.Testing` dependency.
- **Test updates**: Added new interface members to
`TestReactiveUIBuilder` mock in Blazor tests, removed now-unnecessary
`using ReactiveUI.Testing.Reactive` from scheduler tests.1 parent db239a9 commit 61d2b5b
13 files changed
Lines changed: 218 additions & 1896 deletions
File tree
- src
- ReactiveUI.Testing.Reactive
- ReactiveUI
- Activation
- Bindings/Property
- Builder
- tests
- ReactiveUI.Blazor.Tests
- ReactiveUI.Builder.Tests
- ReactiveUI.Testing.Tests
- ReactiveUI.Tests/API
- ReactiveUI.Wpf.Tests/Wpf
This file was deleted.
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
93 | | - | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
94 | 117 | | |
95 | 118 | | |
96 | 119 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
103 | | - | |
| 103 | + | |
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
219 | 219 | | |
220 | 220 | | |
221 | 221 | | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
222 | 289 | | |
223 | 290 | | |
224 | 291 | | |
| |||
Lines changed: 18 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
259 | 259 | | |
260 | 260 | | |
261 | 261 | | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
262 | 280 | | |
263 | 281 | | |
Lines changed: 70 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
128 | 187 | | |
129 | 188 | | |
130 | 189 | | |
| |||
150 | 209 | | |
151 | 210 | | |
152 | 211 | | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
153 | 223 | | |
Lines changed: 0 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | | - | |
12 | 10 | | |
13 | 11 | | |
14 | 12 | | |
| |||
Lines changed: 9 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2040 | 2040 | | |
2041 | 2041 | | |
2042 | 2042 | | |
| 2043 | + | |
| 2044 | + | |
| 2045 | + | |
| 2046 | + | |
| 2047 | + | |
2043 | 2048 | | |
| 2049 | + | |
| 2050 | + | |
2044 | 2051 | | |
2045 | 2052 | | |
2046 | 2053 | | |
| |||
2066 | 2073 | | |
2067 | 2074 | | |
2068 | 2075 | | |
| 2076 | + | |
| 2077 | + | |
2069 | 2078 | | |
2070 | 2079 | | |
2071 | 2080 | | |
| |||
0 commit comments