From a52ad35d807d882cdd5debaedff0444c630b6498 Mon Sep 17 00:00:00 2001 From: Nirmal Guru Date: Sun, 14 Feb 2021 14:02:31 +0530 Subject: [PATCH] Use Type aliasing instead of macros The .NET Formatter breaks in these scenarios. Improves maintainability of code in the long run. --- .../Adaptive/AdaptiveProgressBar.cs | 44 ++++++------------- .../Adaptive/AdaptiveText.cs | 17 +++---- 2 files changed, 23 insertions(+), 38 deletions(-) diff --git a/Microsoft.Toolkit.Uwp.Notifications/Adaptive/AdaptiveProgressBar.cs b/Microsoft.Toolkit.Uwp.Notifications/Adaptive/AdaptiveProgressBar.cs index ced2e168357..1df297836b5 100644 --- a/Microsoft.Toolkit.Uwp.Notifications/Adaptive/AdaptiveProgressBar.cs +++ b/Microsoft.Toolkit.Uwp.Notifications/Adaptive/AdaptiveProgressBar.cs @@ -2,11 +2,19 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#pragma warning disable SA1121 // UseBuiltInTypeAlias + +using System; +using Microsoft.Toolkit.Uwp.Notifications.Adaptive.Elements; + #if WINRT using System.Collections.Generic; +using BindableProgressBarValue = Microsoft.Toolkit.Uwp.Notifications.AdaptiveProgressBarValue; +using BindableString = System.String; +#else +using BindableProgressBarValue = Microsoft.Toolkit.Uwp.Notifications.BindableProgressBarValue; +using BindableString = Microsoft.Toolkit.Uwp.Notifications.BindableString; #endif -using System; -using Microsoft.Toolkit.Uwp.Notifications.Adaptive.Elements; namespace Microsoft.Toolkit.Uwp.Notifications { @@ -25,46 +33,22 @@ public sealed class AdaptiveProgressBar : IToastBindingGenericChild /// /// Gets or sets an optional title string. Supports data binding. /// - public -#if WINRT - string -#else - BindableString -#endif - Title { get; set; } + public BindableString Title { get; set; } /// /// Gets or sets the value of the progress bar. Supports data binding. Defaults to 0. /// - public -#if WINRT - AdaptiveProgressBarValue -#else - BindableProgressBarValue -#endif - Value { get; set; } = AdaptiveProgressBarValue.FromValue(0); + public BindableProgressBarValue Value { get; set; } = AdaptiveProgressBarValue.FromValue(0); /// /// Gets or sets an optional string to be displayed instead of the default percentage string. If this isn't provided, something like "70%" will be displayed. /// - public -#if WINRT - string -#else - BindableString -#endif - ValueStringOverride { get; set; } + public BindableString ValueStringOverride { get; set; } /// /// Gets or sets a status string (Required), which is displayed underneath the progress bar. This string should reflect the status of the operation, like "Downloading..." or "Installing..." /// - public -#if WINRT - string -#else - BindableString -#endif - Status { get; set; } + public BindableString Status { get; set; } internal Element_AdaptiveProgressBar ConvertToElement() { diff --git a/Microsoft.Toolkit.Uwp.Notifications/Adaptive/AdaptiveText.cs b/Microsoft.Toolkit.Uwp.Notifications/Adaptive/AdaptiveText.cs index 21151fe86d3..0279b856c3e 100644 --- a/Microsoft.Toolkit.Uwp.Notifications/Adaptive/AdaptiveText.cs +++ b/Microsoft.Toolkit.Uwp.Notifications/Adaptive/AdaptiveText.cs @@ -2,10 +2,17 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#pragma warning disable SA1121 // UseBuiltInTypeAlias + +using System; +using Microsoft.Toolkit.Uwp.Notifications.Adaptive.Elements; + #if WINRT using System.Collections.Generic; +using BindableString = System.String; +#else +using BindableString = Microsoft.Toolkit.Uwp.Notifications.BindableString; #endif -using Microsoft.Toolkit.Uwp.Notifications.Adaptive.Elements; namespace Microsoft.Toolkit.Uwp.Notifications { @@ -29,13 +36,7 @@ public sealed class AdaptiveText /// Gets or sets the text to display. Data binding support added in Creators Update, /// only works for toast top-level text elements. /// - public -#if WINRT - string -#else - BindableString -#endif - Text { get; set; } + public BindableString Text { get; set; } /// /// Gets or sets the target locale of the XML payload, specified as a BCP-47 language tags