Resolving warnings and treating warnings as errors in WinUI project. (#824)

This commit is contained in:
Burak Kaan Köse
2026-02-27 20:12:43 +01:00
committed by GitHub
parent d2fce5eee1
commit 0e742c7a8f
55 changed files with 336 additions and 269 deletions
@@ -10,7 +10,7 @@ namespace Wino.Dialogs;
public sealed partial class AccountCreationDialog : ContentDialog, IAccountCreationDialog
{
private TaskCompletionSource<bool> dialogOpened = new TaskCompletionSource<bool>();
public CancellationTokenSource CancellationTokenSource { get; private set; }
public CancellationTokenSource? CancellationTokenSource { get; private set; }
public AccountCreationDialogState State
{
@@ -41,7 +41,7 @@ public sealed partial class AccountCreationDialog : ContentDialog, IAccountCreat
// Unregister from closing event.
Closing -= DialogClosing;
if (cancel && !CancellationTokenSource.IsCancellationRequested)
if (cancel && CancellationTokenSource != null && !CancellationTokenSource.IsCancellationRequested)
{
CancellationTokenSource.Cancel();
}
@@ -6,9 +6,9 @@ namespace Wino.Dialogs;
public sealed partial class AccountPickerDialog : ContentDialog
{
public MailAccount PickedAccount { get; set; }
public MailAccount? PickedAccount { get; set; }
public List<MailAccount> AvailableAccounts { get; set; }
public List<MailAccount> AvailableAccounts { get; set; } = [];
public AccountPickerDialog(List<MailAccount> availableAccounts)
{
@@ -10,21 +10,21 @@ namespace Wino.Dialogs;
public sealed partial class CustomThemeBuilderDialog : ContentDialog
{
public byte[] WallpaperData { get; private set; }
public string AccentColor { get; private set; }
public byte[] WallpaperData { get; private set; } = Array.Empty<byte>();
public string AccentColor { get; private set; } = string.Empty;
private INewThemeService _themeService;
private readonly INewThemeService _themeService;
public CustomThemeBuilderDialog()
{
InitializeComponent();
_themeService = WinoApplication.Current.Services.GetService<INewThemeService>();
_themeService = WinoApplication.Current.Services.GetRequiredService<INewThemeService>();
}
private async void ApplyClicked(ContentDialog sender, ContentDialogButtonClickEventArgs args)
{
if (Array.Empty<byte>() == WallpaperData)
if (WallpaperData.Length == 0)
return;
var deferal = args.GetDeferral();
@@ -45,11 +45,11 @@ public sealed partial class CustomThemeBuilderDialog : ContentDialog
private async void BrowseWallpaperClicked(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{
var dialogService = WinoApplication.Current.Services.GetService<IMailDialogService>();
var dialogService = WinoApplication.Current.Services.GetRequiredService<IMailDialogService>();
var pickedFileData = await dialogService.PickWindowsFileContentAsync(".jpg", ".png");
if (pickedFileData == Array.Empty<byte>()) return;
if (pickedFileData.Length == 0) return;
IsPrimaryButtonEnabled = true;
@@ -15,7 +15,7 @@ namespace Wino.Mail.WinUI.Dialogs;
public sealed partial class NewAccountDialog : ContentDialog
{
private Dictionary<SpecialImapProvider, string> helpingLinks = new Dictionary<SpecialImapProvider, string>()
private readonly Dictionary<SpecialImapProvider, string> helpingLinks = new Dictionary<SpecialImapProvider, string>()
{
{ SpecialImapProvider.iCloud, "https://support.apple.com/en-us/102654" },
{ SpecialImapProvider.Yahoo, "http://help.yahoo.com/kb/SLN15241.html" },
@@ -28,9 +28,9 @@ public sealed partial class NewAccountDialog : ContentDialog
public static readonly DependencyProperty SelectedCalendarModeIndexProperty = DependencyProperty.Register(nameof(SelectedCalendarModeIndex), typeof(int), typeof(NewAccountDialog), new PropertyMetadata(0));
public AppColorViewModel SelectedColor
public AppColorViewModel? SelectedColor
{
get { return (AppColorViewModel)GetValue(SelectedColorProperty); }
get { return (AppColorViewModel?)GetValue(SelectedColorProperty); }
set { SetValue(SelectedColorProperty, value); }
}
@@ -43,9 +43,9 @@ public sealed partial class NewAccountDialog : ContentDialog
/// <summary>
/// Gets or sets current selected mail provider in the dialog.
/// </summary>
public ProviderDetail SelectedMailProvider
public ProviderDetail? SelectedMailProvider
{
get { return (ProviderDetail)GetValue(SelectedMailProviderProperty); }
get { return (ProviderDetail?)GetValue(SelectedMailProviderProperty); }
set { SetValue(SelectedMailProviderProperty, value); }
}
@@ -64,9 +64,9 @@ public sealed partial class NewAccountDialog : ContentDialog
// List of available mail providers for now.
public List<IProviderDetail> Providers { get; set; }
public List<IProviderDetail> Providers { get; set; } = [];
public List<AppColorViewModel> AvailableColors { get; set; }
public List<AppColorViewModel> AvailableColors { get; set; } = [];
public List<string> CalendarModeOptions { get; } =
[
Translator.ImapCalDavSettingsPage_CalendarModeCalDav,
@@ -75,7 +75,7 @@ public sealed partial class NewAccountDialog : ContentDialog
];
public AccountCreationDialogResult Result = null;
public AccountCreationDialogResult? Result = null;
public NewAccountDialog()
{
@@ -113,6 +113,9 @@ public sealed partial class NewAccountDialog : ContentDialog
private void CreateClicked(ContentDialog sender, ContentDialogButtonClickEventArgs args)
{
if (SelectedMailProvider == null)
return;
if (IsSpecialImapServerPartVisible)
{
// Special imap detail input.
@@ -198,7 +201,11 @@ public sealed partial class NewAccountDialog : ContentDialog
private async void AppSpecificHelpButtonClicked(object sender, RoutedEventArgs e)
{
var helpUrl = helpingLinks[SelectedMailProvider.SpecialImapProvider];
if (SelectedMailProvider == null ||
!helpingLinks.TryGetValue(SelectedMailProvider.SpecialImapProvider, out var helpUrl))
{
return;
}
await Launcher.LaunchUriAsync(new Uri(helpUrl));
}
+1 -1
View File
@@ -25,7 +25,7 @@ public sealed partial class PrintDialog : ContentDialog
/// Initializes the dialog with existing print settings.
/// </summary>
/// <param name="printSettings">The initial print settings to load.</param>
public PrintDialog(WebView2PrintSettingsModel printSettings = null)
public PrintDialog(WebView2PrintSettingsModel printSettings = default!)
{
if (printSettings != null) PrintSettings = printSettings;