Skip to content

Use BooleanBoxes for default values in DependencyProperty metadata #10711

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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 @@ -5,6 +5,8 @@
global using System.Collections.Generic;
global using System.Diagnostics;

global using MS.Internal.KnownBoxes;

global using DataFormatsCore = System.Private.Windows.Ole.DataFormatsCore<
System.Windows.DataFormat>;
#pragma warning disable IDE0005 // Using directive is unnecessary.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace System.Windows.Automation
Expand Down Expand Up @@ -246,7 +246,7 @@ public static string GetItemType(DependencyObject element)
"IsColumnHeader",
typeof(bool),
typeof(AutomationProperties),
new UIPropertyMetadata(MS.Internal.KnownBoxes.BooleanBoxes.FalseBox));
new UIPropertyMetadata(BooleanBoxes.FalseBox));

/// <summary>
/// Helper for setting IsColumnHeader property on a DependencyObject.
Expand Down Expand Up @@ -278,7 +278,7 @@ public static bool GetIsColumnHeader(DependencyObject element)
"IsRowHeader",
typeof(bool),
typeof(AutomationProperties),
new UIPropertyMetadata(MS.Internal.KnownBoxes.BooleanBoxes.FalseBox));
new UIPropertyMetadata(BooleanBoxes.FalseBox));

/// <summary>
/// Helper for setting IsRowHeader property on a DependencyObject.
Expand Down Expand Up @@ -310,7 +310,7 @@ public static bool GetIsRowHeader(DependencyObject element)
"IsRequiredForForm",
typeof(bool),
typeof(AutomationProperties),
new UIPropertyMetadata(MS.Internal.KnownBoxes.BooleanBoxes.FalseBox));
new UIPropertyMetadata(BooleanBoxes.FalseBox));

/// <summary>
/// Helper for setting IsRequiredForForm property on a DependencyObject.
Expand Down Expand Up @@ -536,7 +536,7 @@ public static AutomationHeadingLevel GetHeadingLevel(DependencyObject element)
"IsDialog",
typeof(bool),
typeof(AutomationProperties),
new UIPropertyMetadata(false));
new UIPropertyMetadata(BooleanBoxes.FalseBox));

/// <summary>
/// Helper for setting IsDialog property on a DependencyObject.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

using MS.Internal;
using MS.Internal.Interop;
using MS.Internal.KnownBoxes;
using MS.Internal.PresentationCore;
using System.Windows.Automation;
using System.Windows.Automation.Peers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using MS.Utility;
using MS.Internal;
using MS.Internal.KnownBoxes;

namespace System.Windows
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using MS.Internal.KnownBoxes;

namespace System.Windows
{
/////////////////////////////////////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
//

using MS.Internal;
using MS.Internal.KnownBoxes;
using MS.Utility;
using System.ComponentModel;
using System.Windows.Input;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
//

using MS.Internal;
using MS.Internal.KnownBoxes;
using MS.Utility;
using System.ComponentModel;
using System.Windows.Input;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
//

using MS.Internal;
using MS.Internal.KnownBoxes;
using MS.Utility;
using System.ComponentModel;
using System.Windows.Input;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

//
//

using System.ComponentModel;
using System.Windows.Media;
using System.Windows.Media.Media3D;
using MS.Internal.KnownBoxes;


namespace System.Windows.Input
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public static CultureInfo GetInputLanguage(DependencyObject target)
"RestoreInputLanguage",
typeof(bool),
typeof(InputLanguageManager),
new PropertyMetadata(false)
new PropertyMetadata(BooleanBoxes.FalseBox)
);

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ internal InputMethod()
typeof(bool),
typeof(InputMethod),
new PropertyMetadata(
true,
BooleanBoxes.TrueBox,
new PropertyChangedCallback(IsInputMethodEnabled_Changed)));

/// <summary>
Expand Down Expand Up @@ -247,7 +247,7 @@ public static bool GetIsInputMethodEnabled(DependencyObject target)
"IsInputMethodSuspended",
typeof(bool),
typeof(InputMethod),
new PropertyMetadata(false));
new PropertyMetadata(BooleanBoxes.FalseBox));

/// <summary>
/// Setter for IsInputMethodSuspended DependencyProperty
Expand Down Expand Up @@ -379,7 +379,7 @@ public static ImeSentenceModeValues GetPreferredImeSentenceMode(DependencyObject
"InputScope",
typeof(InputScope),
typeof(InputMethod),
new PropertyMetadata((InputScope) null));
new PropertyMetadata((InputScope)null));

/// <summary>
/// Setter for InputScope DependencyProperty
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace System.Windows.Input
Expand Down Expand Up @@ -602,7 +602,7 @@ public static void SetIsPressAndHoldEnabled(DependencyObject element, bool enabl
/// <seealso cref="Stylus.GetIsPressAndHoldEnabled" />
/// <seealso cref="Stylus.SetIsPressAndHoldEnabled" />
public static readonly DependencyProperty IsPressAndHoldEnabledProperty
= DependencyProperty.RegisterAttached("IsPressAndHoldEnabled", typeof(bool), typeof(Stylus), new PropertyMetadata(true)); // note we can't specify inherits in frameworkcore. new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.Inherits)
= DependencyProperty.RegisterAttached("IsPressAndHoldEnabled", typeof(bool), typeof(Stylus), new PropertyMetadata(BooleanBoxes.TrueBox)); // note we can't specify inherits in frameworkcore. new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.Inherits)


/// <summary>
Expand Down Expand Up @@ -642,7 +642,7 @@ public static void SetIsFlicksEnabled(DependencyObject element, bool enabled)
/// <seealso cref="Stylus.GetIsFlicksEnabled" />
/// <seealso cref="Stylus.SetIsFlicksEnabled" />
public static readonly DependencyProperty IsFlicksEnabledProperty
= DependencyProperty.RegisterAttached("IsFlicksEnabled", typeof(bool), typeof(Stylus), new PropertyMetadata(true)); // note we can't specify inherits in frameworkcore. new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.Inherits)
= DependencyProperty.RegisterAttached("IsFlicksEnabled", typeof(bool), typeof(Stylus), new PropertyMetadata(BooleanBoxes.TrueBox)); // note we can't specify inherits in frameworkcore. new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.Inherits)


/// <summary>
Expand Down Expand Up @@ -682,7 +682,7 @@ public static void SetIsTapFeedbackEnabled(DependencyObject element, bool enable
/// <seealso cref="Stylus.GetIsTapFeedbackEnabled" />
/// <seealso cref="Stylus.SetIsTapFeedbackEnabled" />
public static readonly DependencyProperty IsTapFeedbackEnabledProperty
= DependencyProperty.RegisterAttached("IsTapFeedbackEnabled", typeof(bool), typeof(Stylus), new PropertyMetadata(true)); // note we can't specify inherits in frameworkcore. new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.Inherits)
= DependencyProperty.RegisterAttached("IsTapFeedbackEnabled", typeof(bool), typeof(Stylus), new PropertyMetadata(BooleanBoxes.TrueBox)); // note we can't specify inherits in frameworkcore. new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.Inherits)


/// <summary>
Expand Down Expand Up @@ -721,7 +721,7 @@ public static void SetIsTouchFeedbackEnabled(DependencyObject element, bool enab
/// <seealso cref="Stylus.GetIsTouchFeedbackEnabled" />
/// <seealso cref="Stylus.SetIsTouchFeedbackEnabled" />
public static readonly DependencyProperty IsTouchFeedbackEnabledProperty
= DependencyProperty.RegisterAttached("IsTouchFeedbackEnabled", typeof(bool), typeof(Stylus), new PropertyMetadata(true)); // note we can't specify inherits in frameworkcore. new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.Inherits)
= DependencyProperty.RegisterAttached("IsTouchFeedbackEnabled", typeof(bool), typeof(Stylus), new PropertyMetadata(BooleanBoxes.TrueBox)); // note we can't specify inherits in frameworkcore. new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.Inherits)


/////////////////////////////////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System.Windows.Media.Media3D;
using System.Windows.Threading;
using MS.Internal;
using MS.Internal.KnownBoxes;
using MS.Utility;
using System.Windows.Input.Tracing;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
// An ImageSource that displays a user created D3D surface

using MS.Internal;
using MS.Internal.KnownBoxes;
using MS.Win32.PresentationCore;
using System.ComponentModel;
using System.Windows.Media;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ private static void AnimationTimeline_PropertyChangedFunction(DependencyObject d
"IsAdditive", // Property Name
typeof(bool), // Property Type
typeof(AnimationTimeline), // Owner Class
new PropertyMetadata(false,
new PropertyMetadata(BooleanBoxes.FalseBox,
new PropertyChangedCallback(AnimationTimeline_PropertyChangedFunction)));

/// <summary>
Expand All @@ -43,7 +43,7 @@ private static void AnimationTimeline_PropertyChangedFunction(DependencyObject d
"IsCumulative", // Property Name
typeof(bool), // Property Type
typeof(AnimationTimeline), // Owner Class
new PropertyMetadata(false,
new PropertyMetadata(BooleanBoxes.FalseBox,
new PropertyChangedCallback(AnimationTimeline_PropertyChangedFunction)));

#endregion
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

//
//

using MS.Internal.KnownBoxes;

namespace System.Windows.Media.Animation
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// Please see MilCodeGen.html for more information.
//

using MS.Internal.KnownBoxes;
using System.Collections;
using System.ComponentModel;
using System.Windows.Markup;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// Please see MilCodeGen.html for more information.
//

using MS.Internal.KnownBoxes;
using System.Globalization;
using System.Windows.Media.Media3D;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// Please see MilCodeGen.html for more information.
//

using MS.Internal.KnownBoxes;
using System.Collections;
using System.ComponentModel;
using System.Windows.Markup;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// Please see MilCodeGen.html for more information.
//

using MS.Internal.KnownBoxes;
using System.Collections;
using System.ComponentModel;
using System.Windows.Markup;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// Please see MilCodeGen.html for more information.
//

using MS.Internal.KnownBoxes;
using System.Globalization;
using System.Windows.Media.Media3D;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// Please see MilCodeGen.html for more information.
//

using MS.Internal.KnownBoxes;
using System.Collections;
using System.ComponentModel;
using System.Windows.Markup;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// Please see MilCodeGen.html for more information.
//

using MS.Internal.KnownBoxes;
using System.Globalization;
using System.Windows.Media.Media3D;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// Please see MilCodeGen.html for more information.
//

using MS.Internal.KnownBoxes;
using System.Collections;
using System.ComponentModel;
using System.Windows.Markup;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// Please see MilCodeGen.html for more information.
//

using MS.Internal.KnownBoxes;
using System.Globalization;
using System.Windows.Media.Media3D;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// Please see MilCodeGen.html for more information.
//

using MS.Internal.KnownBoxes;
using System.Collections;
using System.ComponentModel;
using System.Windows.Markup;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// Please see MilCodeGen.html for more information.
//

using MS.Internal.KnownBoxes;
using System.Globalization;
using System.Windows.Media.Media3D;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// Please see MilCodeGen.html for more information.
//

using MS.Internal.KnownBoxes;
using System.Collections;
using System.ComponentModel;
using System.Windows.Markup;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// Please see MilCodeGen.html for more information.
//

using MS.Internal.KnownBoxes;
using System.Globalization;
using System.Windows.Media.Media3D;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// Please see MilCodeGen.html for more information.
//

using MS.Internal.KnownBoxes;
using System.Collections;
using System.ComponentModel;
using System.Windows.Markup;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// Please see MilCodeGen.html for more information.
//

using MS.Internal.KnownBoxes;
using System.Globalization;
using System.Windows.Media.Media3D;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// Please see MilCodeGen.html for more information.
//

using MS.Internal.KnownBoxes;
using System.Collections;
using System.ComponentModel;
using System.Windows.Markup;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// Please see MilCodeGen.html for more information.
//

using MS.Internal.KnownBoxes;
using System.Collections;
using System.ComponentModel;
using System.Windows.Markup;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// Please see MilCodeGen.html for more information.
//

using MS.Internal.KnownBoxes;
using System.Collections;
using System.ComponentModel;
using System.Windows.Markup;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// Please see MilCodeGen.html for more information.
//

using MS.Internal.KnownBoxes;
using System.Globalization;
using System.Windows.Media.Media3D;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// Please see MilCodeGen.html for more information.
//

using MS.Internal.KnownBoxes;
using System.Collections;
using System.ComponentModel;
using System.Windows.Markup;
Expand Down
Loading