From 62b6a40e0e7d4d0429de9aec5268b9e222e1df43 Mon Sep 17 00:00:00 2001 From: Youssef1313 Date: Tue, 27 Sep 2022 09:48:41 +0200 Subject: [PATCH] build: Enable CS1998 as error --- .../Uno.UI.Lottie/LottieVisualSourceBase.cs | 4 +- .../ThemableLottieVisualSource.Android.cs | 4 +- .../ThemableLottieVisualSource.cs | 4 +- src/Directory.Build.props | 3 +- src/SamplesApp/SamplesApp.Shared/App.xaml.cs | 18 +++--- .../Extensions/QueryExtensions.async.cs | 14 +++-- .../SampleControlUITestBase.cs | 7 ++- .../TextBlockTests/TextBlockTests.cs | 2 +- .../Windows_UI_Xaml_Input/Capture_Tests.cs | 10 +-- .../SetTarget_After_Start.cs | 2 +- .../Presentation/SampleChooserViewModel.cs | 62 ++++++++++++------- .../Controls/UnitTest/UnitTestsControl.cs | 12 +++- .../SamplesApp.Wasm/SamplesApp.Wasm.csproj | 2 +- .../Windows_Devices/Power/Battery.xaml.cs | 2 +- .../AuthenticationBroker_Demo.xaml.cs | 12 +++- .../Windows_System/Power/PowerManager.xaml.cs | 2 +- .../HitTest_GeometryGroup.xaml.cs | 2 +- .../Clipping/Clipping652.xaml.cs | 16 ++--- .../TransformToVisual_ScrollViewer.xaml.cs | 4 +- .../TransformToVisual_Transform.xaml.cs | 2 +- .../BackButtonImage/CommandBar_Page1.xaml.cs | 2 +- .../BackButtonTitle/CommandBar_Page1.xaml.cs | 2 +- .../LongTitle/CommandBar_Page1.xaml.cs | 4 +- .../LongTitle/CommandBar_Page2.xaml.cs | 4 +- .../LongTitle/CommandBar_Page3.xaml.cs | 2 +- .../ImageTests/Models/ImageFilePathModel.cs | 14 +++-- ...istView_Header_DataContextChanging.xaml.cs | 4 +- ...GridView_Vertical_MaxItemWidthViewModel.cs | 2 +- .../Uno.Analyzers.Tests.csproj | 1 - src/Uno.CrossTargetting.props | 4 +- .../HotReload/ServerHotReloadProcessor.cs | 12 ++-- src/Uno.UI.RemoteControl.VS/EntryPoint.cs | 20 +++--- .../ClientHotReloadProcessor.Xaml.cs | 2 +- .../HotReload/ClientHotReloadProcessor.cs | 4 +- .../DataTransfer/ClipboardExtensions.cs | 20 +++--- .../Storage/Pickers/FolderPickerExtension.cs | 6 +- .../WpfDragDropExtension.cs | 4 +- .../Helpers/ImageAssert.cs | 2 +- .../common/CalendarHelper.h.cs | 4 +- .../IntegrationTests/common/TestServices.cs | 7 ++- .../controls/appbar/AppBarIntegrationTests.cs | 8 +-- .../CalendarViewIntegrationTests.cs | 16 ++--- .../commandbar/CommandBarIntegrationTests.cs | 23 +++---- .../MUX/Helpers/ControlHelper.cs | 2 +- .../Repeater/ItemTemplateTests.cs | 10 +-- .../MUX/Utilities/RunOnUIThread.cs | 12 +++- .../Collections/Given_ValueSet.cs | 2 +- .../Metadata/Given_ApiInformation.cs | 2 +- .../Given_StorageFolder_Native.wasm.cs | 3 +- .../Streams/Given_DataWriter.cs | 2 +- .../Given_DispatcherQueueTimer.cs | 2 +- .../Tests/Windows_UI/Given_Color.cs | 8 +-- .../Windows_UI_Popups/Given_MessageDialog.cs | 4 +- .../ItemsControl_ItemsSource_Leak.xaml.cs | 3 +- .../Windows_UI_Xaml/Given_FrameworkElement.cs | 6 +- .../Tests/Windows_UI_Xaml/Given_Style.cs | 2 +- .../Tests/Windows_UI_Xaml/Given_UIElement.cs | 4 +- .../Windows_UI_Xaml/Given_UIElement.wasm.cs | 8 +-- .../Tests/Windows_UI_Xaml/Given_xLoad.cs | 8 +-- .../Windows_UI_Xaml_Controls/Given_Flyout.cs | 12 ++-- .../Windows_UI_Xaml_Controls/Given_Image.cs | 2 +- .../Given_ListViewBase_Items.cs | 38 ++++++------ .../Given_TextBlock.cs | 2 +- .../Given_MarkupExtension.cs | 4 +- .../Given_BitmapSource.cs | 8 +-- src/Uno.UI.TestComparer/Program.cs | 4 +- .../Uno.UI.TestComparer.csproj | 2 +- .../Uno.UI.Tests.Performance.csproj | 2 +- .../Uno.UI.Tests.ViewLibrary.csproj | 2 +- .../Uno.UI.Tests.ViewLibraryProps.csproj | 2 +- src/Uno.UI.Tests/Uno.UI.Tests.csproj | 2 +- .../ItemsControlTests/Given_ItemsControl.cs | 4 +- .../AnimatedVisualPlayer.cs | 6 +- .../UI/Xaml/Controls/Image/Image.Android.cs | 33 +++++++--- .../Controls/PersonPicture/PersonPicture.cs | 2 +- .../UI/Xaml/Controls/WebView/WebView.skia.cs | 4 +- src/Uno.UI/UI/Xaml/DragDrop/DropUITarget.cs | 3 +- src/Uno.UI/UI/Xaml/Media/ImageSource.iOS.cs | 4 +- .../UI/Xaml/Media/Imaging/BitmapSource.cs | 8 ++- .../Xaml/Media/Imaging/RenderTargetBitmap.cs | 14 +++-- .../UI/Xaml/Media/Imaging/SvgImageSource.cs | 7 ++- .../PhoneCallHistoryEntryReader.Android.cs | 6 +- .../Geolocation/Geolocator.iOSmacOS.cs | 4 +- .../Devices/Midi/MidiInPort.iOSmacOS.cs | 4 +- .../Devices/Midi/MidiOutPort.iOSmacOS.cs | 4 +- src/Uno.UWP/Devices/Midi/MidiOutPort.wasm.cs | 4 +- src/Uno.UWP/Devices/Radios/Radio.Android.cs | 4 +- .../Graphics/Imaging/BitmapEncoder.android.cs | 8 ++- .../Graphics/Imaging/BitmapEncoder.ios.cs | 5 +- .../Graphics/Imaging/BitmapEncoder.skia.cs | 8 ++- .../Media/Capture/CameraCaptureUI.iOS.cs | 4 +- .../Media/Capture/CameraCaptureUI.other.cs | 2 +- .../SpeechRecognition/SpeechRecognizer.cs | 7 ++- .../Notification/VibrationDevice.iOS.cs | 2 +- .../WebAuthenticationBrokerProvider.skia.cs | 2 +- .../Services/Store/StoreContext.Android.cs | 6 +- src/Uno.UWP/Storage/NameCollisionOption.cs | 5 +- src/Uno.UWP/Storage/StorageFile.Local.cs | 27 ++++---- src/Uno.UWP/Storage/StorageFile.android.cs | 2 - src/Uno.UWP/Storage/StorageFile.cs | 3 +- src/Uno.UWP/Storage/StorageFile.iOS.cs | 8 +-- src/Uno.UWP/Storage/StorageFile.wasm.cs | 2 - src/Uno.UWP/Storage/StorageFolder.Local.cs | 1 - src/Uno.UWP/Storage/StorageFolder.cs | 4 +- .../Storage/StorageStreamTransaction.cs | 4 +- .../Streams/Internal/NativeReadStream.wasm.cs | 4 +- .../Internal/NativeReadStreamAdapter.wasm.cs | 4 +- .../Streams/RandomAccessStreamReference.cs | 4 +- .../WindowsRuntimeSystemExtensions.cs | 2 +- .../System/Launcher.Android.SpecialUris.cs | 8 +-- src/Uno.UWP/System/Launcher.Android.cs | 2 +- .../System/Launcher.iOS.SpecialUris.cs | 6 +- src/Uno.UWP/System/Launcher.iOSmacOS.cs | 13 ++-- .../System/Launcher.macOS.SpecialUris.cs | 8 +-- src/Uno.UWP/System/Launcher.wasm.cs | 4 +- ...rProfilePersonalizationSettings.Android.cs | 4 +- src/Uno.UWP/UI/Popups/MessageDialog.wasm.cs | 2 +- .../StatusBar/StatusBar.Android.cs | 6 +- .../ViewManagement/StatusBar/StatusBar.iOS.cs | 12 ++-- 119 files changed, 453 insertions(+), 346 deletions(-) diff --git a/src/AddIns/Uno.UI.Lottie/LottieVisualSourceBase.cs b/src/AddIns/Uno.UI.Lottie/LottieVisualSourceBase.cs index 694b98c0cf98..1e5a96ea600f 100644 --- a/src/AddIns/Uno.UI.Lottie/LottieVisualSourceBase.cs +++ b/src/AddIns/Uno.UI.Lottie/LottieVisualSourceBase.cs @@ -238,7 +238,7 @@ Size IAnimatedVisualSource.Measure(Size availableSize) private async Task TryLoadDownloadJson(Uri uri, CancellationToken ct) { - if(await TryLoadEmbeddedJson(uri, ct) is {} json) + if (TryLoadEmbeddedJson(uri, ct) is { } json) { return json; } @@ -262,7 +262,7 @@ Size IAnimatedVisualSource.Measure(Size availableSize) : null; } - private async Task TryLoadEmbeddedJson(Uri uri, CancellationToken ct) + private IInputStream? TryLoadEmbeddedJson(Uri uri, CancellationToken ct) { if (uri.Scheme != "embedded") { diff --git a/src/AddIns/Uno.UI.Lottie/ThemableLottieVisualSource.Android.cs b/src/AddIns/Uno.UI.Lottie/ThemableLottieVisualSource.Android.cs index 391cc43d43aa..7bf8c99aa4aa 100644 --- a/src/AddIns/Uno.UI.Lottie/ThemableLottieVisualSource.Android.cs +++ b/src/AddIns/Uno.UI.Lottie/ThemableLottieVisualSource.Android.cs @@ -49,7 +49,7 @@ public partial class ThemableLottieVisualSource : LottieVisualSourceBase, IThema _updateCallback = updateCallback; - var t = LoadAndUpdate(cts.Token, sourceCacheKey, sourceJson); + LoadAndUpdate(cts.Token, sourceCacheKey, sourceJson); return Disposable.Create(() => { @@ -58,7 +58,7 @@ public partial class ThemableLottieVisualSource : LottieVisualSourceBase, IThema }); } - private async Task LoadAndUpdate( + private void LoadAndUpdate( CancellationToken ct, string sourceCacheKey, IInputStream sourceJson) diff --git a/src/AddIns/Uno.UI.Lottie/ThemableLottieVisualSource.cs b/src/AddIns/Uno.UI.Lottie/ThemableLottieVisualSource.cs index c97678a9f281..7c76b94aee0f 100644 --- a/src/AddIns/Uno.UI.Lottie/ThemableLottieVisualSource.cs +++ b/src/AddIns/Uno.UI.Lottie/ThemableLottieVisualSource.cs @@ -51,7 +51,7 @@ public Task LoadForTests( _updateCallback = updateCallback; - var t = LoadAndUpdate(cts.Token, sourceCacheKey, sourceJson); + LoadAndUpdate(cts.Token, sourceCacheKey, sourceJson); return Disposable.Create(() => { @@ -60,7 +60,7 @@ public Task LoadForTests( }); } - private async Task LoadAndUpdate( + private void LoadAndUpdate( CancellationToken ct, string sourceCacheKey, IInputStream sourceJson) diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 7cd6c0977cb7..c09cc89cebe1 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -5,7 +5,6 @@ - $(NoWarn);1998 $(NoWarn);CA1416 $(NoWarn);MSB4011 portable @@ -168,7 +167,7 @@ $(MSBuildProjectName.Contains('Test')) $(MSBuildProjectName.Contains('Sample')) $(MSBuildProjectName.Contains('UnoIslands')) - $(WarningsAsErrors);nullable;CS8032 + $(WarningsAsErrors);nullable;CS8032;CS1998 diff --git a/src/SamplesApp/SamplesApp.Shared/App.xaml.cs b/src/SamplesApp/SamplesApp.Shared/App.xaml.cs index e92a49bcf207..a196899ef4da 100644 --- a/src/SamplesApp/SamplesApp.Shared/App.xaml.cs +++ b/src/SamplesApp/SamplesApp.Shared/App.xaml.cs @@ -155,7 +155,7 @@ private void AppendRepositoryPathToTitleBar() } #endif - private static async Task HandleSkiaAutoScreenshots(LaunchActivatedEventArgs e) + private static bool HandleSkiaAutoScreenshots(LaunchActivatedEventArgs e) { #if __SKIA__ || __MACOS__ var runAutoScreenshotsParam = @@ -185,7 +185,11 @@ private static async Task HandleSkiaAutoScreenshots(LaunchActivatedEventAr return false; } - private static async Task HandleSkiaRuntimeTests(LaunchActivatedEventArgs e) + private static +#if __SKIA__ || __MACOS__ + async +#endif + Task HandleSkiaRuntimeTests(LaunchActivatedEventArgs e) { #if __SKIA__ || __MACOS__ var runRuntimeTestsResultsParam = @@ -208,7 +212,7 @@ await SampleControl.Presentation.SampleChooserViewModel.Instance.RunRuntimeTests return true; } #endif - return false; + return Task.FromResult(false); } #if __IOS__ @@ -318,7 +322,7 @@ private async void HandleLaunchArguments(LaunchActivatedEventArgs launchActivate { Console.WriteLine($"HandleLaunchArguments: {launchActivatedEventArgs.Arguments}"); - if (await HandleSkiaAutoScreenshots(launchActivatedEventArgs)) + if (HandleSkiaAutoScreenshots(launchActivatedEventArgs)) { return; } @@ -328,7 +332,7 @@ private async void HandleLaunchArguments(LaunchActivatedEventArgs launchActivate return; } - if (await TryNavigateToLaunchSampleAsync(launchActivatedEventArgs)) + if (TryNavigateToLaunchSample(launchActivatedEventArgs)) { return; } @@ -340,7 +344,7 @@ private async void HandleLaunchArguments(LaunchActivatedEventArgs launchActivate } } - private async Task TryNavigateToLaunchSampleAsync(LaunchActivatedEventArgs launchActivatedEventArgs) + private bool TryNavigateToLaunchSample(LaunchActivatedEventArgs launchActivatedEventArgs) { const string samplePrefix = "sample="; try @@ -363,7 +367,7 @@ private async Task TryNavigateToLaunchSampleAsync(LaunchActivatedEventArgs var category = pathParts[0]; var sampleName = pathParts[1]; - await SampleControl.Presentation.SampleChooserViewModel.Instance.SetSelectedSample(CancellationToken.None, category, sampleName); + SampleControl.Presentation.SampleChooserViewModel.Instance.SetSelectedSample(CancellationToken.None, category, sampleName); return true; } catch (Exception ex) diff --git a/src/SamplesApp/SamplesApp.UITests/Extensions/QueryExtensions.async.cs b/src/SamplesApp/SamplesApp.UITests/Extensions/QueryExtensions.async.cs index 21dd63ed8bc2..5ab4bc3b7e38 100644 --- a/src/SamplesApp/SamplesApp.UITests/Extensions/QueryExtensions.async.cs +++ b/src/SamplesApp/SamplesApp.UITests/Extensions/QueryExtensions.async.cs @@ -12,18 +12,24 @@ public static class AppExtensions // Those are only mapping to the sync version but are needed to allow // multi-targeting with **Runtime UI tests** engine which has only async versions. - public static async Task WaitForDependencyPropertyValueAsync( + public static Task WaitForDependencyPropertyValueAsync( this IApp app, QueryEx element, string dependencyPropertyName, string value) - => app.WaitForDependencyPropertyValue(element, dependencyPropertyName, value); + { + app.WaitForDependencyPropertyValue(element, dependencyPropertyName, value); + return Task.CompletedTask; + } - public static async Task WaitForDependencyPropertyValueAsync( + public static Task WaitForDependencyPropertyValueAsync( this IApp app, Func element, string dependencyPropertyName, T expectedValue) - => app.WaitForDependencyPropertyValue(element, dependencyPropertyName, expectedValue); + { + app.WaitForDependencyPropertyValue(element, dependencyPropertyName, expectedValue); + return Task.CompletedTask; + } } #endif diff --git a/src/SamplesApp/SamplesApp.UITests/SampleControlUITestBase.cs b/src/SamplesApp/SamplesApp.UITests/SampleControlUITestBase.cs index f8452da69e08..31b23ba71ff7 100644 --- a/src/SamplesApp/SamplesApp.UITests/SampleControlUITestBase.cs +++ b/src/SamplesApp/SamplesApp.UITests/SampleControlUITestBase.cs @@ -337,8 +337,11 @@ private IEnumerable GetActivePlatforms() } } - protected async Task RunAsync(string metadataName, bool waitForSampleControl = true, bool skipInitialScreenshot = false, int sampleLoadTimeout = 5) - => Run(metadataName, waitForSampleControl, skipInitialScreenshot, sampleLoadTimeout); + protected Task RunAsync(string metadataName, bool waitForSampleControl = true, bool skipInitialScreenshot = false, int sampleLoadTimeout = 5) + { + Run(metadataName, waitForSampleControl, skipInitialScreenshot, sampleLoadTimeout); + return Task.CompletedTask; + } protected void Run(string metadataName, bool waitForSampleControl = true, bool skipInitialScreenshot = false, int sampleLoadTimeout = 5) { diff --git a/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Controls/TextBlockTests/TextBlockTests.cs b/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Controls/TextBlockTests/TextBlockTests.cs index d64c14e3f482..38b52b96d70b 100644 --- a/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Controls/TextBlockTests/TextBlockTests.cs +++ b/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Controls/TextBlockTests/TextBlockTests.cs @@ -98,7 +98,7 @@ public void When_Foreground_Changed_With_Visibility() [Test] [AutoRetry] - public async Task When_TextDecoration_Changed() + public void When_TextDecoration_Changed() { Run("UITests.Shared.Windows_UI_Xaml_Controls.TextBlockControl.TextBlock_Decorations"); diff --git a/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Input/Capture_Tests.cs b/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Input/Capture_Tests.cs index 2560f51f371d..62fbbcb823a5 100644 --- a/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Input/Capture_Tests.cs +++ b/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Input/Capture_Tests.cs @@ -21,26 +21,26 @@ public partial class Capture_Tests : SampleControlUITestBase [ActivePlatforms(Platform.iOS, Platform.Android)] // This fails with unit test [InjectedPointer(PointerDeviceType.Touch)] public async Task TestSimple() - => RunTest("Simple", TouchAndMoveOut); + => await RunTest("Simple", TouchAndMoveOut); [Test] [AutoRetry] [InjectedPointer(PointerDeviceType.Touch)] public async Task TestVisibility() - => RunTest("Visibility"); + => await RunTest("Visibility"); [Test] [AutoRetry] [InjectedPointer(PointerDeviceType.Touch)] public async Task TestNestedVisibility() - => RunTest("NestedVisibility"); + => await RunTest("NestedVisibility"); [Test] [AutoRetry] [Ignore("Inconsistent behavior between manual and unit test")] [InjectedPointer(PointerDeviceType.Touch)] public async Task TestIsEnabled() - => RunTest("IsEnabled"); + => await RunTest("IsEnabled"); [Test] [AutoRetry] @@ -48,7 +48,7 @@ public async Task TestIsEnabled() [ActivePlatforms(Platform.Browser)] // The IsEnabled property is not inherited on other platforms yet. [InjectedPointer(PointerDeviceType.Touch)] public async Task TestNestedIsEnabled() - => RunTest("NestedIsEnabled"); + => await RunTest("NestedIsEnabled"); private readonly Action TouchAndHold = element => /*element.TouchAndHold() not implemented ... we can use tap instead */ element.FastTap(); diff --git a/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Media_Animation/SetTarget_After_Start.cs b/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Media_Animation/SetTarget_After_Start.cs index ea5d1dcae658..b3a2c00db689 100644 --- a/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Media_Animation/SetTarget_After_Start.cs +++ b/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Media_Animation/SetTarget_After_Start.cs @@ -16,7 +16,7 @@ public partial class SetTarget_After_Start : SampleControlUITestBase { [Test] [AutoRetry] - public async Task When_Target_Is_Set_After_Start() + public void When_Target_Is_Set_After_Start() { Run("UITests.Shared.Windows_UI_Xaml_Media_Animation.SetTargetProperty"); var playBtn = _app.Marked("playButton"); diff --git a/src/SamplesApp/SamplesApp.UnitTests.Shared/Controls/UITests/Presentation/SampleChooserViewModel.cs b/src/SamplesApp/SamplesApp.UnitTests.Shared/Controls/UITests/Presentation/SampleChooserViewModel.cs index 6b36efeffcdf..c63bba00622a 100644 --- a/src/SamplesApp/SamplesApp.UnitTests.Shared/Controls/UITests/Presentation/SampleChooserViewModel.cs +++ b/src/SamplesApp/SamplesApp.UnitTests.Shared/Controls/UITests/Presentation/SampleChooserViewModel.cs @@ -119,7 +119,7 @@ public SampleChooserViewModel() /// /// The page to go to. /// - private async Task ShowNewSection(CancellationToken ct, Section section) + private void ShowNewSection(CancellationToken ct, Section section) { Console.WriteLine($"Section changed: {section}"); @@ -132,7 +132,7 @@ private async Task ShowNewSection(CancellationToken ct, Section section) case Section.Favorites: case Section.Search: _previousSections.Push(_lastSection); - await ShowSelectedList(ct, section); + ShowSelectedList(ct, section); return; // Return after a Tab is shown @@ -151,12 +151,12 @@ private async Task ShowNewSection(CancellationToken ct, Section section) /// /// /// - private async Task ShowPreviousSection(CancellationToken ct) + private void ShowPreviousSection(CancellationToken ct) { if (_previousSections.Count == 0) { _lastSection = Section.Library; - await ShowSelectedList(ct, Section.Library); + ShowSelectedList(ct, Section.Library); return; } @@ -169,7 +169,7 @@ private async Task ShowPreviousSection(CancellationToken ct) case Section.Recents: case Section.Favorites: case Section.Search: - await ShowSelectedList(ct, priorPage); + ShowSelectedList(ct, priorPage); break; default: @@ -177,7 +177,7 @@ private async Task ShowPreviousSection(CancellationToken ct) } } - private async Task ShowSelectedList(CancellationToken ct, Section section) + private void ShowSelectedList(CancellationToken ct, Section section) { CategoryVisibility = section == Section.Library; CategoriesSelected = section == Section.Library || section == Section.Samples; @@ -194,7 +194,7 @@ private async Task LogViewDump(CancellationToken ct) { await Window.Current.Dispatcher.RunAsync( CoreDispatcherPriority.Normal, - async () => + () => { var currentContent = ContentPhone as Control; @@ -356,7 +356,7 @@ from sample in category.SamplesContent _log.Debug($"Generating {folderName}\\{fileName}"); } - await ShowNewSection(ct, Section.SamplesContent); + ShowNewSection(ct, Section.SamplesContent); SelectedLibrarySample = sample.Sample; @@ -608,9 +608,9 @@ private async Task> GetRecentSamples(CancellationToke } } - private async Task GetLatestCategory(CancellationToken ct) + private SampleChooserCategory GetLatestCategory(CancellationToken ct) { - var latestSelected = await Get(SampleChooserLatestCategoryConstant, () => (string)null); + var latestSelected = Get(SampleChooserLatestCategoryConstant, () => (string)null); return _categories.FirstOrDefault(c => c.Category == latestSelected) ?? _categories.FirstOrDefault(); } @@ -883,11 +883,11 @@ void Dispose(object snd, RoutedEventArgs e) var recents = await GetRecentSamples(ct); // Get the selected category, else if null find it using the SampleContent passed in - var selectedCategory = SelectedCategory ?? await GetCategory(newContent); + var selectedCategory = SelectedCategory ?? GetCategory(newContent); if (selectedCategory != null) { - await Set(SampleChooserLatestCategoryConstant, selectedCategory.Category); + Set(SampleChooserLatestCategoryConstant, selectedCategory.Category); } CurrentSelectedSample = newContent; @@ -912,7 +912,7 @@ void Dispose(object snd, RoutedEventArgs e) return container; } - private async Task GetCategory(SampleChooserContent content) + private SampleChooserCategory GetCategory(SampleChooserContent content) { return _categories.FirstOrDefault(cat => cat.SamplesContent.Any( @@ -938,7 +938,7 @@ from test in category.SamplesContent return string.Join(";", q.Distinct()); } - public async Task SetSelectedSample(CancellationToken token, string categoryName, string sampleName) + public void SetSelectedSample(CancellationToken token, string categoryName, string sampleName) { var category = _categories.FirstOrDefault( c => c.Category != null && @@ -957,7 +957,7 @@ public async Task SetSelectedSample(CancellationToken token, string categoryName return; } - await ShowNewSection(token, Section.SamplesContent); + ShowNewSection(token, Section.SamplesContent); SelectedLibrarySample = sample; } @@ -979,7 +979,7 @@ from test in category.SamplesContent { IsSplitVisible = false; - await ShowNewSection(ct, Section.SamplesContent); + ShowNewSection(ct, Section.SamplesContent); SelectedLibrarySample = sample; @@ -997,7 +997,7 @@ from test in category.SamplesContent } } - private async Task Set(string key, T value) + private void Set(string key, T value) { #if !UNO_REFERENCE_API var json = Newtonsoft.Json.JsonConvert.SerializeObject(value); @@ -1005,7 +1005,7 @@ private async Task Set(string key, T value) #endif } - private async Task Get(string key, Func d = null) + private T Get(string key, Func d = null) { #if !UNO_REFERENCE_API var json = (string)ApplicationData.Current.LocalSettings.Values[key]; @@ -1015,7 +1015,11 @@ private async Task Get(string key, Func d = null) #endif } - private async Task SetFile(string key, T value) + private +#if !UNO_REFERENCE_API + async +#endif + Task SetFile(string key, T value) { #if !UNO_REFERENCE_API var json = Newtonsoft.Json.JsonConvert.SerializeObject(value); @@ -1039,10 +1043,16 @@ private async Task SetFile(string key, T value) _log.Error(e.Message); } } +#else + return Task.CompletedTask; #endif } - private async Task GetFile(string key, Func defaultValue = null) + private +#if !UNO_REFERENCE_API + async +#endif + Task GetFile(string key, Func defaultValue = null) { #if !UNO_REFERENCE_API string json = null; @@ -1076,8 +1086,12 @@ private async Task GetFile(string key, Func defaultValue = null) _log.Error($"Could not deserialize Sample chooser file {key}.", ex); } } -#endif + return defaultValue != null ? defaultValue() : default(T); +#else + return Task.FromResult(defaultValue != null ? defaultValue() : default(T)); +#endif + } @@ -1091,7 +1105,11 @@ private async Task DumpOutputFolderName(CancellationToken ct, string folderName) } } - private async Task GenerateBitmap(CancellationToken ct + private +#if !__WASM__ + async +#endif + Task GenerateBitmap(CancellationToken ct , Windows.UI.Xaml.Media.Imaging.RenderTargetBitmap targetBitmap , StorageFile file , FrameworkElement content diff --git a/src/SamplesApp/SamplesApp.UnitTests.Shared/Controls/UnitTest/UnitTestsControl.cs b/src/SamplesApp/SamplesApp.UnitTests.Shared/Controls/UnitTest/UnitTestsControl.cs index b6316760bad2..a45c20eb6b07 100644 --- a/src/SamplesApp/SamplesApp.UnitTests.Shared/Controls/UnitTest/UnitTestsControl.cs +++ b/src/SamplesApp/SamplesApp.UnitTests.Shared/Controls/UnitTest/UnitTestsControl.cs @@ -776,7 +776,11 @@ await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { var ptSubscription = (instance as IInjectPointers ?? throw new InvalidOperationException("test class does not supports pointer selection.")).SetPointer(pt); - cleanupActions.Add(async _ => ptSubscription.Dispose()); + cleanupActions.Add(_ => + { + ptSubscription.Dispose(); + return Task.CompletedTask; + }); } sw.Start(); @@ -790,7 +794,11 @@ await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => if (testCase.Pointer is { } pt) { var ptSubscription = (instance as IInjectPointers ?? throw new InvalidOperationException("test class does not supports pointer selection.")).SetPointer(pt); - cleanupActions.Add(async _ => ptSubscription.Dispose()); + cleanupActions.Add(_ => + { + ptSubscription.Dispose(); + return Task.CompletedTask; + }); } sw.Start(); diff --git a/src/SamplesApp/SamplesApp.Wasm/SamplesApp.Wasm.csproj b/src/SamplesApp/SamplesApp.Wasm/SamplesApp.Wasm.csproj index 7c08db3a50ef..5d861c5eabe5 100644 --- a/src/SamplesApp/SamplesApp.Wasm/SamplesApp.Wasm.csproj +++ b/src/SamplesApp/SamplesApp.Wasm/SamplesApp.Wasm.csproj @@ -4,7 +4,7 @@ Exe net6.0 $(DefineConstants);__WASM__;HAS_UNO;UNO_REFERENCE_API - $(NoWarn);NU1701;CS1998;NU1504;UXAML0002 + $(NoWarn);NU1701;NU1504;UXAML0002 $(NoWarn);CA1834 $(NoWarn);CA1845 true diff --git a/src/SamplesApp/UITests.Shared/Windows_Devices/Power/Battery.xaml.cs b/src/SamplesApp/UITests.Shared/Windows_Devices/Power/Battery.xaml.cs index ff56a65ac32a..2986278515d7 100644 --- a/src/SamplesApp/UITests.Shared/Windows_Devices/Power/Battery.xaml.cs +++ b/src/SamplesApp/UITests.Shared/Windows_Devices/Power/Battery.xaml.cs @@ -29,7 +29,7 @@ public Battery() this.InitializeComponent(); } - private async void getBatteryInfo_Click(object sender, RoutedEventArgs e) + private void getBatteryInfo_Click(object sender, RoutedEventArgs e) { uiErrorMsg.Text = ""; uiOkMsg.Text = ""; diff --git a/src/SamplesApp/UITests.Shared/Windows_Security/Authentication_Web/AuthenticationBroker_Demo.xaml.cs b/src/SamplesApp/UITests.Shared/Windows_Security/Authentication_Web/AuthenticationBroker_Demo.xaml.cs index d8855254661b..65a2331011ee 100644 --- a/src/SamplesApp/UITests.Shared/Windows_Security/Authentication_Web/AuthenticationBroker_Demo.xaml.cs +++ b/src/SamplesApp/UITests.Shared/Windows_Security/Authentication_Web/AuthenticationBroker_Demo.xaml.cs @@ -77,7 +77,11 @@ public AuthenticationBroker_Demo() } #endif - private async void SignIn_Clicked(object sender, RoutedEventArgs e) + private +#if !NET6_0_OR_GREATER + async +#endif + void SignIn_Clicked(object sender, RoutedEventArgs e) { #if !NET6_0_OR_GREATER var startUri = new Uri(_loginState.StartUrl); @@ -114,7 +118,11 @@ private async void SignIn_Clicked(object sender, RoutedEventArgs e) #endif } - private async void SignOut_Clicked(object sender, RoutedEventArgs e) + private +#if !NET6_0_OR_GREATER + async +#endif + void SignOut_Clicked(object sender, RoutedEventArgs e) { #if !NET6_0_OR_GREATER var userResult = await WebAuthenticationBroker.AuthenticateAsync(WebAuthenticationOptions.None, _logoutUrl); diff --git a/src/SamplesApp/UITests.Shared/Windows_System/Power/PowerManager.xaml.cs b/src/SamplesApp/UITests.Shared/Windows_System/Power/PowerManager.xaml.cs index 463fa09d21cb..d8328479d6ce 100644 --- a/src/SamplesApp/UITests.Shared/Windows_System/Power/PowerManager.xaml.cs +++ b/src/SamplesApp/UITests.Shared/Windows_System/Power/PowerManager.xaml.cs @@ -57,7 +57,7 @@ await ExecuteOnUiThreadAsync(() => private async void UwpPowerManager_BatteryStatusChanged(object sender, object e) { - await ExecuteOnUiThreadAsync(async () => + await ExecuteOnUiThreadAsync(() => BatteryStatusOutput.Text = UwpPowerManager.BatteryStatus.ToString()); } diff --git a/src/SamplesApp/UITests.Shared/Windows_UI_Input/PointersTests/HitTest_GeometryGroup.xaml.cs b/src/SamplesApp/UITests.Shared/Windows_UI_Input/PointersTests/HitTest_GeometryGroup.xaml.cs index c06627a8a3ee..2fbef547bb1d 100644 --- a/src/SamplesApp/UITests.Shared/Windows_UI_Input/PointersTests/HitTest_GeometryGroup.xaml.cs +++ b/src/SamplesApp/UITests.Shared/Windows_UI_Input/PointersTests/HitTest_GeometryGroup.xaml.cs @@ -30,7 +30,7 @@ public HitTest_GeometryGroup() Loaded += (s, e) => { - _ = this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async () => + _ = this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { // this needs to be added on SizeChanged or on a delay HollowCircle2.Data = GenerateHollowCircle(new Size(100, 100)); diff --git a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml/Clipping/Clipping652.xaml.cs b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml/Clipping/Clipping652.xaml.cs index 6a2fc8ef80cc..f85e6735d21b 100644 --- a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml/Clipping/Clipping652.xaml.cs +++ b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml/Clipping/Clipping652.xaml.cs @@ -14,16 +14,18 @@ public Clipping652() { this.InitializeComponent(); +#if UNO_REFERENCE_API DumpTree(); - } - private async void DumpTree() - { -#if UNO_REFERENCE_API - await Task.Delay(1200); - var tree = this.ShowLocalVisualTree(); - System.Diagnostics.Debug.WriteLine(tree); + async void DumpTree() + { + await Task.Delay(1200); + var tree = this.ShowLocalVisualTree(); + System.Diagnostics.Debug.WriteLine(tree); + } #endif } + + } } diff --git a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml/UIElementTests/TransformToVisual_ScrollViewer.xaml.cs b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml/UIElementTests/TransformToVisual_ScrollViewer.xaml.cs index 1199d42e0862..669e3d1eed49 100644 --- a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml/UIElementTests/TransformToVisual_ScrollViewer.xaml.cs +++ b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml/UIElementTests/TransformToVisual_ScrollViewer.xaml.cs @@ -23,9 +23,9 @@ public TransformToVisual_ScrollViewer() Loaded += RunTest; } - private async void RunTest(object sender, RoutedEventArgs e) + private void RunTest(object sender, RoutedEventArgs e) { - await _tests.Run( + _tests.Run( () => When_VerticalScrollViewer_NotScrolled_Top(), () => When_VerticalScrollViewer_NotScrolled_Bottom(), () => When_VerticalScrollViewer_Scrolled_Top(), diff --git a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml/UIElementTests/TransformToVisual_Transform.xaml.cs b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml/UIElementTests/TransformToVisual_Transform.xaml.cs index 99e0c6f32f48..14e00b004416 100644 --- a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml/UIElementTests/TransformToVisual_Transform.xaml.cs +++ b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml/UIElementTests/TransformToVisual_Transform.xaml.cs @@ -229,7 +229,7 @@ public TestRunner(UserControl target, StackPanel testsOutput) } public void Run(params Expression[] tests) => Run(tests.Select(GetTest).ToArray()); - public async Task Run(params Expression>[] tests) => Run(tests.Select(GetTest).ToArray()); + public void Run(params Expression>[] tests) => Run(tests.Select(GetTest).ToArray()); private async void Run(params Test[] tests) { diff --git a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/CommandBar/BackButtonImage/CommandBar_Page1.xaml.cs b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/CommandBar/BackButtonImage/CommandBar_Page1.xaml.cs index 648ed7959902..a8ddc1ff0a0e 100644 --- a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/CommandBar/BackButtonImage/CommandBar_Page1.xaml.cs +++ b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/CommandBar/BackButtonImage/CommandBar_Page1.xaml.cs @@ -17,7 +17,7 @@ public CommandBar_Page1() this.InitializeComponent(); } - public async void OnButtonClicked(object sender, RoutedEventArgs e) + public void OnButtonClicked(object sender, RoutedEventArgs e) { Frame.Navigate(typeof(CommandBar_Page2)); } diff --git a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/CommandBar/BackButtonTitle/CommandBar_Page1.xaml.cs b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/CommandBar/BackButtonTitle/CommandBar_Page1.xaml.cs index 996a50d23b2b..48ccf6d2899d 100644 --- a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/CommandBar/BackButtonTitle/CommandBar_Page1.xaml.cs +++ b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/CommandBar/BackButtonTitle/CommandBar_Page1.xaml.cs @@ -17,7 +17,7 @@ public CommandBar_Page1() this.InitializeComponent(); } - public async void OnButtonClicked(object sender, RoutedEventArgs e) + public void OnButtonClicked(object sender, RoutedEventArgs e) { Frame.Navigate(typeof(CommandBar_Page2)); } diff --git a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/CommandBar/LongTitle/CommandBar_Page1.xaml.cs b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/CommandBar/LongTitle/CommandBar_Page1.xaml.cs index 36ac76b8ca0a..c78d505590b2 100644 --- a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/CommandBar/LongTitle/CommandBar_Page1.xaml.cs +++ b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/CommandBar/LongTitle/CommandBar_Page1.xaml.cs @@ -21,10 +21,10 @@ public CommandBar_Page1() this.InitializeComponent(); } - public async void OnButtonClicked(object sender, RoutedEventArgs e) + public void OnButtonClicked(object sender, RoutedEventArgs e) => Frame.Navigate(typeof(CommandBar_Page2)); - public async void OnCalculateSizeClicked(object sender, RoutedEventArgs e) + public void OnCalculateSizeClicked(object sender, RoutedEventArgs e) { #if __IOS__ UIView parent = this; diff --git a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/CommandBar/LongTitle/CommandBar_Page2.xaml.cs b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/CommandBar/LongTitle/CommandBar_Page2.xaml.cs index f1d02e15ab04..d8a72e351bff 100644 --- a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/CommandBar/LongTitle/CommandBar_Page2.xaml.cs +++ b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/CommandBar/LongTitle/CommandBar_Page2.xaml.cs @@ -33,10 +33,10 @@ public CommandBar_Page2() public void OnBackButtonClicked(object sender, object args) => Frame.GoBack(); - public async void OnButtonClicked(object sender, RoutedEventArgs e) + public void OnButtonClicked(object sender, RoutedEventArgs e) => Frame.Navigate(typeof(CommandBar_Page3)); - public async void OnCalculateSizeClicked(object sender, RoutedEventArgs e) + public void OnCalculateSizeClicked(object sender, RoutedEventArgs e) { #if __IOS__ UIView parent = this; diff --git a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/CommandBar/LongTitle/CommandBar_Page3.xaml.cs b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/CommandBar/LongTitle/CommandBar_Page3.xaml.cs index c4cc83e7ecbb..a7fd1c7a9bdf 100644 --- a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/CommandBar/LongTitle/CommandBar_Page3.xaml.cs +++ b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/CommandBar/LongTitle/CommandBar_Page3.xaml.cs @@ -17,7 +17,7 @@ public CommandBar_Page3() this.InitializeComponent(); } - public async void OnButtonClicked(object sender, RoutedEventArgs e) + public void OnButtonClicked(object sender, RoutedEventArgs e) => Frame.GoBack(); } } diff --git a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/ImageTests/Models/ImageFilePathModel.cs b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/ImageTests/Models/ImageFilePathModel.cs index efd687293091..ac69dc28b190 100644 --- a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/ImageTests/Models/ImageFilePathModel.cs +++ b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/ImageTests/Models/ImageFilePathModel.cs @@ -86,10 +86,14 @@ private Uri FilePathUri } } - private async Task GetAndCreateFilePath(CancellationToken ct) + private +#if HAS_UNO && !__WASM__ && !__SKIA__ && !__MACOS__ + async +#endif + Task GetAndCreateFilePath(CancellationToken ct) { #if HAS_UNO && !__WASM__ && !__SKIA__ && !__MACOS__ - var bitmap = await CreateBitmap(); + var bitmap = CreateBitmap(); _log.Warn(bitmap.ToString()); @@ -99,12 +103,12 @@ private async Task GetAndCreateFilePath(CancellationToken ct) FilePathUri = uri; return uri.AbsoluteUri; #else - return "HAS_UNO-only sample."; + return Task.FromResult("HAS_UNO-only sample."); #endif } #if __ANDROID__ - private async Task<_Bitmap> CreateBitmap() + private _Bitmap CreateBitmap() { var size = ImageSize.LogicalToPhysicalPixels(); var bitmap = _Bitmap.CreateBitmap((int)size.Width, (int)size.Height, Android.Graphics.Bitmap.Config.Argb8888); @@ -143,7 +147,7 @@ private Task<_Bitmap> CreateBitmap() context.FillEllipseInRect(new CGRect(0, 0, ImageSize.Width, ImageSize.Height)); var bitmap = UIGraphics.GetImageFromCurrentImageContext(); - return Task.FromResult(bitmap); + return bitmap; } private Task StoreFile(_Bitmap bitmap) { diff --git a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/ListView/ListView_Header_DataContextChanging.xaml.cs b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/ListView/ListView_Header_DataContextChanging.xaml.cs index 2179023993a3..31abb6847d45 100644 --- a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/ListView/ListView_Header_DataContextChanging.xaml.cs +++ b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/ListView/ListView_Header_DataContextChanging.xaml.cs @@ -27,7 +27,7 @@ public ListView_Header_DataContextChanging() // Delay to refresh the content _ = Dispatcher.RunIdleAsync( - async _ => + _ => { DataContext = "InitialDataContext"; } @@ -45,7 +45,7 @@ public void OnDataContextChanged(object sender, object args) // DataContext changed ? _ = Dispatcher.RunAsync( CoreDispatcherPriority.Normal, - async () => + () => { var dobj = (FrameworkElement)sender; var change = dobj.DataContext?.ToString() ?? "null"; diff --git a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/Models/GridView_Vertical_MaxItemWidthViewModel.cs b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/Models/GridView_Vertical_MaxItemWidthViewModel.cs index 78243a014345..20ce75e49334 100644 --- a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/Models/GridView_Vertical_MaxItemWidthViewModel.cs +++ b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/Models/GridView_Vertical_MaxItemWidthViewModel.cs @@ -17,7 +17,7 @@ public GridView_Vertical_MaxItemWidthViewModel(CoreDispatcher coreDispatcher) : public object SampleItems { get; } = Enumerable.Range(1, 10).ToArray(); - private async Task GetSampleItems(CancellationToken ct) + private int[] GetSampleItems(CancellationToken ct) { return Enumerable .Range(1, 10) diff --git a/src/Uno.Analyzers.Tests/Uno.Analyzers.Tests.csproj b/src/Uno.Analyzers.Tests/Uno.Analyzers.Tests.csproj index 2280df114660..7b731059d994 100644 --- a/src/Uno.Analyzers.Tests/Uno.Analyzers.Tests.csproj +++ b/src/Uno.Analyzers.Tests/Uno.Analyzers.Tests.csproj @@ -2,7 +2,6 @@ net461 false - 1998 ..\Build\Tests\bin\$(Configuration)_$(Platform)\ 3.8.0 diff --git a/src/Uno.CrossTargetting.props b/src/Uno.CrossTargetting.props index e053bbe42615..bbff39a1dc95 100644 --- a/src/Uno.CrossTargetting.props +++ b/src/Uno.CrossTargetting.props @@ -9,7 +9,7 @@ 255.255.255.255 - $(NoWarn),1998,4014,VSX1000,NU1701 + $(NoWarn),4014,VSX1000,NU1701 true true $(BUILD_REPOSITORY_URI) @@ -22,7 +22,7 @@ - $(NoWarn),1998,0105,4014,VSX1000,NU1701 + $(NoWarn),0105,4014,VSX1000,NU1701 diff --git a/src/Uno.UI.RemoteControl.Server.Processors/HotReload/ServerHotReloadProcessor.cs b/src/Uno.UI.RemoteControl.Server.Processors/HotReload/ServerHotReloadProcessor.cs index f803c30ad75e..63ceba79767d 100644 --- a/src/Uno.UI.RemoteControl.Server.Processors/HotReload/ServerHotReloadProcessor.cs +++ b/src/Uno.UI.RemoteControl.Server.Processors/HotReload/ServerHotReloadProcessor.cs @@ -29,20 +29,22 @@ public ServerHotReloadProcessor(IRemoteControlServer remoteControlServer) public string Scope => "hotreload"; - public async Task ProcessFrame(Frame frame) + public Task ProcessFrame(Frame frame) { switch (frame.Name) { case ConfigureServer.Name: - await ProcessConfigureServer(JsonConvert.DeserializeObject(frame.Content)); + ProcessConfigureServer(JsonConvert.DeserializeObject(frame.Content)); break; case XamlLoadError.Name: - await ProcessXamlLoadError(JsonConvert.DeserializeObject(frame.Content)); + ProcessXamlLoadError(JsonConvert.DeserializeObject(frame.Content)); break; } + + return Task.CompletedTask; } - private async Task ProcessXamlLoadError(XamlLoadError xamlLoadError) + private void ProcessXamlLoadError(XamlLoadError xamlLoadError) { if (this.Log().IsEnabled(LogLevel.Error)) { @@ -53,7 +55,7 @@ private async Task ProcessXamlLoadError(XamlLoadError xamlLoadError) } } - private async Task ProcessConfigureServer(ConfigureServer configureServer) + private void ProcessConfigureServer(ConfigureServer configureServer) { if (this.Log().IsEnabled(LogLevel.Debug)) { diff --git a/src/Uno.UI.RemoteControl.VS/EntryPoint.cs b/src/Uno.UI.RemoteControl.VS/EntryPoint.cs index cfaae2d75dda..efe7c48ac81e 100644 --- a/src/Uno.UI.RemoteControl.VS/EntryPoint.cs +++ b/src/Uno.UI.RemoteControl.VS/EntryPoint.cs @@ -55,10 +55,10 @@ public EntryPoint(DTE2 dte2, string toolsPath, AsyncPackage asyncPackage, Action SetupOutputWindow(); - _dte.Events.SolutionEvents.BeforeClosing += () => SolutionEvents_BeforeClosingAsync(); + _dte.Events.SolutionEvents.BeforeClosing += () => SolutionEvents_BeforeClosing(); _dte.Events.BuildEvents.OnBuildDone += - (s, a) => BuildEvents_OnBuildDoneAsync(s, a); + (s, a) => BuildEvents_OnBuildDone(s, a); _dte.Events.BuildEvents.OnBuildProjConfigBegin += (string project, string projectConfig, string platform, string solutionConfig) => BuildEvents_OnBuildProjConfigBeginAsync(project, projectConfig, platform, solutionConfig); @@ -70,7 +70,7 @@ public EntryPoint(DTE2 dte2, string toolsPath, AsyncPackage asyncPackage, Action _ = UpdateProjectsAsync(); } - private async Task> OnProvideGlobalPropertiesAsync() + private Task> OnProvideGlobalPropertiesAsync() { if (RemoteControlServerPort == 0) { @@ -79,9 +79,9 @@ private async Task> OnProvideGlobalPropertiesAsync() $"Rebuilding the application may fix the issue."); } - return new Dictionary { + return Task.FromResult(new Dictionary { { RemoteControlServerPortProperty, RemoteControlServerPort.ToString(CultureInfo.InvariantCulture) } - }; + }); } private void SetupOutputWindow() @@ -162,7 +162,7 @@ private async Task UpdateProjectsAsync() { try { - await StartServerAsync(); + StartServer(); var portString = RemoteControlServerPort.ToString(CultureInfo.InvariantCulture); foreach (var p in await GetProjectsAsync()) { @@ -190,12 +190,12 @@ private async Task UpdateProjectsAsync() } } - private async Task BuildEvents_OnBuildDoneAsync(vsBuildScope Scope, vsBuildAction Action) + private void BuildEvents_OnBuildDone(vsBuildScope Scope, vsBuildAction Action) { - await StartServerAsync(); + StartServer(); } - private async Task SolutionEvents_BeforeClosingAsync() + private void SolutionEvents_BeforeClosing() { if (_process != null) { @@ -237,7 +237,7 @@ private int GetDotnetMajorVersion() throw new InvalidOperationException($"Unable to detect current dotnet version (\"dotnet --version\" returned \"{result.output}\")"); } - private async Task StartServerAsync() + private void StartServer() { if (_process?.HasExited ?? true) { diff --git a/src/Uno.UI.RemoteControl/HotReload/ClientHotReloadProcessor.Xaml.cs b/src/Uno.UI.RemoteControl/HotReload/ClientHotReloadProcessor.Xaml.cs index 055ace348f0f..7d45e234eaa3 100644 --- a/src/Uno.UI.RemoteControl/HotReload/ClientHotReloadProcessor.Xaml.cs +++ b/src/Uno.UI.RemoteControl/HotReload/ClientHotReloadProcessor.Xaml.cs @@ -30,7 +30,7 @@ namespace Uno.UI.RemoteControl.HotReload { partial class ClientHotReloadProcessor { - private async Task ReloadFile(FileReload fileReload) + private void ReloadFile(FileReload fileReload) { Windows.ApplicationModel.Core.CoreApplication.MainView.Dispatcher.RunAsync( Windows.UI.Core.CoreDispatcherPriority.Normal, diff --git a/src/Uno.UI.RemoteControl/HotReload/ClientHotReloadProcessor.cs b/src/Uno.UI.RemoteControl/HotReload/ClientHotReloadProcessor.cs index 12878b0b5621..0bee89dea9cc 100644 --- a/src/Uno.UI.RemoteControl/HotReload/ClientHotReloadProcessor.cs +++ b/src/Uno.UI.RemoteControl/HotReload/ClientHotReloadProcessor.cs @@ -36,7 +36,7 @@ public async Task Initialize() await ConfigureServer(); } - public async Task ProcessFrame(Messages.Frame frame) + public Task ProcessFrame(Messages.Frame frame) { switch (frame.Name) { @@ -57,6 +57,8 @@ public async Task ProcessFrame(Messages.Frame frame) } break; } + + return Task.CompletedTask; } private async Task ConfigureServer() diff --git a/src/Uno.UI.Runtime.Skia.Gtk/ApplicationModel/DataTransfer/ClipboardExtensions.cs b/src/Uno.UI.Runtime.Skia.Gtk/ApplicationModel/DataTransfer/ClipboardExtensions.cs index 120877926064..fb8eb1528d32 100644 --- a/src/Uno.UI.Runtime.Skia.Gtk/ApplicationModel/DataTransfer/ClipboardExtensions.cs +++ b/src/Uno.UI.Runtime.Skia.Gtk/ApplicationModel/DataTransfer/ClipboardExtensions.cs @@ -45,35 +45,35 @@ public DataPackageView GetContent() if (_clipboard.WaitIsImageAvailable()) { - dataPackage.SetDataProvider(StandardDataFormats.Bitmap, async ct => + dataPackage.SetDataProvider(StandardDataFormats.Bitmap, ct => { var image = _clipboard.WaitForImage(); var data = image.SaveToBuffer("bmp"); var stream = new MemoryStream(data); - return RandomAccessStreamReference.CreateFromStream(stream.AsRandomAccessStream()); + return Task.FromResult(RandomAccessStreamReference.CreateFromStream(stream.AsRandomAccessStream())); }); } if (_clipboard.WaitIsTargetAvailable(HtmlContent)) { - dataPackage.SetDataProvider(StandardDataFormats.Html, async ct => + dataPackage.SetDataProvider(StandardDataFormats.Html, ct => { var selectionData = _clipboard.WaitForContents(HtmlContent); - return Encoding.UTF8.GetString(selectionData.Data); + return Task.FromResult(Encoding.UTF8.GetString(selectionData.Data)); }); } if (_clipboard.WaitIsTargetAvailable(RtfContent)) { - dataPackage.SetDataProvider(StandardDataFormats.Rtf, async ct => + dataPackage.SetDataProvider(StandardDataFormats.Rtf, ct => { var selectionData = _clipboard.WaitForContents(RtfContent); - return Encoding.UTF8.GetString(selectionData.Data); + return Task.FromResult(Encoding.UTF8.GetString(selectionData.Data)); }); } if (_clipboard.WaitIsTextAvailable()) { - dataPackage.SetDataProvider(StandardDataFormats.Text, async ct => + dataPackage.SetDataProvider(StandardDataFormats.Text, ct => { - return _clipboard.WaitForText(); + return Task.FromResult(_clipboard.WaitForText()); }); } if (_clipboard.WaitIsUrisAvailable()) @@ -166,10 +166,10 @@ public void SetContent(DataPackage content) CoreDispatcher.Main.RunAsync( CoreDispatcherPriority.High, - () => SetContentAsync(content)); + () => SetContentCore(content)); } - private async Task SetContentAsync(DataPackage content) + private void SetContentCore(DataPackage content) { var data = content?.GetView(); var targetList = new TargetList(); diff --git a/src/Uno.UI.Runtime.Skia.Wpf/Extensions/Storage/Pickers/FolderPickerExtension.cs b/src/Uno.UI.Runtime.Skia.Wpf/Extensions/Storage/Pickers/FolderPickerExtension.cs index e88b9636901e..bc21d142a71a 100644 --- a/src/Uno.UI.Runtime.Skia.Wpf/Extensions/Storage/Pickers/FolderPickerExtension.cs +++ b/src/Uno.UI.Runtime.Skia.Wpf/Extensions/Storage/Pickers/FolderPickerExtension.cs @@ -20,7 +20,7 @@ public FolderPickerExtension(FolderPicker owner) _picker = owner ?? throw new ArgumentNullException(nameof(owner)); } - public async Task PickSingleFolderAsync(CancellationToken token) + public Task PickSingleFolderAsync(CancellationToken token) { SuggestedStartLocation = _picker.SuggestedStartLocation switch { @@ -50,7 +50,7 @@ public FolderPickerExtension(FolderPicker owner) { var path = NativeMethods.SHGetPathFromIDListLong(pidl); if (!string.IsNullOrEmpty(path)) - return new StorageFolder(path); + return Task.FromResult(new StorageFolder(path)); } finally { @@ -58,7 +58,7 @@ public FolderPickerExtension(FolderPicker owner) } } - return null; + return Task.FromResult(null); } private uint FolderBrowserDialog_BrowseCallbackProc(IntPtr hwnd, uint msg, IntPtr lParam, IntPtr lpData) diff --git a/src/Uno.UI.Runtime.Skia.Wpf/WpfDragDropExtension.cs b/src/Uno.UI.Runtime.Skia.Wpf/WpfDragDropExtension.cs index 09c54aa982e3..37bf4ca715b5 100644 --- a/src/Uno.UI.Runtime.Skia.Wpf/WpfDragDropExtension.cs +++ b/src/Uno.UI.Runtime.Skia.Wpf/WpfDragDropExtension.cs @@ -139,7 +139,7 @@ private static DataPackage ToDataPackage(IDataObject src) if (src.GetData(DataFormats.Bitmap) is BitmapSource bitmap) { - dst.SetBitmap(new RandomAccessStreamReference(async ct => + dst.SetBitmap(new RandomAccessStreamReference(ct => { var copy = new MemoryStream(); var encoder = new BmpBitmapEncoder(); @@ -147,7 +147,7 @@ private static DataPackage ToDataPackage(IDataObject src) encoder.Save(copy); copy.Position = 0; - return copy.AsRandomAccessStream().TrySetContentType("image/bmp"); + return Task.FromResult(copy.AsRandomAccessStream().TrySetContentType("image/bmp")); })); } diff --git a/src/Uno.UI.RuntimeTests/Helpers/ImageAssert.cs b/src/Uno.UI.RuntimeTests/Helpers/ImageAssert.cs index c000633bfbe9..5c76d9870e09 100644 --- a/src/Uno.UI.RuntimeTests/Helpers/ImageAssert.cs +++ b/src/Uno.UI.RuntimeTests/Helpers/ImageAssert.cs @@ -41,7 +41,7 @@ public static Task HasColorAtChild(RawBitmap screenshot, UIElement child, double public static async Task HasColorAtChild(RawBitmap screenshot, UIElement child, double x, double y, Color expectedColor, byte tolerance = 0, [CallerLineNumber] int line = 0) { var point = child.TransformToVisual(screenshot.RenderedElement).TransformPoint(new Windows.Foundation.Point(x, y)); - HasColorAtImpl(screenshot, (int)point.X, (int)point.Y, expectedColor, tolerance, line); + await HasColorAtImpl(screenshot, (int)point.X, (int)point.Y, expectedColor, tolerance, line); } /// diff --git a/src/Uno.UI.RuntimeTests/IntegrationTests/common/CalendarHelper.h.cs b/src/Uno.UI.RuntimeTests/IntegrationTests/common/CalendarHelper.h.cs index b75247b599b3..89c4a4ab4b6e 100644 --- a/src/Uno.UI.RuntimeTests/IntegrationTests/common/CalendarHelper.h.cs +++ b/src/Uno.UI.RuntimeTests/IntegrationTests/common/CalendarHelper.h.cs @@ -232,7 +232,7 @@ internal async Task WaitForSelectedDatesChanged() m_selectedDatesChangedRegistration.Detach(); } - internal async Task VerifyNoSelectedDatesChanged() + internal void VerifyNoSelectedDatesChanged() { // we expect no event here, so below statement will timeout and throw WEX.Common.Exception. TestServices.VERIFY_THROWS_WINRT( @@ -242,7 +242,7 @@ internal async Task VerifyNoSelectedDatesChanged() m_selectedDatesChangedRegistration.Detach(); } - internal async Task WaitForCICEvent() + internal void WaitForCICEvent() { m_cicEvent.WaitForDefault(); TestServices.VERIFY_IS_TRUE(m_cicEvent.HasFired()); diff --git a/src/Uno.UI.RuntimeTests/IntegrationTests/common/TestServices.cs b/src/Uno.UI.RuntimeTests/IntegrationTests/common/TestServices.cs index 55a5d65479e2..3dff317ba9ae 100644 --- a/src/Uno.UI.RuntimeTests/IntegrationTests/common/TestServices.cs +++ b/src/Uno.UI.RuntimeTests/IntegrationTests/common/TestServices.cs @@ -45,10 +45,15 @@ internal static FrameworkElement GetPopupOverlayElement(Popup popup) #endif } - internal static async Task RunOnUIThread(Action action) + internal static +#if !__WASM__ + async +#endif + Task RunOnUIThread(Action action) { #if __WASM__ action(); + return Task.CompletedTask; #else await WindowHelper.RootElementDispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => action()); #endif diff --git a/src/Uno.UI.RuntimeTests/IntegrationTests/dxaml/controls/appbar/AppBarIntegrationTests.cs b/src/Uno.UI.RuntimeTests/IntegrationTests/dxaml/controls/appbar/AppBarIntegrationTests.cs index dffc2c6b661a..c89c7c1e8602 100644 --- a/src/Uno.UI.RuntimeTests/IntegrationTests/dxaml/controls/appbar/AppBarIntegrationTests.cs +++ b/src/Uno.UI.RuntimeTests/IntegrationTests/dxaml/controls/appbar/AppBarIntegrationTests.cs @@ -780,7 +780,7 @@ await RunOnUIThread(() => [TestProperty("TestPass:ExcludeOn", "WindowsCore")] [TestProperty("HasAssociatedMasterFile", "True")] [Ignore("Missing VerifyUIElementTreeHelper")] - public async Task CanClosedDisplayModesControlLayout() + public void CanClosedDisplayModesControlLayout() { // TestCleanupWrapper cleanup; @@ -1133,7 +1133,7 @@ await RunOnUIThread(() => [TestProperty("TestPass:ExcludeOn", "WindowsCore")] [TestProperty("HasAssociatedMasterFile", "True")] [Ignore("ValidateUIElementTree not implemented")] - public async Task ValidateInlineAppBars() + public void ValidateInlineAppBars() { //ControlHelper::ValidateUIElementTree( // wf::Size(400, 600), @@ -1914,7 +1914,7 @@ await RunOnUIThread(() => [Ignore]// Not stable between runs; there is a phantom visual that keeps showing up.. [TestProperty("TestPass:ExcludeOn", "WindowsCore")] [TestProperty("HasAssociatedMasterFile", "True")] - public async Task ValidateOverlayDCompTree() + public void ValidateOverlayDCompTree() { // TestServices::WindowHelper->SetWindowSizeOverride(wf::Size(400, 400)); // WUCRenderingScopeGuard guard(DCompRendering::WUCCompleteSynchronousCompTree, false /*resizeWindow*/); @@ -1961,7 +1961,7 @@ public async Task ValidateOverlayDCompTree() [Description("Validates UIElement tree with an overlay-enabled app bar.")] [TestProperty("TestPass:ExcludeOn", "WindowsCore")] [TestProperty("HasAssociatedMasterFile", "True")] - public async Task ValidateOverlayUIETree() + public void ValidateOverlayUIETree() { TestCleanupWrapper cleanup; diff --git a/src/Uno.UI.RuntimeTests/IntegrationTests/dxaml/controls/calendarview/CalendarViewIntegrationTests.cs b/src/Uno.UI.RuntimeTests/IntegrationTests/dxaml/controls/calendarview/CalendarViewIntegrationTests.cs index 28d3a06c30e6..9675a4a2732f 100644 --- a/src/Uno.UI.RuntimeTests/IntegrationTests/dxaml/controls/calendarview/CalendarViewIntegrationTests.cs +++ b/src/Uno.UI.RuntimeTests/IntegrationTests/dxaml/controls/calendarview/CalendarViewIntegrationTests.cs @@ -342,7 +342,7 @@ await RunOnUIThread(() => cv.MaxDate = date; cv.UpdateLayout(); }); - await helper.VerifyNoSelectedDatesChanged(); + helper.VerifyNoSelectedDatesChanged(); } // remove the date @@ -421,7 +421,7 @@ await RunOnUIThread(() => } else { - await helper.VerifyNoSelectedDatesChanged(); + helper.VerifyNoSelectedDatesChanged(); } TestServices.Utilities.VerifyMockDCompOutput(MockDComp.SurfaceComparison.NoComparison, "S"); //Selected @@ -452,7 +452,7 @@ await RunOnUIThread(() => else { // otherwise, no selected dates chagned event. - await helper.VerifyNoSelectedDatesChanged(); + helper.VerifyNoSelectedDatesChanged(); } // the item stays selected until the last time we remove the date from SelectedDates. @@ -531,7 +531,7 @@ await RunOnUIThread(() => { cv.SelectedDates.SetAt(0, date); // no crash, no selected dates changed event. }); - await helper.VerifyNoSelectedDatesChanged(); + helper.VerifyNoSelectedDatesChanged(); } [TestMethod] @@ -583,7 +583,7 @@ await RunOnUIThread(() => LOG_OUTPUT("Release."); TestServices.InputHelper.DynamicRelease(PointerFinger.Finger1); await WindowHelper.WaitForIdle(); - await helper.VerifyNoSelectedDatesChanged(); + helper.VerifyNoSelectedDatesChanged(); await RunOnUIThread(() => { VERIFY_IS_TRUE(cv.SelectedDates.Count == 0u); @@ -852,7 +852,7 @@ await RunOnUIThread(() => await helper.WaitForLoaded(); - await helper.WaitForCICEvent(); + helper.WaitForCICEvent(); await helper.WaitForSelectedDatesChanged(); @@ -3068,9 +3068,9 @@ await RunOnUIThread(() => [TestMethod] [Ignore("ControlHelper.ValidateUIElementTree() not supported yet.")] - public async Task ValidateUIElementTree() + public void ValidateUIElementTree() { - await ControlHelper.ValidateUIElementTree( + ControlHelper.ValidateUIElementTree( new Size(400, 600), 1, // Test setup. diff --git a/src/Uno.UI.RuntimeTests/IntegrationTests/dxaml/controls/commandbar/CommandBarIntegrationTests.cs b/src/Uno.UI.RuntimeTests/IntegrationTests/dxaml/controls/commandbar/CommandBarIntegrationTests.cs index c49a70b02d41..b9a339c74f99 100644 --- a/src/Uno.UI.RuntimeTests/IntegrationTests/dxaml/controls/commandbar/CommandBarIntegrationTests.cs +++ b/src/Uno.UI.RuntimeTests/IntegrationTests/dxaml/controls/commandbar/CommandBarIntegrationTests.cs @@ -252,11 +252,12 @@ public async Task CanCloseUsingBackButton() TestCleanupWrapper cleanup; Func openFunc = async (cmdBar) => await RunOnUIThread(() => cmdBar.IsOpen = true); - Func closeFunc = async (cmdBar) => + Func closeFunc = (cmdBar) => { bool backButtonPressHandled = false; TestServices.Utilities.InjectBackButtonPress(ref backButtonPressHandled); VERIFY_IS_TRUE(backButtonPressHandled); + return Task.CompletedTask; }; await ValidateOpenAndCloseWorker(openFunc, closeFunc); @@ -501,7 +502,7 @@ await RunOnUIThread(() => [Description("Validates that the overflow's max height is 50% of the window height.")] [TestProperty("Hosting:Mode", "UAP")] [Ignore("SetWindowSizeOverride not implemented")] - public async Task ValidateOverflowMaxHeight() + public void ValidateOverflowMaxHeight() { // TestCleanupWrapper cleanup; @@ -1006,7 +1007,7 @@ await RunOnUIThread(() => [TestProperty("TestPass:ExcludeOn", "WindowsCore")] [TestProperty("Hosting:Mode", "UAP")] [Ignore("MouseHelper not implemented.")] // CoreWindow pointer events no longering being raised from lifted Xaml - public async Task ValidateRightClickBehavior() + public void ValidateRightClickBehavior() { LOG_OUTPUT("Validating CommandBarRightClickBehavior with ClosedDisplayMode=Hidden."); ValidateRightClickBehaviorWorker(AppBarClosedDisplayMode.Hidden); @@ -1174,7 +1175,7 @@ await RunOnUIThread(() => [TestMethod] [Ignore("ControlHelper.ValidateUIElementTree not implemented.")] - public async Task ValidateUIElementTreeBoth() + public void ValidateUIElementTreeBoth() { //TestCleanupWrapper cleanup; @@ -1197,7 +1198,7 @@ public async Task ValidateUIElementTreeBoth() [TestMethod] [Ignore("ControlHelper.ValidateUIElementTree not implemented.")] - public async Task ValidateUIElementTreePrimaryOnly() + public void ValidateUIElementTreePrimaryOnly() { //TestCleanupWrapper cleanup; @@ -1220,7 +1221,7 @@ public async Task ValidateUIElementTreePrimaryOnly() [TestMethod] [Ignore("ControlHelper.ValidateUIElementTree not implemented.")] - public async Task ValidateUIElementTreeSecondaryOnly() + public void ValidateUIElementTreeSecondaryOnly() { //TestCleanupWrapper cleanup; @@ -1775,7 +1776,7 @@ await RunOnUIThread(() => [Description("Validates that after clicking on an AppBarButton, the CommandBar closes before the button's click handlers execute.")] [TestProperty("TestPass:ExcludeOn", "WindowsCore")] - public async Task DoesCloseBeforeButtonClickHandlersExecute() + public void DoesCloseBeforeButtonClickHandlersExecute() { } @@ -3497,7 +3498,7 @@ await RunOnUIThread(async () => CommonInputHelper.Left(inputDevice, cmdBar); await WindowHelper.WaitForIdle(); - await RunOnUIThread(async () => + await RunOnUIThread(() => { var focusedElement = FocusManager.GetFocusedElement(WindowHelper.WindowContent.XamlRoot); VERIFY_IS_TRUE(focusedElement.Equals(cmdBar.PrimaryCommands.GetAt(0)), $"Input: {inputDevice}, Focused element ({focusedElement.GetHashCode()}) should be primary command ({cmdBar.PrimaryCommands.GetAt(0).GetHashCode()})"); @@ -3507,7 +3508,7 @@ await RunOnUIThread(async () => CommonInputHelper.Left(inputDevice, cmdBar); await WindowHelper.WaitForIdle(); - await RunOnUIThread(async () => + await RunOnUIThread(() => { var focusedElement = FocusManager.GetFocusedElement(WindowHelper.WindowContent.XamlRoot); VERIFY_IS_TRUE(focusedElement.Equals(cmdBar.Content), $"Input: {inputDevice}, Focused element ({focusedElement.GetHashCode()}) should be content ({cmdBar.Content.GetHashCode()})"); @@ -5242,7 +5243,7 @@ private static UIElement GetSecondaryItemsPresenter(CommandBar cmdBar) } - private async Task ValidateUIElementTestSetup(bool addPrimary, bool addSecondary) + private Panel ValidateUIElementTestSetup(bool addPrimary, bool addSecondary) { // xaml_controls::Grid^ rootGrid = nullptr; // RunOnUIThread([&] () @@ -5322,7 +5323,7 @@ private async Task ValidateUIElementTestSetup(bool addPrimary, bool addSe return new Grid(); } - private async Task ValidateRightClickBehaviorWorker(AppBarClosedDisplayMode closedDisplayMode) + private void ValidateRightClickBehaviorWorker(AppBarClosedDisplayMode closedDisplayMode) { // // CoreWindow isn't agile, so we can't use the SafeEventRegistration utility, // // so we have to manage it manually. diff --git a/src/Uno.UI.RuntimeTests/MUX/Helpers/ControlHelper.cs b/src/Uno.UI.RuntimeTests/MUX/Helpers/ControlHelper.cs index 76f5dfe15504..f45130346a48 100644 --- a/src/Uno.UI.RuntimeTests/MUX/Helpers/ControlHelper.cs +++ b/src/Uno.UI.RuntimeTests/MUX/Helpers/ControlHelper.cs @@ -92,7 +92,7 @@ await RunOnUIThread.ExecuteAsync(() => await DoClickUsingAP(button); } - public static async Task ValidateUIElementTree( + public static void ValidateUIElementTree( Size windowSizeOverride, double scale, Func> setup, diff --git a/src/Uno.UI.RuntimeTests/MUX/Microsoft_UI_Xaml_Controls/Repeater/ItemTemplateTests.cs b/src/Uno.UI.RuntimeTests/MUX/Microsoft_UI_Xaml_Controls/Repeater/ItemTemplateTests.cs index 16e5f5d9e289..e55f45ebeb8c 100644 --- a/src/Uno.UI.RuntimeTests/MUX/Microsoft_UI_Xaml_Controls/Repeater/ItemTemplateTests.cs +++ b/src/Uno.UI.RuntimeTests/MUX/Microsoft_UI_Xaml_Controls/Repeater/ItemTemplateTests.cs @@ -47,7 +47,7 @@ public class ItemTemplateTests : MUXApiTestBase [TestMethod] public async Task ValidateRecycling() { - await RunOnUIThread.ExecuteAsync(async () => + await RunOnUIThread.ExecuteAsync(() => { var elementFactory = new RecyclingElementFactory() { @@ -381,7 +381,7 @@ await RunOnUIThread.ExecuteAsync(async () => public async Task ValidateNoSizeWhenEmptyDataTemplate() { ItemsRepeater repeater = null; - await RunOnUIThread.ExecuteAsync(async () => + await RunOnUIThread.ExecuteAsync(() => { var elementFactory = new RecyclingElementFactory(); elementFactory.RecyclePool = new RecyclePool(); @@ -459,7 +459,7 @@ await RunOnUIThread.ExecuteAsync(async () => [TestMethod] public async Task ValidateReyclingElementFactoryWithNoTemplate() { - await RunOnUIThread.ExecuteAsync(async () => + await RunOnUIThread.ExecuteAsync(() => { var elementFactory = new RecyclingElementFactoryDerived() { @@ -521,7 +521,7 @@ await RunOnUIThread.ExecuteAsync(async () => [TestMethod] public async Task ValidateTemplateSwitchingRefreshesElementsVirtualizingLayout() { - await RunOnUIThread.ExecuteAsync(async () => + await RunOnUIThread.ExecuteAsync(() => { ValidateTemplateSwitchingRefreshesElements(new StackLayout()); }); @@ -530,7 +530,7 @@ await RunOnUIThread.ExecuteAsync(async () => [TestMethod] public async Task ValidateTemplateSwitchingRefreshesElementsNonVirtualizingLayout() { - await RunOnUIThread.ExecuteAsync(async () => + await RunOnUIThread.ExecuteAsync(() => { ValidateTemplateSwitchingRefreshesElements(new NonVirtualStackLayout()); }); diff --git a/src/Uno.UI.RuntimeTests/MUX/Utilities/RunOnUIThread.cs b/src/Uno.UI.RuntimeTests/MUX/Utilities/RunOnUIThread.cs index 61e6e4d47881..7b4ab8b79d6c 100644 --- a/src/Uno.UI.RuntimeTests/MUX/Utilities/RunOnUIThread.cs +++ b/src/Uno.UI.RuntimeTests/MUX/Utilities/RunOnUIThread.cs @@ -102,13 +102,21 @@ public static void Execute(CoreApplicationView whichView, Action action) } public static async Task ExecuteAsync(Action action) => - await ExecuteAsync(CoreApplication.MainView, async () => action()); + await ExecuteAsync(CoreApplication.MainView, () => + { + action(); + return Task.CompletedTask; + }); public static async Task ExecuteAsync(Func task) => await ExecuteAsync(CoreApplication.MainView, task); public static async Task ExecuteAsync(CoreApplicationView whichView, Action action) => - await ExecuteAsync(whichView, async () => action()); + await ExecuteAsync(whichView, () => + { + action(); + return Task.CompletedTask; + }); public static async Task ExecuteAsync(CoreApplicationView whichView, Func task) { diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_Foundation/Collections/Given_ValueSet.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_Foundation/Collections/Given_ValueSet.cs index a2423efeb7ab..f1dd5065b236 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Windows_Foundation/Collections/Given_ValueSet.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Windows_Foundation/Collections/Given_ValueSet.cs @@ -33,7 +33,7 @@ public void Cleanup() } [TestMethod] - public async void When_ModificationEvent() + public void When_ModificationEvent() { // .Add diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_Foundation/Metadata/Given_ApiInformation.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_Foundation/Metadata/Given_ApiInformation.cs index e1cb4fdb5e78..65b0dfdd4e71 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Windows_Foundation/Metadata/Given_ApiInformation.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Windows_Foundation/Metadata/Given_ApiInformation.cs @@ -8,7 +8,7 @@ namespace Uno.UI.RuntimeTests.Tests.Windows_Foundation.Metadata public class Given_ApiInformation { [TestMethod] - public async Task When_IsPropertyPresent_Called_Twice() + public void When_IsPropertyPresent_Called_Twice() { // Verifies fix for issue #4803 // SharedHelpers called IsPropertyPresent twice for an implemented property diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_Storage/Given_StorageFolder_Native.wasm.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_Storage/Given_StorageFolder_Native.wasm.cs index a91af1003467..b8bc9a076411 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Windows_Storage/Given_StorageFolder_Native.wasm.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Windows_Storage/Given_StorageFolder_Native.wasm.cs @@ -19,8 +19,9 @@ protected override async Task GetRootFolderAsync() return folder!; } - protected override async Task CleanupRootFolderAsync() + protected override Task CleanupRootFolderAsync() { + return Task.CompletedTask; } } } diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_Storage/Streams/Given_DataWriter.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_Storage/Streams/Given_DataWriter.cs index 6991b8dcf775..57d98b650d9f 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Windows_Storage/Streams/Given_DataWriter.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Windows_Storage/Streams/Given_DataWriter.cs @@ -14,7 +14,7 @@ namespace Uno.UI.RuntimeTests.Tests.Windows_Storage.Streams public class When_DataWriter { [TestMethod] - public async Task When_WriteThenRead() + public void When_WriteThenRead() { bool saveBool = true; byte saveByte = 10; diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_System/Given_DispatcherQueueTimer.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_System/Given_DispatcherQueueTimer.cs index 83a54b55d41b..4c6548584eb4 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Windows_System/Given_DispatcherQueueTimer.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Windows_System/Given_DispatcherQueueTimer.cs @@ -160,7 +160,7 @@ public async Task When_StartAndStopFromBackgroundThread() [TestMethod] [RunsOnUIThread] [ExpectedException(typeof(ArgumentException))] - public async Task When_SetNegativeInterval() + public void When_SetNegativeInterval() { var timer = DispatcherQueue.GetForCurrentThread().CreateTimer(); diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_UI/Given_Color.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_UI/Given_Color.cs index ddc118e58a26..3a745565bba4 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Windows_UI/Given_Color.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Windows_UI/Given_Color.cs @@ -17,12 +17,12 @@ public class Given_Color #if HAS_UNO [TestMethod] [DynamicData(nameof(GetData), DynamicDataSourceType.Method)] - public async Task When_FromArgb(byte a, byte r, byte g, byte b, uint result) + public void When_FromArgb(byte a, byte r, byte g, byte b, uint result) => Assert.AreEqual(result, Color.FromArgb(a, r, g, b).AsUInt32()); [TestMethod] [DynamicData(nameof(GetData), DynamicDataSourceType.Method)] - public async Task When_GetHashCode(byte a, byte r, byte g, byte b, uint result) + public void When_GetHashCode(byte a, byte r, byte g, byte b, uint result) => Assert.AreEqual(result, (uint)Color.FromArgb(a, r, g, b).GetHashCode()); public static IEnumerable GetData() @@ -42,12 +42,12 @@ public static IEnumerable GetData() [TestMethod] [DynamicData(nameof(GetCompare), DynamicDataSourceType.Method)] - public async Task When_Equals(Color left, Color right, bool result) + public void When_Equals(Color left, Color right, bool result) => Assert.AreEqual(result, left.Equals(right)); [TestMethod] [DynamicData(nameof(GetCompare), DynamicDataSourceType.Method)] - public async Task When_op_Equals(Color left, Color right, bool result) + public void When_op_Equals(Color left, Color right, bool result) => Assert.AreEqual(result, left == right); public static IEnumerable GetCompare() diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Popups/Given_MessageDialog.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Popups/Given_MessageDialog.cs index 246ee22e5620..45a5b4531b22 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Popups/Given_MessageDialog.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Popups/Given_MessageDialog.cs @@ -25,7 +25,7 @@ public class Given_MessageDialog { [TestMethod] [RunsOnUIThread] - public async Task Should_Close_Open_Flyouts() + public void Should_Close_Open_Flyouts() { var button = new Windows.UI.Xaml.Controls.Button(); var flyout = new Flyout(); @@ -42,7 +42,7 @@ public async Task Should_Close_Open_Flyouts() [TestMethod] [RunsOnUIThread] - public async Task Should_Not_Close_Open_ContentDialogs() + public void Should_Not_Close_Open_ContentDialogs() { Assert.AreEqual(0, GetNonMessageDialogPopupsCount()); diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Controls/ItemsControl_ItemsSource_Leak.xaml.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Controls/ItemsControl_ItemsSource_Leak.xaml.cs index 3e5f5e6db627..5c401e411de6 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Controls/ItemsControl_ItemsSource_Leak.xaml.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Controls/ItemsControl_ItemsSource_Leak.xaml.cs @@ -21,7 +21,7 @@ public ItemsControl_ItemsSource_Leak() InitializeComponent(); } - public async Task WaitForTestToComplete() + public Task WaitForTestToComplete() { control1.ItemsSource = _staticObservableCollection; control3.ItemsSource = _staticCollectionViewSource; @@ -29,6 +29,7 @@ public async Task WaitForTestToComplete() #if HAS_UNO control2.ItemsSource = _staticObservableVector; #endif + return Task.CompletedTask; } } } diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Given_FrameworkElement.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Given_FrameworkElement.cs index d2411f3af30d..b86eeefd61a1 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Given_FrameworkElement.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Given_FrameworkElement.cs @@ -574,7 +574,7 @@ public async Task When_Add_Element_Then_Load_Raised() [TestMethod] [RunsOnUIThread] - public async Task When_Add_Native_Child_To_ElementCollection() + public void When_Add_Native_Child_To_ElementCollection() { var panel = new Grid(); var tbNativeTyped = (_View)new TextBlock(); @@ -585,7 +585,7 @@ public async Task When_Add_Native_Child_To_ElementCollection() [TestMethod] [RunsOnUIThread] - public async Task When_Set_Name() + public void When_Set_Name() { var SUT = new Border(); SUT.Name = "Test"; @@ -595,7 +595,7 @@ public async Task When_Set_Name() [TestMethod] [RunsOnUIThread] - public async Task When_Set_NameProperty() + public void When_Set_NameProperty() { var SUT = new Border(); SUT.SetValue(FrameworkElement.NameProperty, "Test"); diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Given_Style.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Given_Style.cs index 1cbde67c90f6..fe8806153b27 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Given_Style.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Given_Style.cs @@ -17,7 +17,7 @@ public class Given_Style #if !NETFX_CORE // Control template does not support lambda parameter [TestMethod] [RunsOnUIThread] - public async Task When_StyleFailsToApply() + public void When_StyleFailsToApply() { var style = new Style() { diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Given_UIElement.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Given_UIElement.cs index ae8ce0affde2..2417d6121bf6 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Given_UIElement.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Given_UIElement.cs @@ -294,7 +294,7 @@ public async Task When_InvalidatingMeasureExplicitly() [DataRow(0.001d)] [DataRow(0.1d)] [DataRow(100d)] - public async Task When_InvalidatingMeasureThenMeasure(double size) + public void When_InvalidatingMeasureThenMeasure(double size) { var sut = new MeasureAndArrangeCounter(); @@ -320,7 +320,7 @@ public async Task When_InvalidatingMeasureThenMeasure(double size) [DataRow(0.001d)] [DataRow(0.1d)] [DataRow(100d)] - public async Task When_InvalidatingArrangeThenMeasureAndArrange(double size) + public void When_InvalidatingArrangeThenMeasureAndArrange(double size) { var sut = new MeasureAndArrangeCounter(); diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Given_UIElement.wasm.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Given_UIElement.wasm.cs index 19dfb23338f7..649cfebcb183 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Given_UIElement.wasm.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Given_UIElement.wasm.cs @@ -24,7 +24,7 @@ public partial class Given_UIElement { [TestMethod] [RunsOnUIThread] - public async Task When_HTMLElement_InternalElement() + public void When_HTMLElement_InternalElement() { var SUT = new Line(); @@ -34,7 +34,7 @@ public async Task When_HTMLElement_InternalElement() [TestMethod] [RunsOnUIThread] - public async Task When_HTMLElement_ExternalElement_NoOverride() + public void When_HTMLElement_ExternalElement_NoOverride() { var SUT = new MyLine(); @@ -43,7 +43,7 @@ public async Task When_HTMLElement_ExternalElement_NoOverride() [TestMethod] [RunsOnUIThread] - public async Task When_HTMLElement_ExternalElement_Override() + public void When_HTMLElement_ExternalElement_Override() { var SUT = new MyLineOverride(); @@ -66,7 +66,7 @@ public async Task When_HTMLElement_ExternalElement_Override_Then_IsHitTestable() [TestMethod] [RunsOnUIThread] - public async Task When_HTMLElement_ExternalElement_Override_Twice() + public void When_HTMLElement_ExternalElement_Override_Twice() { var SUT = new MyLine2(); diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Given_xLoad.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Given_xLoad.cs index 6c077fb419c9..4c3cbb239fc0 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Given_xLoad.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Given_xLoad.cs @@ -18,7 +18,7 @@ public class Given_xLoad { [TestMethod] [RunsOnUIThread] - public async Task When_xLoad_Literal() + public void When_xLoad_Literal() { var sut = new xLoad_Literal(); @@ -32,7 +32,7 @@ public async Task When_xLoad_Literal() [TestMethod] [RunsOnUIThread] - public async Task When_xLoad_xBind() + public void When_xLoad_xBind() { var sut = new xLoad_xBind(); @@ -80,7 +80,7 @@ public void When_xLoad_Visibility_While_Materializing() [TestMethod] [RunsOnUIThread] - public async Task When_xLoad_xBind_xLoad_Initial() + public void When_xLoad_xBind_xLoad_Initial() { var grid = new Grid(); TestServices.WindowHelper.WindowContent = grid; @@ -98,7 +98,7 @@ public async Task When_xLoad_xBind_xLoad_Initial() [TestMethod] [RunsOnUIThread] - public async Task When_xLoad_xBind_xLoad_While_Loading() + public void When_xLoad_xBind_xLoad_While_Loading() { var grid = new Grid(); TestServices.WindowHelper.WindowContent = grid; diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_Flyout.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_Flyout.cs index c131b00c6c07..a4807d67ece8 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_Flyout.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_Flyout.cs @@ -45,12 +45,12 @@ public async Task When_Unloaded_Before_Shown() await TestServices.WindowHelper.WaitForIdle(); } - +#if IS_UNO [TestMethod] [RunsOnUIThread] public async Task When_LoadedAndUnloaded_Check_Binding() { -#if IS_UNO + var (flyout, content) = CreateFlyoutWithBindingMultipleChildren(); const double MarginValue = 105; @@ -105,8 +105,9 @@ public async Task When_LoadedAndUnloaded_Check_Binding() Assert.AreEqual("A New Context", (stackPanel.Children[0] as TextBlock).Text); flyout.Hide(); + + } #endif - } [TestMethod] #if __MACOS__ @@ -451,11 +452,12 @@ public async Task Check_Placement_All_MenuFlyout( } } +#if IS_UNO [TestMethod] [RunsOnUIThread] public async Task Test_Flyout_Binding() { -#if IS_UNO + var (flyout, content) = CreateFlyoutWithBinding(); var buttonA = new Button() @@ -475,8 +477,8 @@ public async Task Test_Flyout_Binding() var stackPanel = content as StackPanel; Assert.AreEqual("My Data Context", (stackPanel.Children[0] as TextBlock).Text); -#endif } +#endif [TestMethod] [RunsOnUIThread] diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_Image.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_Image.cs index aa5edb4a64bb..3a81598eccaf 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_Image.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_Image.cs @@ -122,7 +122,7 @@ public async Task When_Resource_Has_Scale_Qualifier() [TestMethod] [RunsOnUIThread] - public async Task TargetNullValue_Is_Correctly_Applied() + public void TargetNullValue_Is_Correctly_Applied() { var SUT = new ImageSource_TargetNullValue(); diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_ListViewBase_Items.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_ListViewBase_Items.cs index 2d0573dd2f60..dcd988f286ce 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_ListViewBase_Items.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_ListViewBase_Items.cs @@ -29,7 +29,7 @@ namespace Uno.UI.RuntimeTests.Tests.Windows_UI_Xaml_Controls public partial class Given_ListViewBase_Items { [TestMethod] - public async Task When_Items_Added_Count_Updated() + public void When_Items_Added_Count_Updated() { var listView = new ListView(); listView.Items.Add(1); @@ -37,7 +37,7 @@ public async Task When_Items_Added_Count_Updated() } [TestMethod] - public async Task When_Items_Added_ItemsSource_Stays_Null() + public void When_Items_Added_ItemsSource_Stays_Null() { var listView = new ListView(); listView.Items.Add(1); @@ -45,7 +45,7 @@ public async Task When_Items_Added_ItemsSource_Stays_Null() } [TestMethod] - public async Task When_ItemsSource_Used_Items_NotNull() + public void When_ItemsSource_Used_Items_NotNull() { var listView = new ListView(); listView.ItemsSource = new List() { 1, 2 }; @@ -53,7 +53,7 @@ public async Task When_ItemsSource_Used_Items_NotNull() } [TestMethod] - public async Task When_ItemsSource_Unset_Items_NotNull() + public void When_ItemsSource_Unset_Items_NotNull() { var listView = new ListView(); listView.ItemsSource = new List() { 1, 2 }; @@ -63,7 +63,7 @@ public async Task When_ItemsSource_Unset_Items_NotNull() } [TestMethod] - public async Task When_ItemsSource_Set_To_Empty_Items_Cleared() + public void When_ItemsSource_Set_To_Empty_Items_Cleared() { var listView = new ListView(); listView.Items.Add(1); @@ -72,7 +72,7 @@ public async Task When_ItemsSource_Set_To_Empty_Items_Cleared() } [TestMethod] - public async Task When_ItemsSource_Unset_Items_Not_Cleared() + public void When_ItemsSource_Unset_Items_Not_Cleared() { var listView = new ListView(); listView.Items.Add(1); @@ -82,7 +82,7 @@ public async Task When_ItemsSource_Unset_Items_Not_Cleared() } [TestMethod] - public async Task When_ItemsSource_Unset_When_Already_Null_Items_Not_Cleared() + public void When_ItemsSource_Unset_When_Already_Null_Items_Not_Cleared() { var listView = new ListView(); listView.Items.Add(1); @@ -91,7 +91,7 @@ public async Task When_ItemsSource_Unset_When_Already_Null_Items_Not_Cleared() } [TestMethod] - public async Task When_ItemsSource_Set_Items_Not_Modifiable() + public void When_ItemsSource_Set_Items_Not_Modifiable() { var listView = new ListView(); listView.ItemsSource = new List() { 1 }; @@ -110,7 +110,7 @@ public async Task When_ItemsSource_Set_Items_Not_Modifiable() } [TestMethod] - public async Task When_ItemsSource_Unset_Items_Modifiable() + public void When_ItemsSource_Unset_Items_Modifiable() { var listView = new ListView(); listView.ItemsSource = new List() { 1 }; @@ -119,7 +119,7 @@ public async Task When_ItemsSource_Unset_Items_Modifiable() } [TestMethod] - public async Task When_ItemsSource_List_Modified_Change_Is_Reflected() + public void When_ItemsSource_List_Modified_Change_Is_Reflected() { var listView = new ListView(); var items = new List() { 1 }; @@ -130,7 +130,7 @@ public async Task When_ItemsSource_List_Modified_Change_Is_Reflected() } [TestMethod] - public async Task When_ItemsSource_List_Modified_VectorChange_Not_Triggered() + public void When_ItemsSource_List_Modified_VectorChange_Not_Triggered() { var listView = new ListView(); var items = new List() { 1 }; @@ -147,7 +147,7 @@ public async Task When_ItemsSource_List_Modified_VectorChange_Not_Triggered() } [TestMethod] - public async Task When_ItemsSource_Resets_ItemsCollection_Reference_Does_Not_Change() + public void When_ItemsSource_Resets_ItemsCollection_Reference_Does_Not_Change() { var listView = new ListView(); var oldItems = listView.Items; @@ -162,7 +162,7 @@ public async Task When_ItemsSource_Resets_ItemsCollection_Reference_Does_Not_Cha } [TestMethod] - public async Task When_ItemsSource_ObservableCollection_Modified_VectorChange_Triggered() + public void When_ItemsSource_ObservableCollection_Modified_VectorChange_Triggered() { var listView = new ListView(); var items = new ObservableCollection() { 1 }; @@ -179,7 +179,7 @@ public async Task When_ItemsSource_ObservableCollection_Modified_VectorChange_Tr } [TestMethod] - public async Task When_ItemsSource_Set_Items_Sync() + public void When_ItemsSource_Set_Items_Sync() { var listView = new ListView(); @@ -191,7 +191,7 @@ public async Task When_ItemsSource_Set_Items_Sync() } [TestMethod] - public async Task When_ItemsSource_Updated_Items_Sync() + public void When_ItemsSource_Updated_Items_Sync() { var listView = new ListView(); @@ -209,7 +209,7 @@ public async Task When_ItemsSource_Updated_Items_Sync() [TestMethod] - public async Task When_ItemsSource_Changes_Items_VectorChanged_Triggered() + public void When_ItemsSource_Changes_Items_VectorChanged_Triggered() { var listView = new ListView(); @@ -233,7 +233,7 @@ public async Task When_ItemsSource_Changes_Items_VectorChanged_Triggered() } [TestMethod] - public async Task When_ItemsSource_Enumerable_Changes_Items_Do_Not_Sync() + public void When_ItemsSource_Enumerable_Changes_Items_Do_Not_Sync() { var listView = new ListView(); @@ -251,7 +251,7 @@ public async Task When_ItemsSource_Enumerable_Changes_Items_Do_Not_Sync() [TestMethod] - public async Task When_ItemsSource_ReadOnly_Items_ReadOnly_Does_Not_Change() + public void When_ItemsSource_ReadOnly_Items_ReadOnly_Does_Not_Change() { var listView = new ListView(); Assert.IsFalse(listView.Items.IsReadOnly); @@ -260,7 +260,7 @@ public async Task When_ItemsSource_ReadOnly_Items_ReadOnly_Does_Not_Change() } [TestMethod] - public async Task When_ItemsSource_ICollection_Items_Do_Not_Sync() + public void When_ItemsSource_ICollection_Items_Do_Not_Sync() { var listView = new ListView(); var items = new Dictionary() { { 1, "Hello" } }; diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_TextBlock.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_TextBlock.cs index 99ebd8c30f6e..02cab1e74d2b 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_TextBlock.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_TextBlock.cs @@ -59,7 +59,7 @@ public void Check_Text_When_Having_Inline_Text_In_Span() [TestMethod] [RunsOnUIThread] - public async Task When_Null_FontFamily() + public void When_Null_FontFamily() { var SUT = new TextBlock { Text = "Some text", FontFamily = null }; WindowHelper.WindowContent = SUT; diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Markup/Given_MarkupExtension.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Markup/Given_MarkupExtension.cs index 27cf2e590232..7ebb5aa97830 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Markup/Given_MarkupExtension.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Markup/Given_MarkupExtension.cs @@ -21,7 +21,7 @@ public class Given_MarkupExtension { #if HAS_UNO || !WINDOWS_UWP // the signatures are present from winui, uno\uwp and uno\winui, just not uwp [TestMethod] - public async Task When_MarkupExtension_Default() + public void When_MarkupExtension_Default() { var page = new MarkupExtension_ParserContext(); @@ -35,7 +35,7 @@ public async Task When_MarkupExtension_Default() } [TestMethod] - public async Task When_MarkupExtension_Nested() + public void When_MarkupExtension_Nested() { var page = new MarkupExtension_ParserContext(); diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Media_Imaging/Given_BitmapSource.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Media_Imaging/Given_BitmapSource.cs index ceb5b8048037..4c4aa9bf2242 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Media_Imaging/Given_BitmapSource.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Media_Imaging/Given_BitmapSource.cs @@ -19,7 +19,7 @@ public class Given_BitmapSource { [TestMethod] [RunsOnUIThread] - public async Task When_SetSource_Then_StreamClonedSynchronously() + public void When_SetSource_Then_StreamClonedSynchronously() { var sut = new BitmapImage(); var stream = new Given_BitmapSource_Stream(); @@ -40,7 +40,7 @@ public async Task When_SetSource_Then_StreamClonedSynchronously() [TestMethod] [RunsOnUIThread] - public async Task When_SetSourceAsync_Then_StreamClonedSynchronously() + public void When_SetSourceAsync_Then_StreamClonedSynchronously() { var sut = new BitmapImage(); var stream = new Given_BitmapSource_Stream(); @@ -85,7 +85,7 @@ public async Task When_MsAppData() #if !WINDOWS_UWP [TestMethod] [RunsOnUIThread] - public async Task When_SetSource_Stream_Then_StreamClonedSynchronously() + public void When_SetSource_Stream_Then_StreamClonedSynchronously() { var sut = new BitmapImage(); var stream = new Given_BitmapSource_Stream(); @@ -105,7 +105,7 @@ public async Task When_SetSource_Stream_Then_StreamClonedSynchronously() [TestMethod] [RunsOnUIThread] - public async Task When_SetSourceAsync_Stream_Then_StreamClonedSynchronously() + public void When_SetSourceAsync_Stream_Then_StreamClonedSynchronously() { var sut = new BitmapImage(); var stream = new Given_BitmapSource_Stream(); diff --git a/src/Uno.UI.TestComparer/Program.cs b/src/Uno.UI.TestComparer/Program.cs index b2209cf6fdff..daba5d94d3e7 100644 --- a/src/Uno.UI.TestComparer/Program.cs +++ b/src/Uno.UI.TestComparer/Program.cs @@ -160,7 +160,7 @@ IEnumerable GetAllPlatforms() private static async Task TryPublishPRComments(List results, string githubPAT, string sourceRepository, string githubPRid, int currentBuild) { - var comment = await BuildPRComment(results, currentBuild); + var comment = BuildPRComment(results, currentBuild); if (!int.TryParse(githubPRid, out _)) { @@ -179,7 +179,7 @@ private static async Task TryPublishPRComments(List results, stri await GitHubClient.PostPRCommentsAsync(githubPAT, sourceRepository, githubPRid, comment); } - private static async Task BuildPRComment(List results, int currentBuild) + private static string BuildPRComment(List results, int currentBuild) { var comment = new StringBuilder(); var hasErrors = results.Any(r => r.TotalTests - r.UnchangedTests != 0); diff --git a/src/Uno.UI.TestComparer/Uno.UI.TestComparer.csproj b/src/Uno.UI.TestComparer/Uno.UI.TestComparer.csproj index 92a2df813d39..2152d2756f04 100644 --- a/src/Uno.UI.TestComparer/Uno.UI.TestComparer.csproj +++ b/src/Uno.UI.TestComparer/Uno.UI.TestComparer.csproj @@ -6,7 +6,7 @@ true false true - SYSLIB0014;CS1998 + SYSLIB0014 diff --git a/src/Uno.UI.Tests.Performance/Uno.UI.Tests.Performance.csproj b/src/Uno.UI.Tests.Performance/Uno.UI.Tests.Performance.csproj index 428e3748a4bb..c64f7f0cc419 100644 --- a/src/Uno.UI.Tests.Performance/Uno.UI.Tests.Performance.csproj +++ b/src/Uno.UI.Tests.Performance/Uno.UI.Tests.Performance.csproj @@ -2,7 +2,7 @@ net461 false - 1998;4014;67 + 4014;67 bin\$(Platform)\$(Configuration) Exe diff --git a/src/Uno.UI.Tests.ViewLibrary/Uno.UI.Tests.ViewLibrary.csproj b/src/Uno.UI.Tests.ViewLibrary/Uno.UI.Tests.ViewLibrary.csproj index 574c13045b57..1a0bc83ec374 100644 --- a/src/Uno.UI.Tests.ViewLibrary/Uno.UI.Tests.ViewLibrary.csproj +++ b/src/Uno.UI.Tests.ViewLibrary/Uno.UI.Tests.ViewLibrary.csproj @@ -1,7 +1,7 @@  net461 - 1998;4014;67 + 4014;67 bin\$(Platform)\$(Configuration) true false diff --git a/src/Uno.UI.Tests.ViewLibraryProps/Uno.UI.Tests.ViewLibraryProps.csproj b/src/Uno.UI.Tests.ViewLibraryProps/Uno.UI.Tests.ViewLibraryProps.csproj index 1606a287771c..fa50779f710f 100644 --- a/src/Uno.UI.Tests.ViewLibraryProps/Uno.UI.Tests.ViewLibraryProps.csproj +++ b/src/Uno.UI.Tests.ViewLibraryProps/Uno.UI.Tests.ViewLibraryProps.csproj @@ -1,7 +1,7 @@ net461 - 1998;4014;67 + 4014;67 bin\$(Platform)\$(Configuration) true false diff --git a/src/Uno.UI.Tests/Uno.UI.Tests.csproj b/src/Uno.UI.Tests/Uno.UI.Tests.csproj index 36623242db98..e9d70338b0a0 100644 --- a/src/Uno.UI.Tests/Uno.UI.Tests.csproj +++ b/src/Uno.UI.Tests/Uno.UI.Tests.csproj @@ -2,7 +2,7 @@ net461 false - 1998;4014;67;CA1824 + 4014;67;CA1824 bin\$(Platform)\$(Configuration) true true diff --git a/src/Uno.UI.Tests/Windows_UI_XAML_Controls/ItemsControlTests/Given_ItemsControl.cs b/src/Uno.UI.Tests/Windows_UI_XAML_Controls/ItemsControlTests/Given_ItemsControl.cs index 24bfb5871fe0..2b41e82f03d4 100644 --- a/src/Uno.UI.Tests/Windows_UI_XAML_Controls/ItemsControlTests/Given_ItemsControl.cs +++ b/src/Uno.UI.Tests/Windows_UI_XAML_Controls/ItemsControlTests/Given_ItemsControl.cs @@ -461,7 +461,7 @@ public void When_ContainerStyleSet() } [TestMethod] - public async Task When_ItemsSource_Changes_Items_VectorChanged_Triggered() + public void When_ItemsSource_Changes_Items_VectorChanged_Triggered() { var listView = new ItemsControl(); @@ -532,7 +532,7 @@ public async Task When_Collection_Reset() #endif [TestMethod] - public async Task When_Collection_Append() + public void When_Collection_Append() { var count = 0; var panel = new StackPanel(); diff --git a/src/Uno.UI/UI/Xaml/Controls/AnimatedVisualPlayer/AnimatedVisualPlayer.cs b/src/Uno.UI/UI/Xaml/Controls/AnimatedVisualPlayer/AnimatedVisualPlayer.cs index 6ca07af9acbb..c7b73c3b1df8 100644 --- a/src/Uno.UI/UI/Xaml/Controls/AnimatedVisualPlayer/AnimatedVisualPlayer.cs +++ b/src/Uno.UI/UI/Xaml/Controls/AnimatedVisualPlayer/AnimatedVisualPlayer.cs @@ -96,7 +96,11 @@ private static void UpdateSourceOnChanged(DependencyObject source, DependencyPro public void Pause() => Source?.Pause(); - public async Task PlayAsync(double fromProgress, double toProgress, bool looped) => Source?.Play(fromProgress, toProgress, looped); + public Task PlayAsync(double fromProgress, double toProgress, bool looped) + { + Source?.Play(fromProgress, toProgress, looped); + return Task.CompletedTask; + } public void Resume() => Source?.Resume(); diff --git a/src/Uno.UI/UI/Xaml/Controls/Image/Image.Android.cs b/src/Uno.UI/UI/Xaml/Controls/Image/Image.Android.cs index 03f79a816ab1..902cd6384933 100644 --- a/src/Uno.UI/UI/Xaml/Controls/Image/Image.Android.cs +++ b/src/Uno.UI/UI/Xaml/Controls/Image/Image.Android.cs @@ -183,7 +183,7 @@ private void TryOpenImage(bool forceReload = false) } else if (imageSource.ResourceId.HasValue) { - var dummy = SetSourceResource(imageSource); + SetSourceResource(imageSource); } else if (imageSource.FilePath.HasValue() || imageSource.WebUri != null || imageSource.Stream != null) { @@ -280,7 +280,11 @@ private async Task SetSourceUriOrStream(ImageSource newImageSource) //If a remote image is fetched a second time, it may be set synchronously (eg if the image is cached) within a layout pass (ie from OnLayoutPartial). In this case, we must dispatch RequestLayout for the image control to be measured correctly. if (MustDispatchSetSource()) { - Dispatch(async ct => RequestLayout()); + Dispatch(ct => + { + RequestLayout(); + return Task.CompletedTask; + }); } } catch (Exception ex) @@ -291,7 +295,7 @@ private async Task SetSourceUriOrStream(ImageSource newImageSource) } } - private async Task SetSourceResource(ImageSource newImageSource) + private void SetSourceResource(ImageSource newImageSource) { // The Jupiter behavior is to reset the visual right away, displaying nothing // then show the new image. We're rescheduling the work below, so there is going @@ -305,10 +309,11 @@ private async Task SetSourceResource(ImageSource newImageSource) int imageWidth = o.OutWidth; int imageHeight = o.OutHeight; - Func setResource = async (ct) => + Func setResource = (ct) => { _native.SetImageResource(newImageSource.ResourceId.Value); OnImageOpened(newImageSource); + return Task.CompletedTask; }; if ( @@ -329,14 +334,18 @@ private void SetSourceDrawable(ImageSource newImageSource) { if (MustDispatchSetSource()) { - Dispatch(ct => SetSourceDrawableAsync(ct, newImageSource)); + Dispatch(ct => + { + SetSourceDrawable(ct, newImageSource); + return Task.CompletedTask; + }); } else { - var unused = SetSourceDrawableAsync(CancellationToken.None, newImageSource); + SetSourceDrawable(CancellationToken.None, newImageSource); } } - private async Task SetSourceDrawableAsync(CancellationToken ct, ImageSource newImageSource) + private void SetSourceDrawable(CancellationToken ct, ImageSource newImageSource) { _native.SetImageDrawable(newImageSource.BitmapDrawable); OnImageOpened(newImageSource); @@ -346,15 +355,19 @@ private void SetSourceBitmap((ImageSource src, Bitmap data) image) { if (MustDispatchSetSource()) { - Dispatch(ct => SetSourceBitmapAsync(ct, image)); + Dispatch(ct => + { + SetSourceBitmapAsync(ct, image); + return Task.CompletedTask; + }); } else { - var unused = SetSourceBitmapAsync(CancellationToken.None, image); + SetSourceBitmapAsync(CancellationToken.None, image); } } - private async Task SetSourceBitmapAsync(CancellationToken ct, (ImageSource src, Bitmap data) image) + private void SetSourceBitmapAsync(CancellationToken ct, (ImageSource src, Bitmap data) image) { _native.SetImageBitmap(image.data); OnImageOpened(image.src); diff --git a/src/Uno.UI/UI/Xaml/Controls/PersonPicture/PersonPicture.cs b/src/Uno.UI/UI/Xaml/Controls/PersonPicture/PersonPicture.cs index 030a4957d7ff..31221981577a 100644 --- a/src/Uno.UI/UI/Xaml/Controls/PersonPicture/PersonPicture.cs +++ b/src/Uno.UI/UI/Xaml/Controls/PersonPicture/PersonPicture.cs @@ -77,7 +77,7 @@ public PersonPicture() SizeChanged += OnSizeChanged; } - async Task LoadImageAsync(IRandomAccessStreamReference thumbStreamReference) + Task LoadImageAsync(IRandomAccessStreamReference thumbStreamReference) { m_profilePictureReadAsync = null; diff --git a/src/Uno.UI/UI/Xaml/Controls/WebView/WebView.skia.cs b/src/Uno.UI/UI/Xaml/Controls/WebView/WebView.skia.cs index 12565bc01ef7..24d021f33a10 100644 --- a/src/Uno.UI/UI/Xaml/Controls/WebView/WebView.skia.cs +++ b/src/Uno.UI/UI/Xaml/Controls/WebView/WebView.skia.cs @@ -20,12 +20,12 @@ public partial class WebView { //This should be IAsyncOperation instead of Task but we use an extension method to enable the same signature in Win. //IAsyncOperation is not available in Xamarin. - public async Task InvokeScriptAsync(CancellationToken ct, string script, string[] arguments) + public Task InvokeScriptAsync(CancellationToken ct, string script, string[] arguments) { throw new NotSupportedException(); } - public async Task InvokeScriptAsync(string script, string[] arguments) + public Task InvokeScriptAsync(string script, string[] arguments) { throw new NotSupportedException(); } diff --git a/src/Uno.UI/UI/Xaml/DragDrop/DropUITarget.cs b/src/Uno.UI/UI/Xaml/DragDrop/DropUITarget.cs index a5247bee24cb..059965121f5a 100644 --- a/src/Uno.UI/UI/Xaml/DragDrop/DropUITarget.cs +++ b/src/Uno.UI/UI/Xaml/DragDrop/DropUITarget.cs @@ -81,11 +81,12 @@ private IAsyncOperation EnterOrOverAsync(CoreDragInfo drag /// public IAsyncAction LeaveAsync(CoreDragInfo dragInfo) - => AsyncAction.FromTask(async ct => + => AsyncAction.FromTask(ct => { var leaveTasks = _pendingDropTargets.ToArray().Select(RaiseLeave); _pendingDropTargets.Clear(); Task.WhenAll(leaveTasks); + return Task.CompletedTask; async Task RaiseLeave(KeyValuePair target) { diff --git a/src/Uno.UI/UI/Xaml/Media/ImageSource.iOS.cs b/src/Uno.UI/UI/Xaml/Media/ImageSource.iOS.cs index 87a484e6f41f..401fb59c6fdb 100644 --- a/src/Uno.UI/UI/Xaml/Media/ImageSource.iOS.cs +++ b/src/Uno.UI/UI/Xaml/Media/ImageSource.iOS.cs @@ -197,7 +197,7 @@ internal async Task Open(CancellationToken ct) { await CoreDispatcher.Main.RunAsync( CoreDispatcherPriority.Normal, - async () => + () => { _imageData = OpenBundle(); } @@ -229,7 +229,7 @@ await CoreDispatcher.Main.RunAsync( { await CoreDispatcher.Main.RunAsync( CoreDispatcherPriority.Normal, - async () => + () => { if (SupportsFromBundle) { diff --git a/src/Uno.UI/UI/Xaml/Media/Imaging/BitmapSource.cs b/src/Uno.UI/UI/Xaml/Media/Imaging/BitmapSource.cs index 28ac72f9b3c5..5fa774222606 100644 --- a/src/Uno.UI/UI/Xaml/Media/Imaging/BitmapSource.cs +++ b/src/Uno.UI/UI/Xaml/Media/Imaging/BitmapSource.cs @@ -108,7 +108,11 @@ private void SetSourceCore(IRandomAccessStream streamSource) #endif } - private async Task ForceLoad(CancellationToken ct) + private +#if __NETSTD__ + async +#endif + Task ForceLoad(CancellationToken ct) { #if __NETSTD__ var tcs = new TaskCompletionSource(); @@ -123,6 +127,8 @@ void OnChanged(ImageData data) { tcs.TrySetResult(null); } +#else + return Task.CompletedTask; #endif } diff --git a/src/Uno.UI/UI/Xaml/Media/Imaging/RenderTargetBitmap.cs b/src/Uno.UI/UI/Xaml/Media/Imaging/RenderTargetBitmap.cs index d3de5eb51a86..7fe8983db8b8 100644 --- a/src/Uno.UI/UI/Xaml/Media/Imaging/RenderTargetBitmap.cs +++ b/src/Uno.UI/UI/Xaml/Media/Imaging/RenderTargetBitmap.cs @@ -83,7 +83,7 @@ public int PixelHeight [global::Uno.NotImplemented()] #endif public IAsyncAction RenderAsync(UIElement? element, int scaledWidth, int scaledHeight) - => AsyncAction.FromTask(async ct => + => AsyncAction.FromTask(ct => { try { @@ -98,13 +98,15 @@ public IAsyncAction RenderAsync(UIElement? element, int scaledWidth, int scaledH { this.Log().Error("Failed to render element to bitmap.", error); } + + return Task.CompletedTask; }); #if NOT_IMPLEMENTED [global::Uno.NotImplemented()] #endif public IAsyncAction RenderAsync(UIElement? element) - => AsyncAction.FromTask(async ct => + => AsyncAction.FromTask(ct => { try { @@ -120,19 +122,21 @@ public IAsyncAction RenderAsync(UIElement? element) { this.Log().Error("Failed to render element to bitmap.", error); } + + return Task.CompletedTask; }); #if NOT_IMPLEMENTED [global::Uno.NotImplemented()] #endif public IAsyncOperation GetPixelsAsync() - => AsyncOperation.FromTask(async (op, ct) => + => AsyncOperation.FromTask((op, ct) => { if (_buffer is null) { - return new Buffer(Array.Empty()); + return Task.FromResult(new Buffer(Array.Empty())); } - return new Buffer(_buffer.AsMemory().Slice(0,_bufferSize)); + return Task.FromResult(new Buffer(_buffer.AsMemory().Slice(0,_bufferSize))); }); #if NOT_IMPLEMENTED diff --git a/src/Uno.UI/UI/Xaml/Media/Imaging/SvgImageSource.cs b/src/Uno.UI/UI/Xaml/Media/Imaging/SvgImageSource.cs index 2b4ad34bd1d7..875184bf2820 100644 --- a/src/Uno.UI/UI/Xaml/Media/Imaging/SvgImageSource.cs +++ b/src/Uno.UI/UI/Xaml/Media/Imaging/SvgImageSource.cs @@ -56,7 +56,10 @@ public SvgImageSource(Uri uriSource) public IAsyncOperation SetSourceAsync(IRandomAccessStream streamSource) { - async Task SetSourceAsync( +#if __NETSTD__ + async +#endif + Task SetSourceAsync( CancellationToken ct, AsyncOperation _) { @@ -85,7 +88,7 @@ void OnChanged(ImageData data) } #else Stream = streamSource.CloneStream().AsStream(); - return SvgImageSourceLoadStatus.Success; + return Task.FromResult(SvgImageSourceLoadStatus.Success); #endif } diff --git a/src/Uno.UWP/ApplicationModel/Calls/PhoneCallHistoryEntryReader.Android.cs b/src/Uno.UWP/ApplicationModel/Calls/PhoneCallHistoryEntryReader.Android.cs index 2fea089bbdc8..cc34de574448 100644 --- a/src/Uno.UWP/ApplicationModel/Calls/PhoneCallHistoryEntryReader.Android.cs +++ b/src/Uno.UWP/ApplicationModel/Calls/PhoneCallHistoryEntryReader.Android.cs @@ -32,13 +32,13 @@ public partial class PhoneCallHistoryEntryReader /// public IAsyncOperation> ReadBatchAsync() => ReadBatchAsyncTask().AsAsyncOperation(); - private async Task> ReadBatchAsyncTask() + private Task> ReadBatchAsyncTask() { var entriesList = new List(); if (_cursor is null) { - return entriesList; + return Task.FromResult>(entriesList); } try @@ -95,7 +95,7 @@ private async Task> ReadBatchAsyncTask() CleanupCursor(); } - return entriesList; + return Task.FromResult>(entriesList); } private void InitializeCursor() diff --git a/src/Uno.UWP/Devices/Geolocation/Geolocator.iOSmacOS.cs b/src/Uno.UWP/Devices/Geolocation/Geolocator.iOSmacOS.cs index 627612724e2f..81850049bde9 100644 --- a/src/Uno.UWP/Devices/Geolocation/Geolocator.iOSmacOS.cs +++ b/src/Uno.UWP/Devices/Geolocation/Geolocator.iOSmacOS.cs @@ -180,9 +180,9 @@ private static async Task RequestAccessInternalAsync() } } - public static async Task> GetGeopositionHistoryAsync(DateTime startTime) { return new List(); } + public static Task> GetGeopositionHistoryAsync(DateTime startTime) { return Task.FromResult>(new List()); } - public static async Task> GetGeopositionHistoryAsync(DateTime startTime, TimeSpan duration) { return new List(); } + public static Task> GetGeopositionHistoryAsync(DateTime startTime, TimeSpan duration) { return Task.FromResult>(new List()); } private static GeolocationAccessStatus TranslateStatus(CLAuthorizationStatus status) { diff --git a/src/Uno.UWP/Devices/Midi/MidiInPort.iOSmacOS.cs b/src/Uno.UWP/Devices/Midi/MidiInPort.iOSmacOS.cs index 9e04d3edc391..c2aa4511897c 100644 --- a/src/Uno.UWP/Devices/Midi/MidiInPort.iOSmacOS.cs +++ b/src/Uno.UWP/Devices/Midi/MidiInPort.iOSmacOS.cs @@ -49,7 +49,7 @@ partial void DisposeNative() _endpoint = null; } - private static async Task FromIdInternalAsync(DeviceIdentifier identifier) + private static Task FromIdInternalAsync(DeviceIdentifier identifier) { var provider = new MidiInDeviceClassProvider(); var nativeDeviceInfo = provider.GetNativeEndpoint(identifier.Id); @@ -59,7 +59,7 @@ private static async Task FromIdInternalAsync(DeviceIdentifier ident "Given MIDI out device does not exist or is no longer connected"); } - return new MidiInPort(identifier.ToString(), nativeDeviceInfo); + return Task.FromResult(new MidiInPort(identifier.ToString(), nativeDeviceInfo)); } diff --git a/src/Uno.UWP/Devices/Midi/MidiOutPort.iOSmacOS.cs b/src/Uno.UWP/Devices/Midi/MidiOutPort.iOSmacOS.cs index aed43772cb77..0d8bc02f4dbd 100644 --- a/src/Uno.UWP/Devices/Midi/MidiOutPort.iOSmacOS.cs +++ b/src/Uno.UWP/Devices/Midi/MidiOutPort.iOSmacOS.cs @@ -41,7 +41,7 @@ public void Dispose() _endpoint = null; } - private static async Task FromIdInternalAsync(DeviceIdentifier identifier) + private static Task FromIdInternalAsync(DeviceIdentifier identifier) { var provider = new MidiOutDeviceClassProvider(); var nativeDeviceInfo = provider.GetNativeEndpoint(identifier.Id); @@ -53,7 +53,7 @@ private static async Task FromIdInternalAsync(DeviceIdentifier ide var port = new MidiOutPort(identifier.ToString(), nativeDeviceInfo); port.Open(); - return port; + return Task.FromResult(port); } private void SendBufferInternal(IBuffer midiData, TimeSpan timestamp) diff --git a/src/Uno.UWP/Devices/Midi/MidiOutPort.wasm.cs b/src/Uno.UWP/Devices/Midi/MidiOutPort.wasm.cs index 2e468ca49045..7a9523d1f85a 100644 --- a/src/Uno.UWP/Devices/Midi/MidiOutPort.wasm.cs +++ b/src/Uno.UWP/Devices/Midi/MidiOutPort.wasm.cs @@ -41,9 +41,9 @@ public void SendBufferInternal(IBuffer midiBuffer, TimeSpan timestamp) InvokeJS(command); } - private static async Task FromIdInternalAsync(DeviceIdentifier identifier) + private static Task FromIdInternalAsync(DeviceIdentifier identifier) { - return new MidiOutPort(identifier.ToString(), identifier.Id); + return Task.FromResult(new MidiOutPort(identifier.ToString(), identifier.Id)); } } } diff --git a/src/Uno.UWP/Devices/Radios/Radio.Android.cs b/src/Uno.UWP/Devices/Radios/Radio.Android.cs index 5bf0b6f1f650..353b0c05d26d 100644 --- a/src/Uno.UWP/Devices/Radios/Radio.Android.cs +++ b/src/Uno.UWP/Devices/Radios/Radio.Android.cs @@ -284,7 +284,7 @@ private Radio() } - private async static Task> GetRadiosAsyncTask() + private static Task> GetRadiosAsyncTask() { var radios = new List(); @@ -306,7 +306,7 @@ private async static Task> GetRadiosAsyncTask() radios.Add(radio); // yield oRadio; } - return radios; + return Task.FromResult>(radios); } /// diff --git a/src/Uno.UWP/Graphics/Imaging/BitmapEncoder.android.cs b/src/Uno.UWP/Graphics/Imaging/BitmapEncoder.android.cs index 709a56a6fc4a..7feeea49c8fb 100644 --- a/src/Uno.UWP/Graphics/Imaging/BitmapEncoder.android.cs +++ b/src/Uno.UWP/Graphics/Imaging/BitmapEncoder.android.cs @@ -4,6 +4,7 @@ using System.IO; using Android.Graphics; using Java.Nio; +using System.Threading.Tasks; namespace Windows.Graphics.Imaging { @@ -28,21 +29,22 @@ private BitmapEncoder(Bitmap.CompressFormat imageFormat } public static global::Windows.Foundation.IAsyncOperation CreateAsync(global::System.Guid encoderId, global::Windows.Storage.Streams.IRandomAccessStream stream) => - AsyncOperation.FromTask(async (ct, _) => + AsyncOperation.FromTask((ct, _) => { if (!_encoderMap.TryGetValue(encoderId, out var imageFormat)) { throw new NotImplementedException($"Encoder {encoderId} in not implemented.", new ArgumentException(nameof(encoderId))); } - return new BitmapEncoder(imageFormat, stream); + return Task.FromResult(new BitmapEncoder(imageFormat, stream)); }); public IAsyncAction FlushAsync() => - AsyncAction.FromTask(async ct => + AsyncAction.FromTask(ct => { _softwareBitmap?.Bitmap? .Compress(_imageFormat, 100, _stream.AsStream()); + return Task.CompletedTask; }); public void SetSoftwareBitmap(Windows.Graphics.Imaging.SoftwareBitmap bitmap) diff --git a/src/Uno.UWP/Graphics/Imaging/BitmapEncoder.ios.cs b/src/Uno.UWP/Graphics/Imaging/BitmapEncoder.ios.cs index 634bc293d971..96f466225b3a 100644 --- a/src/Uno.UWP/Graphics/Imaging/BitmapEncoder.ios.cs +++ b/src/Uno.UWP/Graphics/Imaging/BitmapEncoder.ios.cs @@ -5,6 +5,7 @@ using Windows.Foundation; using System.Runtime.InteropServices.WindowsRuntime; using System.Runtime.InteropServices; +using System.Threading.Tasks; namespace Windows.Graphics.Imaging { @@ -28,13 +29,13 @@ private BitmapEncoder(Func encoder } public static global::Windows.Foundation.IAsyncOperation CreateAsync(global::System.Guid encoderId, global::Windows.Storage.Streams.IRandomAccessStream stream) - => AsyncOperation.FromTask(async (ct, _) => + => AsyncOperation.FromTask((ct, _) => { if (!_encoderMap.TryGetValue(encoderId, out var encoder)) { throw new NotImplementedException($"Encoder {encoderId} in not implemented.", new ArgumentException(nameof(encoderId))); } - return new BitmapEncoder(encoder, stream); + return Task.FromResult(new BitmapEncoder(encoder, stream)); }); public global::Windows.Foundation.IAsyncAction FlushAsync() diff --git a/src/Uno.UWP/Graphics/Imaging/BitmapEncoder.skia.cs b/src/Uno.UWP/Graphics/Imaging/BitmapEncoder.skia.cs index 0f6127e67ffd..e979ebe72939 100644 --- a/src/Uno.UWP/Graphics/Imaging/BitmapEncoder.skia.cs +++ b/src/Uno.UWP/Graphics/Imaging/BitmapEncoder.skia.cs @@ -4,6 +4,7 @@ using Windows.Foundation; using System.IO; using System.Runtime.InteropServices; +using System.Threading.Tasks; namespace Windows.Graphics.Imaging { @@ -32,13 +33,13 @@ private BitmapEncoder(SKEncodedImageFormat imageFormat public static IAsyncOperation CreateAsync(Guid encoderId , Storage.Streams.IRandomAccessStream stream) => - AsyncOperation.FromTask(async (ct, _) => + AsyncOperation.FromTask((ct, _) => { if(!_encoderMap.TryGetValue(encoderId,out var imageFormat)) { throw new NotImplementedException($"Encoder {encoderId} in not implemented.", new ArgumentException(nameof(encoderId))); } - return new BitmapEncoder(imageFormat, stream); + return Task.FromResult(new BitmapEncoder(imageFormat, stream)); }); public void SetSoftwareBitmap(SoftwareBitmap bitmap) @@ -48,10 +49,11 @@ public void SetSoftwareBitmap(SoftwareBitmap bitmap) } public IAsyncAction FlushAsync() => - AsyncAction.FromTask(async ct => + AsyncAction.FromTask(ct => { using var data = _softwareBitmap?.Bitmap?.Encode(_imageFormat, 100); data?.SaveTo(_stream.AsStream()); + return Task.CompletedTask; }); public void SetPixelData(global::Windows.Graphics.Imaging.BitmapPixelFormat pixelFormat, global::Windows.Graphics.Imaging.BitmapAlphaMode alphaMode, uint width, uint height, double dpiX, double dpiY, byte[] pixels) diff --git a/src/Uno.UWP/Media/Capture/CameraCaptureUI.iOS.cs b/src/Uno.UWP/Media/Capture/CameraCaptureUI.iOS.cs index 2a15d6dda6c7..be9217f4b88a 100644 --- a/src/Uno.UWP/Media/Capture/CameraCaptureUI.iOS.cs +++ b/src/Uno.UWP/Media/Capture/CameraCaptureUI.iOS.cs @@ -72,7 +72,7 @@ private async Task CaptureFile(CancellationToken ct, CameraCaptureU var image = result.ValueForKey(new NSString("UIImagePickerControllerOriginalImage")) as UIImage; var metadata = result.ValueForKey(new NSString("UIImagePickerControllerOriginalImage")) as UIImage; - var correctedImage = await FixOrientation(ct, image); + var correctedImage = FixOrientation(ct, image); (Stream data, string extension) GetImageStream() { @@ -157,7 +157,7 @@ public override UIInterfaceOrientationMask GetSupportedInterfaceOrientations() /// Cancellation token /// UI Image /// UI image - private async Task FixOrientation(CancellationToken ct, UIImage image) + private UIImage FixOrientation(CancellationToken ct, UIImage image) { if (image.Orientation == UIImageOrientation.Up) { diff --git a/src/Uno.UWP/Media/Capture/CameraCaptureUI.other.cs b/src/Uno.UWP/Media/Capture/CameraCaptureUI.other.cs index e36456af2fcb..9f2018b55e3d 100644 --- a/src/Uno.UWP/Media/Capture/CameraCaptureUI.other.cs +++ b/src/Uno.UWP/Media/Capture/CameraCaptureUI.other.cs @@ -8,7 +8,7 @@ namespace Windows.Media.Capture { public partial class CameraCaptureUI { - private async Task CaptureFile(CancellationToken arg, CameraCaptureUIMode mode) + private Task CaptureFile(CancellationToken arg, CameraCaptureUIMode mode) { return null; diff --git a/src/Uno.UWP/Media/SpeechRecognition/SpeechRecognizer.cs b/src/Uno.UWP/Media/SpeechRecognition/SpeechRecognizer.cs index 387456d250e1..f8280d1b7914 100644 --- a/src/Uno.UWP/Media/SpeechRecognition/SpeechRecognizer.cs +++ b/src/Uno.UWP/Media/SpeechRecognition/SpeechRecognizer.cs @@ -1,6 +1,7 @@ #if __ANDROID__ || __IOS__ || __WASM__ using System; using System.Globalization; +using System.Threading.Tasks; using Windows.Foundation; using Windows.Globalization; @@ -33,12 +34,12 @@ public SpeechRecognizer(Language language) public IAsyncOperation CompileConstraintsAsync() { - return AsyncOperation.FromTask(async ct => + return AsyncOperation.FromTask(ct => { - return new SpeechRecognitionCompilationResult() + return Task.FromResult(new SpeechRecognitionCompilationResult() { Status = SpeechRecognitionResultStatus.Success - }; + }); }); } diff --git a/src/Uno.UWP/Phone/Devices/Notification/VibrationDevice.iOS.cs b/src/Uno.UWP/Phone/Devices/Notification/VibrationDevice.iOS.cs index 0459f357ed6e..fa04a9c3ad1a 100644 --- a/src/Uno.UWP/Phone/Devices/Notification/VibrationDevice.iOS.cs +++ b/src/Uno.UWP/Phone/Devices/Notification/VibrationDevice.iOS.cs @@ -26,7 +26,7 @@ public static VibrationDevice GetDefault() => /// we can produce only very short vibration and one second vibration /// /// - public async void Vibrate(TimeSpan duration) + public void Vibrate(TimeSpan duration) { if (duration.TotalMilliseconds < 200) { diff --git a/src/Uno.UWP/Security/Authentication/Web/WebAuthenticationBrokerProvider.skia.cs b/src/Uno.UWP/Security/Authentication/Web/WebAuthenticationBrokerProvider.skia.cs index 380d9a436947..5926c595dd5f 100644 --- a/src/Uno.UWP/Security/Authentication/Web/WebAuthenticationBrokerProvider.skia.cs +++ b/src/Uno.UWP/Security/Authentication/Web/WebAuthenticationBrokerProvider.skia.cs @@ -14,7 +14,7 @@ protected virtual IEnumerable GetApplicationCustomSchemes() throw new NotImplementedException(); } - protected virtual async Task AuthenticateAsyncCore( + protected virtual Task AuthenticateAsyncCore( WebAuthenticationOptions options, Uri requestUri, Uri callbackUri, diff --git a/src/Uno.UWP/Services/Store/StoreContext.Android.cs b/src/Uno.UWP/Services/Store/StoreContext.Android.cs index 5e12bc551c8c..b33b0d85c8c3 100644 --- a/src/Uno.UWP/Services/Store/StoreContext.Android.cs +++ b/src/Uno.UWP/Services/Store/StoreContext.Android.cs @@ -13,18 +13,18 @@ public sealed partial class StoreContext { public IAsyncOperation GetStoreProductForCurrentAppAsync() { - return AsyncOperation.FromTask(async ct => + return AsyncOperation.FromTask(ct => { var storeId = ContextHelper.Current.PackageName; - return new StoreProductResult + return Task.FromResult(new StoreProductResult { Product = new StoreProduct { StoreId = storeId, LinkUri = new Uri($"https://play.google.com/store/apps/details?id={storeId}") } - }; + }); }); } } diff --git a/src/Uno.UWP/Storage/NameCollisionOption.cs b/src/Uno.UWP/Storage/NameCollisionOption.cs index 1957517809e5..e37edb80cddb 100644 --- a/src/Uno.UWP/Storage/NameCollisionOption.cs +++ b/src/Uno.UWP/Storage/NameCollisionOption.cs @@ -1,7 +1,4 @@ -#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously - - -namespace Windows.Storage +namespace Windows.Storage { public enum NameCollisionOption { diff --git a/src/Uno.UWP/Storage/StorageFile.Local.cs b/src/Uno.UWP/Storage/StorageFile.Local.cs index eec9eec31b76..125d3e3ab591 100644 --- a/src/Uno.UWP/Storage/StorageFile.Local.cs +++ b/src/Uno.UWP/Storage/StorageFile.Local.cs @@ -27,26 +27,29 @@ public Local(string path) protected override bool IsEqual(ImplementationBase impl) => impl is Local other && Path.Equals(other.Path); - public override async Task GetParentAsync(CancellationToken ct) + public override Task GetParentAsync(CancellationToken ct) { var directoryPath = IOPath.GetDirectoryName(Path); - return directoryPath != null ? new StorageFolder(directoryPath) : null; + return Task.FromResult(directoryPath != null ? new StorageFolder(directoryPath) : null); } - public override async Task GetBasicPropertiesAsync(CancellationToken ct) - => BasicProperties.FromFilePath(Owner.Path); + public override Task GetBasicPropertiesAsync(CancellationToken ct) + => Task.FromResult(BasicProperties.FromFilePath(Owner.Path)); - public override async Task OpenAsync(CancellationToken ct, FileAccessMode accessMode, StorageOpenOptions options) - => new RandomAccessStreamWithContentType(FileRandomAccessStream.CreateLocal(Path, ToFileAccess(accessMode), ToFileShare(options)), ContentType); + public override Task OpenAsync(CancellationToken ct, FileAccessMode accessMode, StorageOpenOptions options) + => Task.FromResult(new RandomAccessStreamWithContentType(FileRandomAccessStream.CreateLocal(Path, ToFileAccess(accessMode), ToFileShare(options)), ContentType)); - public override async Task OpenStreamAsync(CancellationToken ct, FileAccessMode accessMode, StorageOpenOptions options) - => File.Open(Path, FileMode.Open, ToFileAccess(accessMode), ToFileShare(options)); + public override Task OpenStreamAsync(CancellationToken ct, FileAccessMode accessMode, StorageOpenOptions options) + => Task.FromResult(File.Open(Path, FileMode.Open, ToFileAccess(accessMode), ToFileShare(options))); - public override async Task OpenTransactedWriteAsync(CancellationToken ct, StorageOpenOptions option) - => new StorageStreamTransaction(Owner, ToFileShare(option)); + public override Task OpenTransactedWriteAsync(CancellationToken ct, StorageOpenOptions option) + => Task.FromResult(new StorageStreamTransaction(Owner, ToFileShare(option))); - public override async Task DeleteAsync(CancellationToken ct, StorageDeleteOption options) - => File.Delete(Path); + public override Task DeleteAsync(CancellationToken ct, StorageDeleteOption options) + { + File.Delete(Path); + return Task.CompletedTask; + } public override async Task CopyAndReplaceAsync(CancellationToken ct, IStorageFile target) { diff --git a/src/Uno.UWP/Storage/StorageFile.android.cs b/src/Uno.UWP/Storage/StorageFile.android.cs index 34dcb30c5115..397e12670289 100644 --- a/src/Uno.UWP/Storage/StorageFile.android.cs +++ b/src/Uno.UWP/Storage/StorageFile.android.cs @@ -1,5 +1,3 @@ -#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously - using System; using System.Globalization; using System.IO; diff --git a/src/Uno.UWP/Storage/StorageFile.cs b/src/Uno.UWP/Storage/StorageFile.cs index 8b41888aa711..c6ae49b759f4 100644 --- a/src/Uno.UWP/Storage/StorageFile.cs +++ b/src/Uno.UWP/Storage/StorageFile.cs @@ -1,5 +1,4 @@ #nullable enable -#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously using System; using System.Globalization; @@ -19,7 +18,7 @@ namespace Windows.Storage public sealed partial class StorageFile : IStorageFile, IStorageFile2, IStorageItem, IStorageItem2 { public static IAsyncOperation GetFileFromPathAsync(string path) - => AsyncOperation.FromTask(async ct => new StorageFile(new Local(path))); + => AsyncOperation.FromTask(ct => Task.FromResult(new StorageFile(new Local(path)))); internal static StorageFile GetFileFromPath(string path) => new StorageFile(new Local(path)); diff --git a/src/Uno.UWP/Storage/StorageFile.iOS.cs b/src/Uno.UWP/Storage/StorageFile.iOS.cs index bd5e628bcc46..cff238477d0d 100644 --- a/src/Uno.UWP/Storage/StorageFile.iOS.cs +++ b/src/Uno.UWP/Storage/StorageFile.iOS.cs @@ -76,14 +76,14 @@ private DateTimeOffset GetDateCreated() public override Task GetParentAsync(CancellationToken ct) => Task.FromResult(_parent); - public override async Task OpenAsync(CancellationToken ct, FileAccessMode accessMode, StorageOpenOptions options) - => new RandomAccessStreamWithContentType(FileRandomAccessStream.CreateSecurityScoped(_nsUrl, ToFileAccess(accessMode), ToFileShare(options)), ContentType); + public override Task OpenAsync(CancellationToken ct, FileAccessMode accessMode, StorageOpenOptions options) + => Task.FromResult(new RandomAccessStreamWithContentType(FileRandomAccessStream.CreateSecurityScoped(_nsUrl, ToFileAccess(accessMode), ToFileShare(options)), ContentType)); - public override async Task OpenStreamAsync(CancellationToken ct, FileAccessMode accessMode, StorageOpenOptions options) + public override Task OpenStreamAsync(CancellationToken ct, FileAccessMode accessMode, StorageOpenOptions options) { Func streamBuilder = () => File.Open(Path, FileMode.Open, ToFileAccess(accessMode), ToFileShare(options)); var streamWrapper = new SecurityScopeStreamWrapper(_nsUrl, streamBuilder); - return streamWrapper; + return Task.FromResult(streamWrapper); } public override Task OpenTransactedWriteAsync(CancellationToken ct, StorageOpenOptions option) => throw new NotImplementedException(); diff --git a/src/Uno.UWP/Storage/StorageFile.wasm.cs b/src/Uno.UWP/Storage/StorageFile.wasm.cs index 953dcce18b8c..dfa1a17ffce7 100644 --- a/src/Uno.UWP/Storage/StorageFile.wasm.cs +++ b/src/Uno.UWP/Storage/StorageFile.wasm.cs @@ -1,5 +1,3 @@ -#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously - using System; using System.Globalization; using System.IO; diff --git a/src/Uno.UWP/Storage/StorageFolder.Local.cs b/src/Uno.UWP/Storage/StorageFolder.Local.cs index 2bd7913acda3..70264c34971d 100644 --- a/src/Uno.UWP/Storage/StorageFolder.Local.cs +++ b/src/Uno.UWP/Storage/StorageFolder.Local.cs @@ -1,5 +1,4 @@ #nullable enable -#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously using System; using System.Collections.Generic; diff --git a/src/Uno.UWP/Storage/StorageFolder.cs b/src/Uno.UWP/Storage/StorageFolder.cs index dbfdf4e6dbaf..4713ce49c5aa 100644 --- a/src/Uno.UWP/Storage/StorageFolder.cs +++ b/src/Uno.UWP/Storage/StorageFolder.cs @@ -1,5 +1,3 @@ -#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously - using System; using System.Collections.Generic; using System.IO; @@ -36,7 +34,7 @@ private StorageFolder(ImplementationBase implementation) internal ImplementationBase Implementation { get; } #if !__WASM__ - private static async Task TryInitializeStorage() { } + private static Task TryInitializeStorage() => Task.CompletedTask; #endif public bool IsOfType(StorageItemTypes type) => diff --git a/src/Uno.UWP/Storage/StorageStreamTransaction.cs b/src/Uno.UWP/Storage/StorageStreamTransaction.cs index 9845703bcbec..489f0b6e806f 100644 --- a/src/Uno.UWP/Storage/StorageStreamTransaction.cs +++ b/src/Uno.UWP/Storage/StorageStreamTransaction.cs @@ -1,5 +1,4 @@ #nullable enable -#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously using System; using System.Collections.Generic; @@ -38,10 +37,11 @@ internal Stream AsAutoCommitStream() public IRandomAccessStream Stream { get; private set; } = null!; - public IAsyncAction CommitAsync() => AsyncAction.FromTask(async ct => + public IAsyncAction CommitAsync() => AsyncAction.FromTask(ct => { ct.ThrowIfCancellationRequested(); Commit(); + return Task.CompletedTask; }); private void Commit() diff --git a/src/Uno.UWP/Storage/Streams/Internal/NativeReadStream.wasm.cs b/src/Uno.UWP/Storage/Streams/Internal/NativeReadStream.wasm.cs index a0c9089f70dc..587066de6996 100644 --- a/src/Uno.UWP/Storage/Streams/Internal/NativeReadStream.wasm.cs +++ b/src/Uno.UWP/Storage/Streams/Internal/NativeReadStream.wasm.cs @@ -69,9 +69,9 @@ public override long Seek(long offset, SeekOrigin origin) public override void Write(byte[] buffer, int offset, int count) => throw new NotSupportedException("This stream is read-only"); - public override async Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) => throw new NotSupportedException("This stream is read-only"); + public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) => throw new NotSupportedException("This stream is read-only"); - protected override async void Dispose(bool disposing) + protected override void Dispose(bool disposing) { _readStreamAdapter.Dispose(); } diff --git a/src/Uno.UWP/Storage/Streams/Internal/NativeReadStreamAdapter.wasm.cs b/src/Uno.UWP/Storage/Streams/Internal/NativeReadStreamAdapter.wasm.cs index 18effba04625..aae3d6531a93 100644 --- a/src/Uno.UWP/Storage/Streams/Internal/NativeReadStreamAdapter.wasm.cs +++ b/src/Uno.UWP/Storage/Streams/Internal/NativeReadStreamAdapter.wasm.cs @@ -68,7 +68,7 @@ public override long Seek(long offset, SeekOrigin origin) => public override void Write(byte[] buffer, int offset, int count) => throw new NotSupportedException("This stream is read-only"); - public override async Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) => throw new NotSupportedException("This stream is read-only."); + public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) => throw new NotSupportedException("This stream is read-only."); public override async Task ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) { @@ -88,7 +88,7 @@ public override async Task ReadAsync(byte[] buffer, int offset, int count, } } - protected override async void Dispose(bool disposing) + protected override void Dispose(bool disposing) { WebAssemblyRuntime.InvokeJS($"{JsType}.close('{_streamId}')"); } diff --git a/src/Uno.UWP/Storage/Streams/RandomAccessStreamReference.cs b/src/Uno.UWP/Storage/Streams/RandomAccessStreamReference.cs index b2c6557a302a..7c8fb4ef8eaa 100644 --- a/src/Uno.UWP/Storage/Streams/RandomAccessStreamReference.cs +++ b/src/Uno.UWP/Storage/Streams/RandomAccessStreamReference.cs @@ -24,9 +24,9 @@ public static RandomAccessStreamReference CreateFromUri(Uri uri) }); public static RandomAccessStreamReference CreateFromStream(IRandomAccessStream stream) - => new RandomAccessStreamReference(async ct => + => new RandomAccessStreamReference(ct => { - return stream.TrySetContentType(); + return Task.FromResult(stream.TrySetContentType()); }); private readonly Func> _open; diff --git a/src/Uno.UWP/System.Runtime/WindowsRuntimeSystemExtensions.cs b/src/Uno.UWP/System.Runtime/WindowsRuntimeSystemExtensions.cs index a7c3f35c3906..2df79cdcd1d6 100644 --- a/src/Uno.UWP/System.Runtime/WindowsRuntimeSystemExtensions.cs +++ b/src/Uno.UWP/System.Runtime/WindowsRuntimeSystemExtensions.cs @@ -78,7 +78,7 @@ public static Task AsTask(this IAsyncActionWithProgress so public static Task AsTask(this IAsyncActionWithProgress source, CancellationToken cancellationToken) => source.AsTaskCore(cancellationToken); - public static async Task AsTask(this IAsyncActionWithProgress source, CancellationToken cancellationToken, IProgress progress) + public static Task AsTask(this IAsyncActionWithProgress source, CancellationToken cancellationToken, IProgress progress) => source.AsTaskCore(cancellationToken, progress); private static async Task AsTaskCore(this IAsyncActionWithProgress source, CancellationToken ct, IProgress? progress = null) diff --git a/src/Uno.UWP/System/Launcher.Android.SpecialUris.cs b/src/Uno.UWP/System/Launcher.Android.SpecialUris.cs index 886c6f2b7e98..44fb4e0cb0dc 100644 --- a/src/Uno.UWP/System/Launcher.Android.SpecialUris.cs +++ b/src/Uno.UWP/System/Launcher.Android.SpecialUris.cs @@ -73,16 +73,16 @@ private static bool CanHandleSpecialUri(Uri uri) } } - private static Task HandleSpecialUriAsync(Uri uri) + private static bool HandleSpecialUri(Uri uri) { switch (uri.Scheme.ToLowerInvariant()) { - case MicrosoftSettingsUri: return HandleSettingsUriAsync(uri); + case MicrosoftSettingsUri: return HandleSettingsUri(uri); default: return LaunchUriActivityAsync(uri); } } - private static Task HandleSettingsUriAsync(Uri uri) + private static bool HandleSettingsUri(Uri uri) { var settingsString = uri.AbsolutePath.ToLowerInvariant(); //get exact match first @@ -99,7 +99,7 @@ private static Task HandleSettingsUriAsync(Uri uri) var intent = new Intent(launchAction ?? Settings.ActionSettings); StartActivity(intent); - return Task.FromResult(true); + return true; } } } diff --git a/src/Uno.UWP/System/Launcher.Android.cs b/src/Uno.UWP/System/Launcher.Android.cs index 688b54e2f092..096a20fb7ab7 100644 --- a/src/Uno.UWP/System/Launcher.Android.cs +++ b/src/Uno.UWP/System/Launcher.Android.cs @@ -26,7 +26,7 @@ public static async Task LaunchUriPlatformAsync(Uri uri) if (IsSpecialUri(uri) && CanHandleSpecialUri(uri)) { - return await HandleSpecialUriAsync(uri); + return HandleSpecialUri(uri); } return await LaunchUriActivityAsync(uri); diff --git a/src/Uno.UWP/System/Launcher.iOS.SpecialUris.cs b/src/Uno.UWP/System/Launcher.iOS.SpecialUris.cs index a4ff80285beb..419d6b4c13e0 100644 --- a/src/Uno.UWP/System/Launcher.iOS.SpecialUris.cs +++ b/src/Uno.UWP/System/Launcher.iOS.SpecialUris.cs @@ -19,16 +19,16 @@ private static bool CanHandleSpecialUri(Uri uri) } } - private static Task HandleSpecialUriAsync(Uri uri) + private static bool HandleSpecialUri(Uri uri) { switch (uri.Scheme.ToLowerInvariant()) { - case MicrosoftSettingsUri: return HandleSettingsUriAsync(uri); + case MicrosoftSettingsUri: return HandleSettingsUri(uri); default: throw new InvalidOperationException("This special URI is not supported on iOS"); } } - private static async Task HandleSettingsUriAsync(Uri uri) => + private static bool HandleSettingsUri(Uri uri) => UIApplication.SharedApplication.OpenUrl( new NSUrl(UIApplication.OpenSettingsUrlString)); } diff --git a/src/Uno.UWP/System/Launcher.iOSmacOS.cs b/src/Uno.UWP/System/Launcher.iOSmacOS.cs index 9c56f070470b..d0e005c961fe 100644 --- a/src/Uno.UWP/System/Launcher.iOSmacOS.cs +++ b/src/Uno.UWP/System/Launcher.iOSmacOS.cs @@ -13,20 +13,21 @@ namespace Windows.System { public static partial class Launcher { - public static async Task LaunchUriPlatformAsync(Uri uri) + // TODO: This should return just bool and be renamed to remove the "Async" suffix. + public static Task LaunchUriPlatformAsync(Uri uri) { if (IsSpecialUri(uri) && CanHandleSpecialUri(uri)) { - return await HandleSpecialUriAsync(uri); + return Task.FromResult(HandleSpecialUri(uri)); } var appleUrl = new AppleUrl(uri.OriginalString); #if __IOS__ - return UIApplication.SharedApplication.OpenUrl( - appleUrl); + return Task.FromResult(UIApplication.SharedApplication.OpenUrl( + appleUrl)); #else - return NSWorkspace.SharedWorkspace.OpenUrl( - appleUrl); + return Task.FromResult(NSWorkspace.SharedWorkspace.OpenUrl( + appleUrl)); #endif } diff --git a/src/Uno.UWP/System/Launcher.macOS.SpecialUris.cs b/src/Uno.UWP/System/Launcher.macOS.SpecialUris.cs index d300c6124601..ba9d86da0f62 100644 --- a/src/Uno.UWP/System/Launcher.macOS.SpecialUris.cs +++ b/src/Uno.UWP/System/Launcher.macOS.SpecialUris.cs @@ -63,16 +63,16 @@ private static bool CanHandleSpecialUri(Uri uri) } } - private static Task HandleSpecialUriAsync(Uri uri) + private static bool HandleSpecialUri(Uri uri) { switch (uri.Scheme.ToLowerInvariant()) { - case MicrosoftSettingsUri: return HandleSettingsUriAsync(uri); + case MicrosoftSettingsUri: return HandleSettingsUri(uri); default: throw new InvalidOperationException("This special URI is not supported on iOS"); } } - private static Task HandleSettingsUriAsync(Uri uri) + private static bool HandleSettingsUri(Uri uri) { var settingsString = uri.AbsolutePath.ToLowerInvariant(); //get exact match first @@ -96,7 +96,7 @@ private static Task HandleSettingsUriAsync(Uri uri) url = NSUrl.CreateFileUrl(new string[] { $@"/System/Library/PreferencePanes/{launchAction}.prefPane" }); } NSWorkspace.SharedWorkspace.OpenUrl(url); - return Task.FromResult(true); + return true } } } diff --git a/src/Uno.UWP/System/Launcher.wasm.cs b/src/Uno.UWP/System/Launcher.wasm.cs index e1941dd9c9e8..d177ad8fc501 100644 --- a/src/Uno.UWP/System/Launcher.wasm.cs +++ b/src/Uno.UWP/System/Launcher.wasm.cs @@ -7,11 +7,11 @@ namespace Windows.System { public static partial class Launcher { - public static async Task LaunchUriPlatformAsync(Uri uri) + public static Task LaunchUriPlatformAsync(Uri uri) { var command = $"Uno.UI.WindowManager.current.open(\"{uri.OriginalString}\");"; var result = WebAssemblyRuntime.InvokeJS(command); - return result == "True"; + return Task.FromResult(result == "True"); } } } diff --git a/src/Uno.UWP/System/UserProfile/UserProfilePersonalizationSettings.Android.cs b/src/Uno.UWP/System/UserProfile/UserProfilePersonalizationSettings.Android.cs index 9ac957c93e86..50eb5414409d 100644 --- a/src/Uno.UWP/System/UserProfile/UserProfilePersonalizationSettings.Android.cs +++ b/src/Uno.UWP/System/UserProfile/UserProfilePersonalizationSettings.Android.cs @@ -34,12 +34,12 @@ private static WallpaperManager GetWallpaperManager() return WallpaperManager.GetInstance(ContextHelper.Current); } - private async Task TrySetImageAsync(StorageFile imageFile, WallpaperManagerFlags target) + private Task TrySetImageAsync(StorageFile imageFile, WallpaperManagerFlags target) { using var wallpaperManager = GetWallpaperManager(); using var stream = File.OpenRead(imageFile.Path); var id = wallpaperManager.SetStream(stream, null, true, target); - return id != 0; //as per docs - if 0 is returned, setting wallpaper failed + return Task.FromResult(id != 0); //as per docs - if 0 is returned, setting wallpaper failed } } } diff --git a/src/Uno.UWP/UI/Popups/MessageDialog.wasm.cs b/src/Uno.UWP/UI/Popups/MessageDialog.wasm.cs index e4ba516e41b3..70a484ea7e21 100644 --- a/src/Uno.UWP/UI/Popups/MessageDialog.wasm.cs +++ b/src/Uno.UWP/UI/Popups/MessageDialog.wasm.cs @@ -23,7 +23,7 @@ private IAsyncOperation ShowNativeAsync(CancellationToken ct) Uno.Foundation.WebAssemblyRuntime.InvokeJS(command); return AsyncOperation.FromTask( - async ct => new UICommand("OK") // TODO: Localize (PBI 28711) + ct => Task.FromResult(new UICommand("OK")) // TODO: Localize (PBI 28711) ); } diff --git a/src/Uno.UWP/UI/ViewManagement/StatusBar/StatusBar.Android.cs b/src/Uno.UWP/UI/ViewManagement/StatusBar/StatusBar.Android.cs index 588f9523d037..8f39fbe04d23 100644 --- a/src/Uno.UWP/UI/ViewManagement/StatusBar/StatusBar.Android.cs +++ b/src/Uno.UWP/UI/ViewManagement/StatusBar/StatusBar.Android.cs @@ -87,23 +87,25 @@ private double PhysicalToLogicalPixels(int physicalPixels) public IAsyncAction ShowAsync() { - return AsyncAction.FromTask(async ct => + return AsyncAction.FromTask(ct => { CoreDispatcher.CheckThreadAccess(); _isShown = true; UpdateSystemUiVisibility(); Showing?.Invoke(this, null); + return Task.CompletedTask; }); } public IAsyncAction HideAsync() { - return AsyncAction.FromTask(async ct => + return AsyncAction.FromTask(ct => { CoreDispatcher.CheckThreadAccess(); _isShown = false; UpdateSystemUiVisibility(); Hiding?.Invoke(this, null); + return Task.CompletedTask; }); } diff --git a/src/Uno.UWP/UI/ViewManagement/StatusBar/StatusBar.iOS.cs b/src/Uno.UWP/UI/ViewManagement/StatusBar/StatusBar.iOS.cs index b0e1cbc17dc0..54384316feb6 100644 --- a/src/Uno.UWP/UI/ViewManagement/StatusBar/StatusBar.iOS.cs +++ b/src/Uno.UWP/UI/ViewManagement/StatusBar/StatusBar.iOS.cs @@ -1,7 +1,7 @@ -#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously -using System; +using System; using System.Collections.Generic; using System.Text; +using System.Threading.Tasks; using UIKit; using Windows.Foundation; using Windows.UI; @@ -56,21 +56,23 @@ public Rect GetOccludedRect() public IAsyncAction ShowAsync() { - return AsyncAction.FromTask(async ct => + return AsyncAction.FromTask(ct => { CoreDispatcher.CheckThreadAccess(); UIApplication.SharedApplication.StatusBarHidden = false; - Showing?.Invoke(this, null); + Showing?.Invoke(this, null); + return Task.CompletedTask; }); } public IAsyncAction HideAsync() { - return AsyncAction.FromTask(async ct => + return AsyncAction.FromTask(ct => { CoreDispatcher.CheckThreadAccess(); UIApplication.SharedApplication.StatusBarHidden = true; Hiding?.Invoke(this, null); + return Task.CompletedTask; }); } }