Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: Enable CS1998 as error #9983

Merged
merged 11 commits into from
Oct 14, 2022
6 changes: 3 additions & 3 deletions src/AddIns/Uno.UI.Lottie/LottieVisualSourceBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public Size Measure(Size availableSize)
private readonly Size CompositionSize = default;
#pragma warning restore CA1805 // Do not initialize unnecessarily

private async Task InnerUpdate(CancellationToken ct)
private Task InnerUpdate(CancellationToken ct)
{
throw new NotSupportedException("Lottie on this platform is not supported yet.");
}
Expand Down Expand Up @@ -238,7 +238,7 @@ Size IAnimatedVisualSource.Measure(Size availableSize)

private async Task<IInputStream?> TryLoadDownloadJson(Uri uri, CancellationToken ct)
{
if(await TryLoadEmbeddedJson(uri, ct) is {} json)
if (TryLoadEmbeddedJson(uri, ct) is { } json)
{
return json;
}
Expand All @@ -262,7 +262,7 @@ Size IAnimatedVisualSource.Measure(Size availableSize)
: null;
}

private async Task<IInputStream?> TryLoadEmbeddedJson(Uri uri, CancellationToken ct)
private IInputStream? TryLoadEmbeddedJson(Uri uri, CancellationToken ct)
{
if (uri.Scheme != "embedded")
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(() =>
{
Expand All @@ -58,7 +58,7 @@ public partial class ThemableLottieVisualSource : LottieVisualSourceBase, IThema
});
}

private async Task LoadAndUpdate(
private void LoadAndUpdate(
CancellationToken ct,
string sourceCacheKey,
IInputStream sourceJson)
Expand Down
8 changes: 4 additions & 4 deletions src/AddIns/Uno.UI.Lottie/ThemableLottieVisualSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ public partial class ThemableLottieVisualSource : LottieVisualSourceBase, IThema
protected override bool IsPayloadNeedsToBeUpdated => true;

#if NETFRAMEWORK
public Task LoadForTests(
public void LoadForTests(
IInputStream sourceJson,
string sourceCacheKey,
UpdatedAnimation updateCallback)
{
_updateCallback = updateCallback;
return LoadAndUpdate(default, sourceCacheKey, sourceJson);
LoadAndUpdate(default, sourceCacheKey, sourceJson);
}

public string? GetJson()
Expand All @@ -51,7 +51,7 @@ public Task LoadForTests(

_updateCallback = updateCallback;

var t = LoadAndUpdate(cts.Token, sourceCacheKey, sourceJson);
LoadAndUpdate(cts.Token, sourceCacheKey, sourceJson);

return Disposable.Create(() =>
{
Expand All @@ -60,7 +60,7 @@ public Task LoadForTests(
});
}

private async Task LoadAndUpdate(
private void LoadAndUpdate(
CancellationToken ct,
string sourceCacheKey,
IInputStream sourceJson)
Expand Down
3 changes: 1 addition & 2 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<Import Project="$(MSBuildSDKExtrasTargets)" Condition="Exists('$(MSBuildSDKExtrasTargets)')" />

<PropertyGroup>
<NoWarn>$(NoWarn);1998</NoWarn>
<NoWarn>$(NoWarn);CA1416</NoWarn> <!-- Disable warning about cross platform call sites -->
<NoWarn>$(NoWarn);MSB4011</NoWarn> <!-- Disable duplicate msbuild files imports message -->
<DebugType>portable</DebugType>
Expand Down Expand Up @@ -182,7 +181,7 @@
<IsTestProject>$(MSBuildProjectName.Contains('Test'))</IsTestProject>
<IsSampleProject>$(MSBuildProjectName.Contains('Sample'))</IsSampleProject>
<IsSampleProject Condition="'$(IsSampleProject)'=='false'">$(MSBuildProjectName.Contains('UnoIslands'))</IsSampleProject>
<WarningsAsErrors>$(WarningsAsErrors);nullable;CS8032;CS0168;CS0169;CS0618</WarningsAsErrors>
<WarningsAsErrors>$(WarningsAsErrors);nullable;CS8032;CS0168;CS0169;CS0618;CS1998</WarningsAsErrors>
</PropertyGroup>

<PropertyGroup>
Expand Down
21 changes: 14 additions & 7 deletions src/SamplesApp/SamplesApp.Shared/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ private void AppendRepositoryPathToTitleBar()
}
#endif

private static async Task<bool> HandleSkiaAutoScreenshots(LaunchActivatedEventArgs e)
private static bool HandleSkiaAutoScreenshots(LaunchActivatedEventArgs e)
{
#if __SKIA__ || __MACOS__
var runAutoScreenshotsParam =
Expand Down Expand Up @@ -185,7 +185,11 @@ private static async Task<bool> HandleSkiaAutoScreenshots(LaunchActivatedEventAr
return false;
}

private static async Task<bool> HandleSkiaRuntimeTests(LaunchActivatedEventArgs e)
private static
#if __SKIA__ || __MACOS__
async
#endif
Task<bool> HandleSkiaRuntimeTests(LaunchActivatedEventArgs e)
{
#if __SKIA__ || __MACOS__
var runRuntimeTestsResultsParam =
Expand All @@ -207,8 +211,11 @@ await SampleControl.Presentation.SampleChooserViewModel.Instance.RunRuntimeTests

return true;
}
#endif

return false;
#else
return Task.FromResult(false);
#endif
}

#if __IOS__
Expand Down Expand Up @@ -318,7 +325,7 @@ private async void HandleLaunchArguments(LaunchActivatedEventArgs launchActivate
{
Console.WriteLine($"HandleLaunchArguments: {launchActivatedEventArgs.Arguments}");

if (await HandleSkiaAutoScreenshots(launchActivatedEventArgs))
if (HandleSkiaAutoScreenshots(launchActivatedEventArgs))
{
return;
}
Expand All @@ -328,7 +335,7 @@ private async void HandleLaunchArguments(LaunchActivatedEventArgs launchActivate
return;
}

if (await TryNavigateToLaunchSampleAsync(launchActivatedEventArgs))
if (TryNavigateToLaunchSample(launchActivatedEventArgs))
{
return;
}
Expand All @@ -340,7 +347,7 @@ private async void HandleLaunchArguments(LaunchActivatedEventArgs launchActivate
}
}

private async Task<bool> TryNavigateToLaunchSampleAsync(LaunchActivatedEventArgs launchActivatedEventArgs)
private bool TryNavigateToLaunchSample(LaunchActivatedEventArgs launchActivatedEventArgs)
{
const string samplePrefix = "sample=";
try
Expand All @@ -363,7 +370,7 @@ private async Task<bool> 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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<T>(
public static Task WaitForDependencyPropertyValueAsync<T>(
this IApp app,
Func<IAppQuery, IAppQuery> element,
string dependencyPropertyName,
T expectedValue)
=> app.WaitForDependencyPropertyValue<T>(element, dependencyPropertyName, expectedValue);
{
app.WaitForDependencyPropertyValue<T>(element, dependencyPropertyName, expectedValue);
return Task.CompletedTask;
}
}
#endif
7 changes: 5 additions & 2 deletions src/SamplesApp/SamplesApp.UITests/SampleControlUITestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,11 @@ private IEnumerable<Platform> 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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,34 +21,34 @@ 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);
Youssef1313 marked this conversation as resolved.
Show resolved Hide resolved

[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]
[Ignore("Inconsistent behavior between manual and unit test")]
[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<QueryEx> TouchAndHold = element => /*element.TouchAndHold() not implemented ... we can use tap instead */ element.FastTap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
Loading