Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(TextBox): Setting TextBox.Text to null should only throw in UWP #11113

Merged
merged 2 commits into from
Jan 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,19 @@ public void When_Setting_Text_Null()
textBox.Text = "Rhubarb";
Assert.AreEqual("Rhubarb", textBox.Text);
Assert.AreEqual(1, callbackCount);


#if !HAS_UNO_WINUI
// Setting TextBox.Text to null throws an exception in UWP but not WinUI.
Assert.ThrowsException<ArgumentNullException>(() => textBox.Text = null);
#endif

Assert.AreEqual("Rhubarb", textBox.Text);
Assert.AreEqual(1, callbackCount);

#if HAS_UNO_WINUI
textBox.Text = null;
Assert.AreEqual("", textBox.Text);
#endif
}

[TestMethod]
Expand Down
4 changes: 4 additions & 0 deletions src/Uno.UI/UI/Xaml/Controls/TextBox/TextBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,11 @@ public string Text
{
if (value == null)
{
#if HAS_UNO_WINUI
value = string.Empty;
#else
throw new ArgumentNullException();
#endif
}

this.SetValue(TextProperty, value);
Expand Down