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

Remove SAL annotations and cleanup BUILD_WINDOWS #1102

Merged
merged 9 commits into from Jul 29, 2019
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions dev/AnimatedVisualPlayer/AnimatedVisualPlayer.cpp
Expand Up @@ -558,10 +558,10 @@ winrt::Size AnimatedVisualPlayer::ArrangeOverride(winrt::Size const& finalSize)
}

winrt::DependencyProperty InitializeDp(
_In_ wstring_view const& propertyNameString,
_In_ wstring_view const& propertyTypeNameString,
_In_opt_ const winrt::IInspectable& defaultValue,
_In_opt_ const winrt::PropertyChangedCallback& propertyChangedCallback = nullptr)
wstring_view const& propertyNameString,
wstring_view const& propertyTypeNameString,
winrt::IInspectable const& defaultValue,
winrt::PropertyChangedCallback const& propertyChangedCallback = nullptr)
{
// There are no attached properties.
auto isAttached = false;
Expand Down
Expand Up @@ -18,19 +18,11 @@
using Microsoft.VisualStudio.TestTools.UnitTesting.Logging;
#endif

#if BUILD_WINDOWS
using System.Windows.Automation;
using MS.Internal.Mita.Foundation;
using MS.Internal.Mita.Foundation.Controls;
using MS.Internal.Mita.Foundation.Waiters;
#else
using Microsoft.Windows.Apps.Test.Automation;
using Microsoft.Windows.Apps.Test.Foundation;
using Microsoft.Windows.Apps.Test.Foundation.Controls;
using Microsoft.Windows.Apps.Test.Foundation.Patterns;
using Microsoft.Windows.Apps.Test.Foundation.Waiters;
#endif


// CatGates requires that test namespaces begin with "Windows.UI.Xaml.Tests",
// so we need to make sure that our test namespace begins with that to ensure that we get picked up.
Expand Down
4 changes: 0 additions & 4 deletions dev/ColorPicker/APITests/ColorPickerTests.cs
Expand Up @@ -26,14 +26,12 @@
using Microsoft.VisualStudio.TestTools.UnitTesting.Logging;
#endif

#if !BUILD_WINDOWS
using ColorSpectrumShape = Microsoft.UI.Xaml.Controls.ColorSpectrumShape;
using ColorSpectrumComponents = Microsoft.UI.Xaml.Controls.ColorSpectrumComponents;
using ColorPicker = Microsoft.UI.Xaml.Controls.ColorPicker;
using ColorChangedEventArgs = Microsoft.UI.Xaml.Controls.ColorChangedEventArgs;
using ColorSpectrum = Microsoft.UI.Xaml.Controls.Primitives.ColorSpectrum;
using XamlControlsXamlMetaDataProvider = Microsoft.UI.Xaml.XamlTypeInfo.XamlControlsXamlMetaDataProvider;
#endif

namespace Windows.UI.Xaml.Tests.MUXControls.ApiTests
{
Expand Down Expand Up @@ -268,7 +266,6 @@ public void ValidateFractionalWidthDoesNotCrash()

// XamlControlsXamlMetaDataProvider does not exist in the OS repo,
// so we can't execute this test as authored there.
#if !BUILD_WINDOWS
[TestMethod]
public void VerifyColorPropertyMetadata()
{
Expand All @@ -281,7 +278,6 @@ public void VerifyColorPropertyMetadata()
Verify.AreEqual(memberType.BaseType.FullName, "ValueType");
});
}
#endif

// This takes a FrameworkElement parameter so you can pass in either a ColorPicker or a ColorSpectrum.
private void SetAsRootAndWaitForColorSpectrumFill(FrameworkElement element)
Expand Down
62 changes: 25 additions & 37 deletions dev/ColorPicker/ColorPicker.cpp
Expand Up @@ -805,9 +805,10 @@ void ColorPicker::OnRgbTextChanging(winrt::TextBox const& sender, winrt::TextBox

// We'll respond to the text change if the user has entered a valid value.
// Otherwise, we'll do nothing except mark the text box's contents as invalid.
unsigned long componentValue;

if (TryParseInt(sender.Text(), &componentValue) == false || componentValue < 0 || componentValue > 255)
auto componentValue = TryParseInt(sender.Text());
if (!componentValue.has_value() ||
componentValue.value() < 0 ||
componentValue.value() > 255)
{
m_isFocusedTextBoxValid = false;
}
Expand All @@ -830,12 +831,10 @@ void ColorPicker::OnHueTextChanging(winrt::TextBox const& /*sender*/, winrt::Tex

// We'll respond to the text change if the user has entered a valid value.
// Otherwise, we'll do nothing except mark the text box's contents as invalid.
unsigned long hueValue;

int minHue = MinHue();
int maxHue = MaxHue();

if (TryParseInt(m_hueTextBox.Text(), &hueValue) == false || hueValue < static_cast<unsigned long>(minHue) || hueValue > static_cast<unsigned long>(maxHue))
auto hueValue = TryParseInt(m_hueTextBox.Text());
if (!hueValue.has_value() ||
hueValue.value() < static_cast<unsigned long>(MinHue()) ||
hueValue.value() > static_cast<unsigned long>(MaxHue()))
{
m_isFocusedTextBoxValid = false;
}
Expand All @@ -858,12 +857,10 @@ void ColorPicker::OnSaturationTextChanging(winrt::TextBox const& /*sender*/, win

// We'll respond to the text change if the user has entered a valid value.
// Otherwise, we'll do nothing except mark the text box's contents as invalid.
unsigned long saturationValue;

int minSaturation = MinSaturation();
int maxSaturation = MaxSaturation();

if (TryParseInt(m_saturationTextBox.Text(), &saturationValue) == false || saturationValue < static_cast<unsigned long>(minSaturation) || saturationValue > static_cast<unsigned long>(maxSaturation))
auto saturationValue = TryParseInt(m_saturationTextBox.Text());
if (!saturationValue.has_value() ||
saturationValue.value() < static_cast<unsigned long>(MinSaturation()) ||
saturationValue.value() > static_cast<unsigned long>(MaxSaturation()))
{
m_isFocusedTextBoxValid = false;
}
Expand All @@ -886,12 +883,10 @@ void ColorPicker::OnValueTextChanging(winrt::TextBox const& /*sender*/, winrt::T

// We'll respond to the text change if the user has entered a valid value.
// Otherwise, we'll do nothing except mark the text box's contents as invalid.
unsigned long valueValue;

int minValue = MinValue();
int maxValue = MaxValue();

if (TryParseInt(m_valueTextBox.Text(), &valueValue) == false || valueValue < static_cast<unsigned long>(minValue) || valueValue > static_cast<unsigned long>(maxValue))
auto value = TryParseInt(m_valueTextBox.Text());
if (!value.has_value() ||
value.value() < static_cast<unsigned long>(MinValue()) ||
value.value() > static_cast<unsigned long>(MaxValue()))
{
m_isFocusedTextBoxValid = false;
}
Expand Down Expand Up @@ -926,17 +921,16 @@ void ColorPicker::OnAlphaTextChanging(winrt::TextBox const& /*sender*/, winrt::T

// We'll respond to the text change if the user has entered a valid value.
// Otherwise, we'll do nothing except mark the text box's contents as invalid.
unsigned long alphaValue;
winrt::hstring alphaString{ static_cast<wstring>(m_alphaTextBox.Text()).substr(0, m_alphaTextBox.Text().size() - 1) };

if (TryParseInt(alphaString, &alphaValue) == false || alphaValue < 0 || alphaValue > 100)
auto alphaValue = TryParseInt(alphaString);
if (!alphaValue.has_value() || alphaValue.value() < 0 || alphaValue.value() > 100)
{
m_isFocusedTextBoxValid = false;
}
else
{
m_isFocusedTextBoxValid = true;
UpdateColor(alphaValue / 100.0, ColorUpdateReason::AlphaTextBoxChanged);
UpdateColor(alphaValue.value() / 100.0, ColorUpdateReason::AlphaTextBoxChanged);
}
}

Expand All @@ -961,17 +955,11 @@ void ColorPicker::OnHexTextChanging(winrt::TextBox const& /*sender*/, winrt::Tex
// We'll respond to the text change if the user has entered a valid value.
// Otherwise, we'll do nothing except mark the text box's contents as invalid.
bool isAlphaEnabled = IsAlphaEnabled();
Rgb rgbValue;
double alphaValue = 1.0;

if (isAlphaEnabled)
{
HexToRgba(m_hexTextBox.Text(), &rgbValue, &alphaValue);
}
else
{
rgbValue = HexToRgb(m_hexTextBox.Text());
}
auto [rgbValue, alphaValue] = [this, isAlphaEnabled]() {
return isAlphaEnabled?
ranjeshj marked this conversation as resolved.
Show resolved Hide resolved
HexToRgba(m_hexTextBox.Text()):
std::make_tuple<Rgb, double>(HexToRgb(m_hexTextBox.Text()), 1.0);
ranjeshj marked this conversation as resolved.
Show resolved Hide resolved
}();

if ((rgbValue.r == -1 && rgbValue.g == -1 && rgbValue.b == -1 && alphaValue == -1) || alphaValue < 0 || alphaValue > 1)
{
Expand Down Expand Up @@ -1255,4 +1243,4 @@ winrt::Color ColorPicker::GetCheckerColor()
}

return checkerColor;
}
}
10 changes: 0 additions & 10 deletions dev/ColorPicker/InteractionTests/ColorPickerTests.cs
Expand Up @@ -19,19 +19,11 @@
using Microsoft.VisualStudio.TestTools.UnitTesting.Logging;
#endif

#if BUILD_WINDOWS
using System.Windows.Automation;
using MS.Internal.Mita.Foundation;
using MS.Internal.Mita.Foundation.Controls;
using MS.Internal.Mita.Foundation.Patterns;
using MS.Internal.Mita.Foundation.Waiters;
#else
using Microsoft.Windows.Apps.Test.Automation;
using Microsoft.Windows.Apps.Test.Foundation;
using Microsoft.Windows.Apps.Test.Foundation.Controls;
using Microsoft.Windows.Apps.Test.Foundation.Patterns;
using Microsoft.Windows.Apps.Test.Foundation.Waiters;
#endif

namespace Windows.UI.Xaml.Tests.MUXControls.InteractionTests
{
Expand Down Expand Up @@ -1214,7 +1206,6 @@ public void VerifyThirdDimensionSliderAutomationValuesAreCorrect()
// As a result, we can't test localization there. The functionality that this is testing is just whether ColorPicker is properly
// loading resources instead of having any hard-coded strings, so running this test only in the MUXControls repo should be OK -
// we don't have any OS repo-specific code in what this is testing, so nothing should change between the two repos.
#if !BUILD_WINDOWS
[TestMethod]
public void VerifyStringsAreLocalizedCorrectly()
{
Expand Down Expand Up @@ -1296,7 +1287,6 @@ private void GetLocalizedText(IList<string> stringList)

stringList.Add(FindElement.ById(AlphaLabelAutomationId).Name);
}
#endif

private ColorPickerTestSetupHelper SetupColorPickerTest(TestOptions options = TestOptions.None)
{
Expand Down
2 changes: 0 additions & 2 deletions dev/ColorPicker/TestUI/ColorPickerPage.xaml.cs
Expand Up @@ -10,13 +10,11 @@
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Shapes;

#if !BUILD_WINDOWS
using ColorSpectrumShape = Microsoft.UI.Xaml.Controls.ColorSpectrumShape;
using ColorSpectrumComponents = Microsoft.UI.Xaml.Controls.ColorSpectrumComponents;
using ColorPicker = Microsoft.UI.Xaml.Controls.ColorPicker;
using ColorChangedEventArgs = Microsoft.UI.Xaml.Controls.ColorChangedEventArgs;
using ColorSpectrum = Microsoft.UI.Xaml.Controls.Primitives.ColorSpectrum;
#endif

namespace MUXControlsTestApp
{
Expand Down
2 changes: 0 additions & 2 deletions dev/CommandBarFlyout/APITests/CommandBarFlyoutTests.cs
Expand Up @@ -23,9 +23,7 @@
using Microsoft.VisualStudio.TestTools.UnitTesting.Logging;
#endif

#if !BUILD_WINDOWS
using CommandBarFlyout = Microsoft.UI.Xaml.Controls.CommandBarFlyout;
#endif

namespace Windows.UI.Xaml.Tests.MUXControls.ApiTests
{
Expand Down
Expand Up @@ -16,19 +16,11 @@
using Microsoft.VisualStudio.TestTools.UnitTesting.Logging;
#endif

#if BUILD_WINDOWS
using System.Windows.Automation;
using MS.Internal.Mita.Foundation;
using MS.Internal.Mita.Foundation.Controls;
using MS.Internal.Mita.Foundation.Patterns;
using MS.Internal.Mita.Foundation.Waiters;
#else
using Microsoft.Windows.Apps.Test.Automation;
using Microsoft.Windows.Apps.Test.Foundation;
using Microsoft.Windows.Apps.Test.Foundation.Controls;
using Microsoft.Windows.Apps.Test.Foundation.Patterns;
using Microsoft.Windows.Apps.Test.Foundation.Waiters;
#endif

namespace Windows.UI.Xaml.Tests.MUXControls.InteractionTests
{
Expand Down
Expand Up @@ -16,19 +16,11 @@
using Microsoft.VisualStudio.TestTools.UnitTesting.Logging;
#endif

#if BUILD_WINDOWS
using System.Windows.Automation;
using MS.Internal.Mita.Foundation;
using MS.Internal.Mita.Foundation.Controls;
using MS.Internal.Mita.Foundation.Patterns;
using MS.Internal.Mita.Foundation.Waiters;
#else
using Microsoft.Windows.Apps.Test.Automation;
using Microsoft.Windows.Apps.Test.Foundation;
using Microsoft.Windows.Apps.Test.Foundation.Controls;
using Microsoft.Windows.Apps.Test.Foundation.Patterns;
using Microsoft.Windows.Apps.Test.Foundation.Waiters;
#endif

namespace Windows.UI.Xaml.Tests.MUXControls.InteractionTests
{
Expand Down
2 changes: 0 additions & 2 deletions dev/CommandBarFlyout/TestUI/CommandBarFlyoutPage.xaml.cs
Expand Up @@ -9,9 +9,7 @@
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Input;

#if !BUILD_WINDOWS
using CommandBarFlyout = Microsoft.UI.Xaml.Controls.CommandBarFlyout;
#endif

namespace MUXControlsTestApp
{
Expand Down
2 changes: 0 additions & 2 deletions dev/CommandBarFlyout/TestUI/TextCommandBarFlyoutPage.xaml.cs
Expand Up @@ -15,9 +15,7 @@
using Windows.UI.Xaml.Documents;
using Windows.UI.Xaml.Input;

#if !BUILD_WINDOWS
using TextCommandBarFlyout = Microsoft.UI.Xaml.Controls.TextCommandBarFlyout;
#endif

namespace MUXControlsTestApp
{
Expand Down