Skip to content

Commit c7e8663

Browse files
committed
fix warnings
1 parent 4b9515c commit c7e8663

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

9.0/Apps/DeveloperBalance/App.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ namespace DeveloperBalance;
44

55
public partial class App : Application
66
{
7-
public static IServiceProvider ServiceProvider { get; private set; }
7+
public static IServiceProvider? ServiceProvider { get; private set; }
88

99
public App()
1010
{

9.0/Apps/DeveloperBalance/Platforms/iOS/SemanticScreenReaderAsyncImplementation.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ namespace DeveloperBalance;
88

99
public class SemanticScreenReaderAsyncImplementation : IAsyncAnnouncement
1010
{
11-
static NSObject Token;
12-
private TaskCompletionSource<bool> announcementCompletionSource;
11+
static NSObject? Token;
12+
private TaskCompletionSource<bool>? announcementCompletionSource;
1313

1414
public void AddNotification()
1515
{
@@ -33,7 +33,7 @@ public void RemoveNotification()
3333

3434
private void AnnouncementDidFinish(NSNotification notification)
3535
{
36-
announcementCompletionSource.TrySetResult(true);
36+
announcementCompletionSource?.TrySetResult(true);
3737
}
3838

3939
public void Announce(string text)

9.0/Apps/DeveloperBalance/Services/AnnouncementHelper.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,19 @@ namespace DeveloperBalance.Services;
55

66
public static class AnnouncementHelper
77
{
8+
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
89
public static async Task Announce(string recipeName)
910
{
1011
#if IOS
11-
var _semanticScreenReader = App.ServiceProvider.GetService<IAsyncAnnouncement>();
12-
await _semanticScreenReader.AnnounceAsync(recipeName);
12+
var _semanticScreenReader = App.ServiceProvider?.GetService<IAsyncAnnouncement>();
13+
if (_semanticScreenReader is not null)
14+
{
15+
await _semanticScreenReader.AnnounceAsync(recipeName);
16+
}
1317
#else
1418
SemanticScreenReader.Announce(recipeName);
1519
#endif
1620
}
21+
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
22+
1723
}

0 commit comments

Comments
 (0)