Skip to content

Commit ef37b28

Browse files
committed
fix(xBind): [Wasm] Fix invalid internal ElementStub state
1 parent 74bf88b commit ef37b28

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Given_xLoad.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,15 @@ public async Task When_xLoad_xBind()
4747
sut.IsLoad = false;
4848

4949
Assert.IsFalse((parent.Child as ElementStub).Load);
50+
51+
sut.IsLoad = true;
52+
53+
Assert.IsNotNull(sut.LoadBorder);
54+
parent = sut.LoadBorder.Parent as Border;
55+
56+
sut.IsLoad = false;
57+
58+
Assert.IsFalse((parent.Child as ElementStub).Load);
5059
}
5160

5261
[TestMethod]

src/Uno.UI/UI/Xaml/ElementStub.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
using System.Collections.Generic;
44
using System.ComponentModel;
55
using System.Text;
6+
using Uno.Extensions;
7+
using Uno.Logging;
68
using Uno.UI;
79
using Uno.UI.DataBinding;
810

@@ -177,6 +179,11 @@ private void RaiseMaterializing()
177179

178180
private void Materialize(bool isVisibilityChanged)
179181
{
182+
if(this.Log().IsEnabled(Microsoft.Extensions.Logging.LogLevel.Debug))
183+
{
184+
this.Log().Debug($"ElementStub.Materialize(isVibilityChanged: {isVisibilityChanged})");
185+
}
186+
180187
if (_content == null && !_isMaterializing)
181188
{
182189
#if !HAS_EXPENSIVE_TRYFINALLY // Try/finally incurs a very large performance hit in mono-wasm - https://github.com/dotnet/runtime/issues/50783
@@ -203,15 +210,20 @@ private void Materialize(bool isVisibilityChanged)
203210
#if !HAS_EXPENSIVE_TRYFINALLY // Try/finally incurs a very large performance hit in mono-wasm - https://github.com/dotnet/runtime/issues/50783
204211
}
205212
finally
213+
#endif
206214
{
207215
_isMaterializing = false;
208216
}
209-
#endif
210217
}
211218
}
212219

213220
private void Dematerialize()
214221
{
222+
if (this.Log().IsEnabled(Microsoft.Extensions.Logging.LogLevel.Debug))
223+
{
224+
this.Log().Debug($"ElementStub.Dematerialize()");
225+
}
226+
215227
if (_content != null)
216228
{
217229
var newView = SwapViews(oldView: (FrameworkElement)_content, newViewProvider: () => this as View);

0 commit comments

Comments
 (0)