From 6f2ffb2f3de76d607c510dcb2e49f72d63baeb3d Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Fri, 18 Jan 2019 18:14:29 +0100 Subject: [PATCH 1/3] Updated PR template. --- .github/PULL_REQUEST_TEMPLATE.md | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 9a0da4aa9b..78b9cff039 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,16 +1,31 @@ -This template is not intended to be prescriptive, but to help us review pull requests it would be useful if you included as much of the following information as possible: +## What does the pull request do? -- What does the pull request do? -- What is the current behavior? -- What is the updated/expected behavior with this PR? -- How was the solution implemented (if it's not obvious)? +Give a bit of background on the PR here, together with links to with related issues etc. -Checklist: +## What is the current behavior? + +If the PR is a fix, describe the current incorrect behavior, otherwise delete this section. + +## What is the updated/expected behavior with this PR? + +Describe how to test the PR. + +## How was the solution implemented (if it's not obvious)? + +Include any information that might be of use to a reviewer here. + +## Checklist - [ ] Added unit tests (if possible)? - [ ] Added XML documentation to any related classes? - [ ] Consider submitting a PR to https://github.com/AvaloniaUI/Avaloniaui.net with user documentation +## Breaking changes + +List any breaking changes here. When the PR is merged please add an entry to https://github.com/AvaloniaUI/Avalonia/wiki/Breaking-Changes + +## Fixed issues + If the pull request fixes issue(s) list them like this: Fixes #123 From b91df127eaaeec4972e0035fb4602a7666cc4a64 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Sat, 19 Jan 2019 01:09:58 +0100 Subject: [PATCH 2/3] Remove :valid and :invalid pseudoclasses. `:valid` and `:invalid` pseudoclasses are being added to all `ContentControls` simply in order to show/hide the `ContentPresenter` in `CheckBox`. Instead of this, add some `ObjectConverters` and use them to set the visibility of the `ContentPresenter.` Also renamed the converters in `StringConverters` to add an `Is` prefix as the `ObjectConverters` didn't look right as just `Null` and `NotNull`. --- .../Data/Converters/ObjectConverters.cs | 24 +++++++++++++++++++ .../Data/Converters/StringConverters.cs | 4 ++-- src/Avalonia.Controls/ContentControl.cs | 2 -- src/Avalonia.Themes.Default/CheckBox.xaml | 9 ++++--- src/Avalonia.Themes.Default/TextBox.xaml | 4 ++-- 5 files changed, 32 insertions(+), 11 deletions(-) create mode 100644 src/Avalonia.Base/Data/Converters/ObjectConverters.cs diff --git a/src/Avalonia.Base/Data/Converters/ObjectConverters.cs b/src/Avalonia.Base/Data/Converters/ObjectConverters.cs new file mode 100644 index 0000000000..3cadfd5b47 --- /dev/null +++ b/src/Avalonia.Base/Data/Converters/ObjectConverters.cs @@ -0,0 +1,24 @@ +// Copyright (c) The Avalonia Project. All rights reserved. +// Licensed under the MIT license. See licence.md file in the project root for full license information. + + +namespace Avalonia.Data.Converters +{ + /// + /// Provides a set of useful s for working with objects. + /// + public static class ObjectConverters + { + /// + /// A value converter that returns true if the input object is a null reference. + /// + public static readonly IValueConverter IsNull = + new FuncValueConverter(x => x is null); + + /// + /// A value converter that returns true if the input object is not null. + /// + public static readonly IValueConverter IsNotNull = + new FuncValueConverter(x => !(x is null)); + } +} diff --git a/src/Avalonia.Base/Data/Converters/StringConverters.cs b/src/Avalonia.Base/Data/Converters/StringConverters.cs index 0101cf5d29..42eb8e1d81 100644 --- a/src/Avalonia.Base/Data/Converters/StringConverters.cs +++ b/src/Avalonia.Base/Data/Converters/StringConverters.cs @@ -12,13 +12,13 @@ namespace Avalonia.Data.Converters /// /// A value converter that returns true if the input string is null or an empty string. /// - public static readonly IValueConverter NullOrEmpty = + public static readonly IValueConverter IsNullOrEmpty = new FuncValueConverter(string.IsNullOrEmpty); /// /// A value converter that returns true if the input string is not null or empty. /// - public static readonly IValueConverter NotNullOrEmpty = + public static readonly IValueConverter IsNotNullOrEmpty = new FuncValueConverter(x => !string.IsNullOrEmpty(x)); } } diff --git a/src/Avalonia.Controls/ContentControl.cs b/src/Avalonia.Controls/ContentControl.cs index 20ec581108..6da6da54a5 100644 --- a/src/Avalonia.Controls/ContentControl.cs +++ b/src/Avalonia.Controls/ContentControl.cs @@ -45,8 +45,6 @@ namespace Avalonia.Controls static ContentControl() { ContentControlMixin.Attach(ContentProperty, x => x.LogicalChildren); - PseudoClass(ContentProperty, x => x != null, ":valid"); - PseudoClass(ContentProperty, x => x == null, ":invalid"); } /// diff --git a/src/Avalonia.Themes.Default/CheckBox.xaml b/src/Avalonia.Themes.Default/CheckBox.xaml index e2301b9b09..f87ae2674f 100644 --- a/src/Avalonia.Themes.Default/CheckBox.xaml +++ b/src/Avalonia.Themes.Default/CheckBox.xaml @@ -1,9 +1,10 @@ - + - diff --git a/src/Avalonia.Themes.Default/TextBox.xaml b/src/Avalonia.Themes.Default/TextBox.xaml index 90100c2f2b..6741bdc7d9 100644 --- a/src/Avalonia.Themes.Default/TextBox.xaml +++ b/src/Avalonia.Themes.Default/TextBox.xaml @@ -23,7 +23,7 @@ Path="UseFloatingWatermark"/> + Converter="{x:Static StringConverters.IsNotNullOrEmpty}"/> @@ -36,7 +36,7 @@ + IsVisible="{TemplateBinding Text, Converter={x:Static StringConverters.IsNullOrEmpty}}"/> Date: Sat, 19 Jan 2019 02:45:59 +0100 Subject: [PATCH 3/3] Fix tests. --- .../Data/BindingTests_Converters.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/Avalonia.Markup.UnitTests/Data/BindingTests_Converters.cs b/tests/Avalonia.Markup.UnitTests/Data/BindingTests_Converters.cs index 123aadfda5..1ede4ee0b0 100644 --- a/tests/Avalonia.Markup.UnitTests/Data/BindingTests_Converters.cs +++ b/tests/Avalonia.Markup.UnitTests/Data/BindingTests_Converters.cs @@ -22,14 +22,14 @@ namespace Avalonia.Markup.UnitTests.Data var target = new Binding(nameof(Class1.Foo)) { - Converter = StringConverters.NullOrEmpty, + Converter = StringConverters.IsNullOrEmpty, }; var expressionObserver = (BindingExpression)target.Initiate( textBlock, TextBlock.TextProperty).Observable; - Assert.Same(StringConverters.NullOrEmpty, expressionObserver.Converter); + Assert.Same(StringConverters.IsNullOrEmpty, expressionObserver.Converter); } public class When_Binding_To_String @@ -129,7 +129,7 @@ namespace Avalonia.Markup.UnitTests.Data var target = new Binding(nameof(Class1.Foo)) { - Converter = StringConverters.NotNullOrEmpty, + Converter = StringConverters.IsNotNullOrEmpty, StringFormat = "Hello {0}", };