diff --git a/README.md b/README.md index fb84756a..93026a4e 100644 --- a/README.md +++ b/README.md @@ -84,7 +84,7 @@ On Windows, TweetDuck uses the [CefSharp](https://github.com/cefsharp/CefSharp/) On Linux, TweetDuck uses the [ChromiumGtk](https://github.com/lunixo/ChromiumGtk) library, which combines [CefGlue](https://gitlab.com/xiliumhq/chromiumembedded/cefglue) for the browser component and [GtkSharp](https://github.com/GtkSharp/GtkSharp) for the GUI. -The solution contains several C# projects for executables and libraries, and F# projects for automated tests. All projects target `.NET 6`. +The solution contains several C# projects for executables and libraries, and F# projects for automated tests. All projects target `.NET 6` and either `C# 10` or `F#`. Projects are organized into folders: * Windows projects are in the `windows/` folder diff --git a/lib/TweetLib.Browser.CEF/TweetLib.Browser.CEF.csproj b/lib/TweetLib.Browser.CEF/TweetLib.Browser.CEF.csproj index a531f33d..2eac49e5 100644 --- a/lib/TweetLib.Browser.CEF/TweetLib.Browser.CEF.csproj +++ b/lib/TweetLib.Browser.CEF/TweetLib.Browser.CEF.csproj @@ -4,7 +4,7 @@ <TargetFramework>net6.0</TargetFramework> <Configurations>Debug;Release</Configurations> <Platforms>x86;x64</Platforms> - <LangVersion>9</LangVersion> + <LangVersion>10</LangVersion> <Nullable>enable</Nullable> <GenerateAssemblyInfo>false</GenerateAssemblyInfo> </PropertyGroup> diff --git a/lib/TweetLib.Browser/TweetLib.Browser.csproj b/lib/TweetLib.Browser/TweetLib.Browser.csproj index 953d39e1..078d5d76 100644 --- a/lib/TweetLib.Browser/TweetLib.Browser.csproj +++ b/lib/TweetLib.Browser/TweetLib.Browser.csproj @@ -4,7 +4,7 @@ <TargetFramework>net6.0</TargetFramework> <Configurations>Debug;Release</Configurations> <Platforms>x86;x64</Platforms> - <LangVersion>9</LangVersion> + <LangVersion>10</LangVersion> <Nullable>enable</Nullable> <GenerateAssemblyInfo>false</GenerateAssemblyInfo> </PropertyGroup> diff --git a/lib/TweetLib.Communication/TweetLib.Communication.csproj b/lib/TweetLib.Communication/TweetLib.Communication.csproj index fbf6f275..1876c9e4 100644 --- a/lib/TweetLib.Communication/TweetLib.Communication.csproj +++ b/lib/TweetLib.Communication/TweetLib.Communication.csproj @@ -3,7 +3,7 @@ <PropertyGroup> <TargetFramework>net6.0</TargetFramework> <Platforms>x86</Platforms> - <LangVersion>9</LangVersion> + <LangVersion>10</LangVersion> <Nullable>enable</Nullable> <GenerateAssemblyInfo>false</GenerateAssemblyInfo> </PropertyGroup> diff --git a/lib/TweetLib.Core/App.cs b/lib/TweetLib.Core/App.cs index ff5399dc..1e2c1114 100644 --- a/lib/TweetLib.Core/App.cs +++ b/lib/TweetLib.Core/App.cs @@ -110,11 +110,11 @@ private static T Validate<T>(T? obj, string name) where T : class { } public sealed class AppBuilder { - public IAppSetup? Setup { get; set; } - public IAppErrorHandler? ErrorHandler { get; set; } - public IAppSystemHandler? SystemHandler { get; set; } - public IAppMessageDialogs? MessageDialogs { get; set; } - public IAppFileDialogs? FileDialogs { get; set; } + public IAppSetup? Setup { get; init; } + public IAppErrorHandler? ErrorHandler { get; init; } + public IAppSystemHandler? SystemHandler { get; init; } + public IAppMessageDialogs? MessageDialogs { get; init; } + public IAppFileDialogs? FileDialogs { get; init; } internal static AppBuilder? Instance { get; private set; } diff --git a/lib/TweetLib.Core/TweetLib.Core.csproj b/lib/TweetLib.Core/TweetLib.Core.csproj index 7850c59b..f91558d5 100644 --- a/lib/TweetLib.Core/TweetLib.Core.csproj +++ b/lib/TweetLib.Core/TweetLib.Core.csproj @@ -4,7 +4,7 @@ <TargetFramework>net6.0</TargetFramework> <Configurations>Debug;Release</Configurations> <Platforms>x86;x64</Platforms> - <LangVersion>9</LangVersion> + <LangVersion>10</LangVersion> <Nullable>enable</Nullable> <GenerateAssemblyInfo>false</GenerateAssemblyInfo> </PropertyGroup> diff --git a/lib/TweetLib.Utils/TweetLib.Utils.csproj b/lib/TweetLib.Utils/TweetLib.Utils.csproj index 953d39e1..078d5d76 100644 --- a/lib/TweetLib.Utils/TweetLib.Utils.csproj +++ b/lib/TweetLib.Utils/TweetLib.Utils.csproj @@ -4,7 +4,7 @@ <TargetFramework>net6.0</TargetFramework> <Configurations>Debug;Release</Configurations> <Platforms>x86;x64</Platforms> - <LangVersion>9</LangVersion> + <LangVersion>10</LangVersion> <Nullable>enable</Nullable> <GenerateAssemblyInfo>false</GenerateAssemblyInfo> </PropertyGroup> diff --git a/windows/TweetDuck.Browser/TweetDuck.Browser.csproj b/windows/TweetDuck.Browser/TweetDuck.Browser.csproj index b73fdbba..66e48964 100644 --- a/windows/TweetDuck.Browser/TweetDuck.Browser.csproj +++ b/windows/TweetDuck.Browser/TweetDuck.Browser.csproj @@ -5,7 +5,7 @@ <Configurations>Debug;Release</Configurations> <Platforms>x86</Platforms> <RuntimeIdentifier>win7-x86</RuntimeIdentifier> - <LangVersion>8.0</LangVersion> + <LangVersion>10</LangVersion> <Nullable>enable</Nullable> </PropertyGroup> diff --git a/windows/TweetDuck.Video/Controls/LabelTooltip.cs b/windows/TweetDuck.Video/Controls/LabelTooltip.cs index 25bc8e76..93969961 100644 --- a/windows/TweetDuck.Video/Controls/LabelTooltip.cs +++ b/windows/TweetDuck.Video/Controls/LabelTooltip.cs @@ -11,11 +11,11 @@ public LabelTooltip() { } public void AttachTooltip(Control control, bool followCursor, string tooltip) { - AttachTooltip(control, followCursor, args => tooltip); + AttachTooltip(control, followCursor, _ => tooltip); } public void AttachTooltip(Control control, bool followCursor, Func<MouseEventArgs, string?> tooltipFunc) { - control.MouseMove += (sender, args) => { + control.MouseMove += (_, args) => { SuspendLayout(); Form? form = control.FindForm(); diff --git a/windows/TweetDuck.Video/FormPlayer.cs b/windows/TweetDuck.Video/FormPlayer.cs index cdd4e1e9..39af1ec4 100644 --- a/windows/TweetDuck.Video/FormPlayer.cs +++ b/windows/TweetDuck.Video/FormPlayer.cs @@ -79,7 +79,7 @@ public FormPlayer(IntPtr handle, int dpi, int volume, string url, string token) return $"{(progress / 60):00}:{(progress % 60):00}"; }); - labelTooltip.AttachTooltip(trackBarVolume, false, args => $"Volume : {trackBarVolume.Value}%"); + labelTooltip.AttachTooltip(trackBarVolume, false, _ => $"Volume : {trackBarVolume.Value}%"); labelTooltip.AttachTooltip(imageClose, false, "Close"); labelTooltip.AttachTooltip(imageDownload, false, "Download"); diff --git a/windows/TweetDuck.Video/TweetDuck.Video.csproj b/windows/TweetDuck.Video/TweetDuck.Video.csproj index 247bd47e..64bf4eee 100644 --- a/windows/TweetDuck.Video/TweetDuck.Video.csproj +++ b/windows/TweetDuck.Video/TweetDuck.Video.csproj @@ -5,7 +5,7 @@ <Configurations>Debug;Release</Configurations> <Platforms>x86</Platforms> <RuntimeIdentifier>win7-x86</RuntimeIdentifier> - <LangVersion>8.0</LangVersion> + <LangVersion>10</LangVersion> <Nullable>enable</Nullable> </PropertyGroup> diff --git a/windows/TweetDuck/Application/FileDialogs.cs b/windows/TweetDuck/Application/FileDialogs.cs index 0a5fcf8d..8999c8a5 100644 --- a/windows/TweetDuck/Application/FileDialogs.cs +++ b/windows/TweetDuck/Application/FileDialogs.cs @@ -14,7 +14,7 @@ public void SaveFile(SaveFileDialogSettings settings, Action<string> onAccepted) OverwritePrompt = settings.OverwritePrompt, Title = settings.DialogTitle, FileName = settings.FileName, - Filter = settings.Filters == null ? null : string.Join("|", settings.Filters.Select(filter => filter.JoinFullNameAndPattern("|"))) + Filter = settings.Filters == null ? null : string.Join("|", settings.Filters.Select(static filter => filter.JoinFullNameAndPattern("|"))) }; if (dialog.ShowDialog() == DialogResult.OK) { diff --git a/windows/TweetDuck/Application/SystemHandler.cs b/windows/TweetDuck/Application/SystemHandler.cs index 0217854c..595b2802 100644 --- a/windows/TweetDuck/Application/SystemHandler.cs +++ b/windows/TweetDuck/Application/SystemHandler.cs @@ -58,7 +58,7 @@ public void OpenBrowser(string? url) { config.Save(); } - if (result == DialogResult.Ignore || result == DialogResult.Yes) { + if (result is DialogResult.Ignore or DialogResult.Yes) { goto case TwitterUrls.UrlType.Fine; } } @@ -81,7 +81,7 @@ public void OpenFileExplorer(string path) { } } - public IAppSystemHandler.OpenAssociatedProgramFunc OpenAssociatedProgram { get; } = path => { + public IAppSystemHandler.OpenAssociatedProgramFunc OpenAssociatedProgram { get; } = static path => { try { using (Process.Start(new ProcessStartInfo { FileName = path, @@ -94,7 +94,7 @@ public void OpenFileExplorer(string path) { }; - public IAppSystemHandler.CopyImageFromFileFunc CopyImageFromFile { get; } = path => { + public IAppSystemHandler.CopyImageFromFileFunc CopyImageFromFile { get; } = static path => { FormManager.RunOnUIThreadAsync(() => { Image image; @@ -109,11 +109,11 @@ public void OpenFileExplorer(string path) { }); }; - public IAppSystemHandler.CopyTextFunc CopyText { get; } = text => { + public IAppSystemHandler.CopyTextFunc CopyText { get; } = static text => { FormManager.RunOnUIThreadAsync(() => ClipboardManager.SetText(text, TextDataFormat.UnicodeText)); }; - public IAppSystemHandler.SearchTextFunc SearchText { get; } = text => { + public IAppSystemHandler.SearchTextFunc SearchText { get; } = static text => { if (string.IsNullOrWhiteSpace(text)) { return; } @@ -138,7 +138,7 @@ void PerformSearch() { return; } - settings.FormClosed += (sender, args) => { + settings.FormClosed += (_, args) => { if (args.CloseReason == CloseReason.UserClosing && config.SearchEngineUrl != searchUrl) { PerformSearch(); } diff --git a/windows/TweetDuck/Browser/Base/CefBrowserComponent.cs b/windows/TweetDuck/Browser/Base/CefBrowserComponent.cs index a0bbfba2..4c1e30a6 100644 --- a/windows/TweetDuck/Browser/Base/CefBrowserComponent.cs +++ b/windows/TweetDuck/Browser/Base/CefBrowserComponent.cs @@ -6,7 +6,7 @@ namespace TweetDuck.Browser.Base { sealed class CefBrowserComponent : BrowserComponentBase { - private static readonly CreateContextMenu DefaultContextMenuFactory = handler => new ContextMenuBase(handler); + private static readonly CreateContextMenu DefaultContextMenuFactory = static handler => new ContextMenuBase(handler); public override string CacheFolder => CefUtils.GetCacheFolder(App.StoragePath); diff --git a/windows/TweetDuck/Browser/Base/ContextMenuBrowser.cs b/windows/TweetDuck/Browser/Base/ContextMenuBrowser.cs index 17fc9e8e..7407ef15 100644 --- a/windows/TweetDuck/Browser/Base/ContextMenuBrowser.cs +++ b/windows/TweetDuck/Browser/Base/ContextMenuBrowser.cs @@ -102,14 +102,14 @@ public override void OnContextMenuDismissed(IWebBrowser browserControl, IBrowser public static ContextMenuStrip CreateMenu(FormBrowser form) { ContextMenuStrip menu = new ContextMenuStrip(); - menu.Items.Add(TitleReloadBrowser, null, (sender, args) => form.ReloadToTweetDeck()); - menu.Items.Add(TitleMuteNotifications, null, (sender, args) => ToggleMuteNotifications()); + menu.Items.Add(TitleReloadBrowser, null, (_, _) => form.ReloadToTweetDeck()); + menu.Items.Add(TitleMuteNotifications, null, static (_, _) => ToggleMuteNotifications()); menu.Items.Add("-"); - menu.Items.Add(TitleSettings, null, (sender, args) => form.OpenSettings()); - menu.Items.Add(TitlePlugins, null, (sender, args) => form.OpenPlugins()); - menu.Items.Add(TitleAboutProgram, null, (sender, args) => form.OpenAbout()); + menu.Items.Add(TitleSettings, null, (_, _) => form.OpenSettings()); + menu.Items.Add(TitlePlugins, null, (_, _) => form.OpenPlugins()); + menu.Items.Add(TitleAboutProgram, null, (_, _) => form.OpenAbout()); - menu.Opening += (sender, args) => { + menu.Opening += (_, _) => { ((ToolStripMenuItem) menu.Items[1]).Checked = Config.MuteNotifications; }; diff --git a/windows/TweetDuck/Browser/Base/PopupHandler.cs b/windows/TweetDuck/Browser/Base/PopupHandler.cs index 65987ec1..005b648d 100644 --- a/windows/TweetDuck/Browser/Base/PopupHandler.cs +++ b/windows/TweetDuck/Browser/Base/PopupHandler.cs @@ -4,7 +4,7 @@ namespace TweetDuck.Browser.Base { sealed class PopupHandler : IPopupHandler { - public static PopupHandler Instance { get; } = new PopupHandler(); + public static PopupHandler Instance { get; } = new (); private PopupHandler() {} diff --git a/windows/TweetDuck/Browser/FormBrowser.cs b/windows/TweetDuck/Browser/FormBrowser.cs index 41cda1af..d6a9c734 100644 --- a/windows/TweetDuck/Browser/FormBrowser.cs +++ b/windows/TweetDuck/Browser/FormBrowser.cs @@ -94,7 +94,7 @@ public FormBrowser(ResourceCache resourceCache, PluginManager pluginManager, IUp Config.MuteToggled += Config_MuteToggled; Config.TrayBehaviorChanged += Config_TrayBehaviorChanged; - Disposed += (sender, args) => { + Disposed += (_, _) => { Config.MuteToggled -= Config_MuteToggled; Config.TrayBehaviorChanged -= Config_TrayBehaviorChanged; browser.Dispose(); @@ -127,7 +127,7 @@ protected override void Dispose(bool disposing) { } private void ShowChildForm(Form form) { - form.VisibleChanged += (sender, args) => form.MoveToCenter(this); + form.VisibleChanged += (_, _) => form.MoveToCenter(this); form.Show(this); } @@ -286,12 +286,12 @@ void OnFinished() { else { FormUpdateDownload downloadForm = new FormUpdateDownload(update); - downloadForm.VisibleChanged += (sender2, args2) => { + downloadForm.VisibleChanged += (_, _) => { downloadForm.MoveToCenter(this); Hide(); }; - downloadForm.FormClosed += (sender2, args2) => { + downloadForm.FormClosed += (_, _) => { if (downloadForm.DialogResult != DialogResult.OK) { update.CancelDownload(); } @@ -391,7 +391,7 @@ public void OpenSettings(Type? startTab) { FormSettings form = new FormSettings(this, plugins, updates, browser.Functions, startTab); - form.FormClosed += (sender, args) => { + form.FormClosed += (_, _) => { if (!prevEnableUpdateCheck && Config.EnableUpdateCheck) { Config.DismissedUpdate = null; Config.Save(); @@ -469,7 +469,7 @@ private void PlayVideo(string videoUrl, string tweetUrl, string username, IJavas if (playerPath == null || !File.Exists(playerPath)) { if (videoPlayer == null) { videoPlayer = new VideoPlayer(this); - videoPlayer.ProcessExited += (sender, args) => browser.HideVideoOverlay(true); + videoPlayer.ProcessExited += (_, _) => browser.HideVideoOverlay(true); } callShowOverlay.ExecuteAsync(); diff --git a/windows/TweetDuck/Browser/Notification/FormNotificationBase.cs b/windows/TweetDuck/Browser/Notification/FormNotificationBase.cs index b1558dff..59c04d63 100644 --- a/windows/TweetDuck/Browser/Notification/FormNotificationBase.cs +++ b/windows/TweetDuck/Browser/Notification/FormNotificationBase.cs @@ -95,10 +95,10 @@ protected virtual FormBorderStyle NotificationBorderStyle { protected readonly CefBrowserComponent browserComponent; private readonly NotificationBrowser browserImpl; - private readonly CefByteArrayResourceHandler resourceHandler = new CefByteArrayResourceHandler(); + private readonly CefByteArrayResourceHandler resourceHandler = new (); private DesktopNotification? currentNotification; - private readonly HashSet<NotificationPauseReason> pauseReasons = new HashSet<NotificationPauseReason>(); + private readonly HashSet<NotificationPauseReason> pauseReasons = new (); public string? CurrentTweetUrl => currentNotification?.TweetUrl; public string? CurrentQuoteUrl => currentNotification?.QuoteUrl; @@ -126,7 +126,7 @@ protected FormNotificationBase(FormBrowser owner, CreateBrowserImplFunc createBr Controls.Add(browser); - Disposed += (sender, args) => { + Disposed += (_, _) => { this.owner.FormClosed -= owner_FormClosed; this.browserImpl.Dispose(); this.browser.Dispose(); diff --git a/windows/TweetDuck/Browser/Notification/FormNotificationExample.cs b/windows/TweetDuck/Browser/Notification/FormNotificationExample.cs index 866557ec..8d57051b 100644 --- a/windows/TweetDuck/Browser/Notification/FormNotificationExample.cs +++ b/windows/TweetDuck/Browser/Notification/FormNotificationExample.cs @@ -37,7 +37,7 @@ protected override FormBorderStyle NotificationBorderStyle { private readonly DesktopNotification exampleNotification; public FormNotificationExample(FormBrowser owner, ITweetDeckInterface tweetDeckInterface, PluginManager pluginManager) : base(owner, (form, browserComponent) => CreateBrowserImpl(browserComponent, new NotificationInterfaceImpl(form), tweetDeckInterface, pluginManager)) { - browserComponent.BrowserLoaded += (sender, args) => { + browserComponent.BrowserLoaded += (_, _) => { Ready?.Invoke(this, EventArgs.Empty); }; diff --git a/windows/TweetDuck/Browser/Notification/FormNotificationMain.cs b/windows/TweetDuck/Browser/Notification/FormNotificationMain.cs index 51ebb92c..c688e1c6 100644 --- a/windows/TweetDuck/Browser/Notification/FormNotificationMain.cs +++ b/windows/TweetDuck/Browser/Notification/FormNotificationMain.cs @@ -104,7 +104,7 @@ protected FormNotificationMain(FormBrowser owner, CreateBrowserImplFunc createBr browser.LoadingStateChanged += Browser_LoadingStateChanged; mouseHookDelegate = MouseHookProc; - Disposed += (sender, args) => StopMouseHook(true); + Disposed += (_, _) => StopMouseHook(true); } private void SetOpacity(int opacity) { diff --git a/windows/TweetDuck/Browser/Notification/FormNotificationTweet.cs b/windows/TweetDuck/Browser/Notification/FormNotificationTweet.cs index 2bb998b5..189e5f75 100644 --- a/windows/TweetDuck/Browser/Notification/FormNotificationTweet.cs +++ b/windows/TweetDuck/Browser/Notification/FormNotificationTweet.cs @@ -33,7 +33,7 @@ protected override bool CanDragWindow { } } - private readonly Queue<DesktopNotification> tweetQueue = new Queue<DesktopNotification>(4); + private readonly Queue<DesktopNotification> tweetQueue = new (4); private bool needsTrim; private bool hasTemporarilyMoved; @@ -43,7 +43,7 @@ protected override bool CanDragWindow { Config.MuteToggled += Config_MuteToggled; WindowsSessionManager.LockStateChanged += WindowsSessionManager_LockStateChanged; - Disposed += (sender, args) => { + Disposed += (_, _) => { Config.MuteToggled -= Config_MuteToggled; WindowsSessionManager.LockStateChanged -= WindowsSessionManager_LockStateChanged; }; @@ -66,7 +66,7 @@ protected override void WndProc(ref Message m) { if (m.Msg == 0x00A7) { // WM_NCMBUTTONDOWN int hitTest = m.WParam.ToInt32(); - if (hitTest == 2 || hitTest == 20) { // HTCAPTION, HTCLOSE + if (hitTest is 2 or 20) { // HTCAPTION, HTCLOSE hasTemporarilyMoved = false; MoveToVisibleLocation(); return; diff --git a/windows/TweetDuck/Browser/Notification/Screenshot/FormNotificationScreenshotable.cs b/windows/TweetDuck/Browser/Notification/Screenshot/FormNotificationScreenshotable.cs index b082a9fc..9ca2ea7c 100644 --- a/windows/TweetDuck/Browser/Notification/Screenshot/FormNotificationScreenshotable.cs +++ b/windows/TweetDuck/Browser/Notification/Screenshot/FormNotificationScreenshotable.cs @@ -27,7 +27,7 @@ public FormNotificationScreenshotable(Action callback, FormBrowser owner, Plugin browserComponent.AttachBridgeObject("$TD_NotificationScreenshot", new ScreenshotBridge(this, SetScreenshotHeight, callback)); - browserComponent.BrowserLoaded += (sender, args) => { + browserComponent.BrowserLoaded += (_, _) => { string? script = ResourceUtils.ReadFileOrNull("notification/screenshot/screenshot.js"); if (script == null) { diff --git a/windows/TweetDuck/Browser/Notification/Screenshot/TweetScreenshotManager.cs b/windows/TweetDuck/Browser/Notification/Screenshot/TweetScreenshotManager.cs index 5bd98e05..093defd5 100644 --- a/windows/TweetDuck/Browser/Notification/Screenshot/TweetScreenshotManager.cs +++ b/windows/TweetDuck/Browser/Notification/Screenshot/TweetScreenshotManager.cs @@ -101,7 +101,7 @@ private void HandleResult(Task<Image> task) { OnFinished(); #else screenshot.MoveToVisibleLocation(); - screenshot.FormClosed += (sender, args) => disposer.Start(); + screenshot.FormClosed += (_, _) => disposer.Start(); #endif } } diff --git a/windows/TweetDuck/Browser/Notification/SoundNotification.cs b/windows/TweetDuck/Browser/Notification/SoundNotification.cs index b8b22313..6ec4915d 100644 --- a/windows/TweetDuck/Browser/Notification/SoundNotification.cs +++ b/windows/TweetDuck/Browser/Notification/SoundNotification.cs @@ -1,5 +1,4 @@ -using System.Drawing; -using System.IO; +using System.IO; using System.Windows.Forms; using CefSharp; using TweetDuck.Controls; @@ -54,7 +53,7 @@ private static (byte[] data, string mimeType)? CreateFileHandler(string path) { Button btnViewOptions = form.AddButton("View Options"); btnViewOptions.Width += 16; - btnViewOptions.Location = new Point(btnViewOptions.Location.X - 16, btnViewOptions.Location.Y); + btnViewOptions.Location = btnViewOptions.Location with { X = btnViewOptions.Location.X - 16 }; if (form.ShowDialog() == DialogResult.OK && form.ClickedButton == btnViewOptions) { browser.OpenSettings(typeof(TabSettingsSounds)); diff --git a/windows/TweetDuck/Browser/TrayIcon.cs b/windows/TweetDuck/Browser/TrayIcon.cs index 0af203c5..402bf6be 100644 --- a/windows/TweetDuck/Browser/TrayIcon.cs +++ b/windows/TweetDuck/Browser/TrayIcon.cs @@ -61,7 +61,7 @@ private TrayIcon() { this.notifyIcon.Text = Program.BrandName; Config.MuteToggled += Config_MuteToggled; - Disposed += (sender, args) => Config.MuteToggled -= Config_MuteToggled; + Disposed += (_, _) => Config.MuteToggled -= Config_MuteToggled; } public TrayIcon(IContainer container) : this() { @@ -119,11 +119,11 @@ public static bool ShouldDisplayIcon(this TrayIcon.Behavior behavior) { } public static bool ShouldHideOnMinimize(this TrayIcon.Behavior behavior) { - return behavior == TrayIcon.Behavior.MinimizeToTray || behavior == TrayIcon.Behavior.Combined; + return behavior is TrayIcon.Behavior.MinimizeToTray or TrayIcon.Behavior.Combined; } public static bool ShouldHideOnClose(this TrayIcon.Behavior behavior) { - return behavior == TrayIcon.Behavior.CloseToTray || behavior == TrayIcon.Behavior.Combined; + return behavior is TrayIcon.Behavior.CloseToTray or TrayIcon.Behavior.Combined; } } } diff --git a/windows/TweetDuck/Browser/TweetDeckBrowser.cs b/windows/TweetDuck/Browser/TweetDeckBrowser.cs index b62bf45c..0051746f 100644 --- a/windows/TweetDuck/Browser/TweetDeckBrowser.cs +++ b/windows/TweetDuck/Browser/TweetDeckBrowser.cs @@ -52,7 +52,7 @@ public TweetDeckBrowser(FormBrowser owner, PluginManager pluginManager, ITweetDe this.browserImpl = new TweetDeckBrowserImpl(browserComponent, tweetDeckInterface, extraContext, new SoundNotification(browserComponent.ResourceHandlerRegistry), pluginManager, updateChecker); if (Arguments.HasFlag(Arguments.ArgIgnoreGDPR)) { - browserComponent.PageLoadEnd += (sender, args) => { + browserComponent.PageLoadEnd += (_, args) => { if (TwitterUrls.IsTweetDeck(args.Url)) { browserComponent.RunScript("gen:gdpr", "TD.storage.Account.prototype.requiresConsent = function() { return false; }"); } diff --git a/windows/TweetDuck/Configuration/UserConfig.cs b/windows/TweetDuck/Configuration/UserConfig.cs index 4dbd3791..b9007a5a 100644 --- a/windows/TweetDuck/Configuration/UserConfig.cs +++ b/windows/TweetDuck/Configuration/UserConfig.cs @@ -18,7 +18,7 @@ sealed class UserConfig : BaseConfig<UserConfig>, IAppUserConfiguration { [SuppressMessage("ReSharper", "UnusedMember.Global")] public bool AllowDataCollection { get; set; } = false; - public WindowState BrowserWindow { get; set; } = new WindowState(); + public WindowState BrowserWindow { get; set; } = new (); public Size PluginsWindowSize { get; set; } = Size.Empty; public bool ExpandLinksOnHover { get; set; } = true; diff --git a/windows/TweetDuck/Controls/ControlExtensions.cs b/windows/TweetDuck/Controls/ControlExtensions.cs index 16a69515..a6e714e8 100644 --- a/windows/TweetDuck/Controls/ControlExtensions.cs +++ b/windows/TweetDuck/Controls/ControlExtensions.cs @@ -6,7 +6,7 @@ namespace TweetDuck.Controls { static class ControlExtensions { - public static readonly Point InvisibleLocation = new Point(-32000, -32000); + public static readonly Point InvisibleLocation = new (-32000, -32000); public static void InvokeSafe(this Control control, Action func) { if (control.InvokeRequired) { @@ -73,7 +73,7 @@ public static bool AlignValueToTick(this TrackBar trackBar) { } public static void EnableMultilineShortcuts(this TextBox textBox) { - textBox.KeyDown += (sender, args) => { + textBox.KeyDown += static (sender, args) => { if (args.Control && args.KeyCode == Keys.A && sender is TextBox tb) { tb.SelectAll(); args.SuppressKeyPress = true; diff --git a/windows/TweetDuck/Dialogs/FormGuide.cs b/windows/TweetDuck/Dialogs/FormGuide.cs index 48de8dd5..d2696c82 100644 --- a/windows/TweetDuck/Dialogs/FormGuide.cs +++ b/windows/TweetDuck/Dialogs/FormGuide.cs @@ -36,7 +36,7 @@ private FormGuide(string url, Form owner) { Text = Program.BrandName + " Guide"; Size = new Size(owner.Size.Width * 3 / 4, owner.Size.Height * 3 / 4); - VisibleChanged += (sender, args) => this.MoveToCenter(owner); + VisibleChanged += (_, _) => this.MoveToCenter(owner); browser = new ChromiumWebBrowser(url) { KeyboardHandler = new CustomKeyboardHandler(null) @@ -51,7 +51,7 @@ private FormGuide(string url, Form owner) { Controls.Add(browser); - Disposed += (sender, args) => { + Disposed += (_, _) => { browserImpl.Dispose(); browser.Dispose(); }; diff --git a/windows/TweetDuck/Dialogs/FormMessage.cs b/windows/TweetDuck/Dialogs/FormMessage.cs index ad9c6e96..4ac61657 100644 --- a/windows/TweetDuck/Dialogs/FormMessage.cs +++ b/windows/TweetDuck/Dialogs/FormMessage.cs @@ -61,7 +61,7 @@ public static bool Show(string caption, string text, MessageBoxIcon icon, string private int ClientWidth { get => ClientSize.Width; - set => ClientSize = new Size(value, ClientSize.Height); + set => ClientSize = ClientSize with { Width = value }; } private int ButtonDistance { @@ -105,7 +105,7 @@ public FormMessage(string caption, string text, MessageBoxIcon messageIcon) { default: icon = null; - labelMessage.Location = new Point(BrowserUtils.Scale(19, dpiScale), labelMessage.Location.Y); // 19 instead of 9 due to larger height + labelMessage.Location = labelMessage.Location with { X = BrowserUtils.Scale(19, dpiScale) }; // 19 instead of 9 due to larger height break; } @@ -134,7 +134,7 @@ public Button AddButton(string title, DialogResult result = DialogResult.OK, Con UseVisualStyleBackColor = true }; - button.Click += (sender, args) => { + button.Click += (_, _) => { ClickedButton = button; DialogResult = result; Close(); @@ -177,7 +177,7 @@ private void RecalculateButtonLocation() { for (int index = 0; index < buttonCount; index++) { Control control = panelActions.Controls[index]; - control.Location = new Point(start - index * dist, control.Location.Y); + control.Location = control.Location with { X = start - index * dist }; } } @@ -190,11 +190,11 @@ private void labelMessage_SizeChanged(object? sender, EventArgs e) { int labelOffset = BrowserUtils.Scale(8, dpiScale); if (isMultiline && !wasLabelMultiline) { - labelMessage.Location = new Point(labelMessage.Location.X, labelMessage.Location.Y - labelOffset); + labelMessage.Location = labelMessage.Location with { Y = labelMessage.Location.Y - labelOffset }; prevLabelHeight += labelOffset; } else if (!isMultiline && wasLabelMultiline) { - labelMessage.Location = new Point(labelMessage.Location.X, labelMessage.Location.Y + labelOffset); + labelMessage.Location = labelMessage.Location with { Y = labelMessage.Location.Y + labelOffset }; prevLabelHeight -= labelOffset; } diff --git a/windows/TweetDuck/Dialogs/FormPlugins.cs b/windows/TweetDuck/Dialogs/FormPlugins.cs index 1ffe9e7a..9cb4603f 100644 --- a/windows/TweetDuck/Dialogs/FormPlugins.cs +++ b/windows/TweetDuck/Dialogs/FormPlugins.cs @@ -31,16 +31,16 @@ public FormPlugins(PluginManager pluginManager) : this() { Size = new Size(Math.Max(MinimumSize.Width, targetSize.Width), Math.Max(MinimumSize.Height, targetSize.Height)); } - Shown += (sender, args) => { + Shown += (_, _) => { ReloadPluginList(); }; - FormClosed += (sender, args) => { + FormClosed += (_, _) => { Config.PluginsWindowSize = Size; Config.Save(); }; - ResizeEnd += (sender, args) => { + ResizeEnd += (_, _) => { timerLayout.Start(); }; } @@ -53,7 +53,7 @@ private void ReloadPluginList() { flowLayoutPlugins.Controls.Clear(); flowLayoutPlugins.SuspendLayout(); - foreach (Plugin plugin in pluginManager.Plugins.OrderBy(GetPluginOrderIndex).ThenBy(plugin => plugin.Name)) { + foreach (Plugin plugin in pluginManager.Plugins.OrderBy(GetPluginOrderIndex).ThenBy(static plugin => plugin.Name)) { flowLayoutPlugins.Controls.Add(new PluginControl(pluginManager, plugin)); flowLayoutPlugins.Controls.Add(new Panel { diff --git a/windows/TweetDuck/Dialogs/FormSettings.cs b/windows/TweetDuck/Dialogs/FormSettings.cs index c8e002b0..e9d6c4a1 100644 --- a/windows/TweetDuck/Dialogs/FormSettings.cs +++ b/windows/TweetDuck/Dialogs/FormSettings.cs @@ -24,7 +24,7 @@ sealed partial class FormSettings : Form, FormManager.IAppDialog { private readonly int buttonHeight; - private readonly Dictionary<Type, SettingsTab> tabs = new Dictionary<Type, SettingsTab>(8); + private readonly Dictionary<Type, SettingsTab> tabs = new (8); private SettingsTab? currentTab; public FormSettings(FormBrowser browser, PluginManager plugins, UpdateChecker updates, TweetDeckFunctions tweetDeckFunctions, Type? startTab) { @@ -44,8 +44,8 @@ public FormSettings(FormBrowser browser, PluginManager plugins, UpdateChecker up AddButton("General", () => new TabSettingsGeneral(this.browser.ReloadToTweetDeck, tweetDeckFunctions.ReloadColumns, updates)); AddButton("Notifications", () => new TabSettingsNotifications(this.browser.CreateExampleNotification())); AddButton("Sounds", () => new TabSettingsSounds(() => tweetDeckFunctions.PlaySoundNotification(true))); - AddButton("Tray", () => new TabSettingsTray()); - AddButton("Feedback", () => new TabSettingsFeedback()); + AddButton("Tray", static () => new TabSettingsTray()); + AddButton("Feedback", static () => new TabSettingsFeedback()); AddButton("Advanced", () => new TabSettingsAdvanced(tweetDeckFunctions.ReinjectCustomCSS, this.browser.OpenDevTools)); SelectTab(tabs[startTab ?? typeof(TabSettingsGeneral)]); @@ -135,7 +135,7 @@ private void AddButton<T>(string title, Func<T> constructor) where T : BaseTab { tabs.Add(typeof(T), new SettingsTab(btn, constructor)); - btn.Click += (sender, args) => SelectTab<T>(); + btn.Click += (_, _) => SelectTab<T>(); } private void SelectTab<T>() where T : BaseTab { diff --git a/windows/TweetDuck/Dialogs/Settings/DialogSettingsManage.cs b/windows/TweetDuck/Dialogs/Settings/DialogSettingsManage.cs index 6480db53..c3f8a296 100644 --- a/windows/TweetDuck/Dialogs/Settings/DialogSettingsManage.cs +++ b/windows/TweetDuck/Dialogs/Settings/DialogSettingsManage.cs @@ -31,7 +31,7 @@ private ProfileManager.Items SelectedItems { public bool ShouldReloadBrowser { get; private set; } private readonly PluginManager plugins; - private readonly Dictionary<CheckBox, ProfileManager.Items> checkBoxMap = new Dictionary<CheckBox, ProfileManager.Items>(4); + private readonly Dictionary<CheckBox, ProfileManager.Items> checkBoxMap = new (4); private readonly bool openImportImmediately; private State currentState; diff --git a/windows/TweetDuck/Dialogs/Settings/TabSettingsAdvanced.cs b/windows/TweetDuck/Dialogs/Settings/TabSettingsAdvanced.cs index 3a8d34cb..d72b019e 100644 --- a/windows/TweetDuck/Dialogs/Settings/TabSettingsAdvanced.cs +++ b/windows/TweetDuck/Dialogs/Settings/TabSettingsAdvanced.cs @@ -156,11 +156,11 @@ private void btnEditCefArgs_Click(object? sender, EventArgs e) { var parentForm = ParentForm ?? throw new InvalidOperationException("Dialog does not have a parent form!"); var form = new DialogSettingsCefArgs(Config.CustomCefArgs); - form.VisibleChanged += (sender2, args2) => { + form.VisibleChanged += (_, _) => { form.MoveToCenter(parentForm); }; - form.FormClosed += (sender2, args2) => { + form.FormClosed += (_, _) => { RestoreParentForm(); if (form.DialogResult == DialogResult.OK) { @@ -178,11 +178,11 @@ private void btnEditCSS_Click(object? sender, EventArgs e) { var parentForm = ParentForm ?? throw new InvalidOperationException("Dialog does not have a parent form!"); var form = new DialogSettingsCSS(Config.CustomBrowserCSS, Config.CustomNotificationCSS, reinjectBrowserCSS, openDevTools); - form.VisibleChanged += (sender2, args2) => { + form.VisibleChanged += (_, _) => { form.MoveToCenter(parentForm); }; - form.FormClosed += (sender2, args2) => { + form.FormClosed += (_, _) => { RestoreParentForm(); if (form.DialogResult == DialogResult.OK) { diff --git a/windows/TweetDuck/Dialogs/Settings/TabSettingsGeneral.cs b/windows/TweetDuck/Dialogs/Settings/TabSettingsGeneral.cs index 89356100..65d8c945 100644 --- a/windows/TweetDuck/Dialogs/Settings/TabSettingsGeneral.cs +++ b/windows/TweetDuck/Dialogs/Settings/TabSettingsGeneral.cs @@ -37,7 +37,7 @@ public TabSettingsGeneral(Action reloadTweetDeck, Action reloadColumns, UpdateCh this.updates = updates; this.updates.CheckFinished += updates_CheckFinished; - Disposed += (sender, args) => this.updates.CheckFinished -= updates_CheckFinished; + Disposed += (_, _) => this.updates.CheckFinished -= updates_CheckFinished; // user interface @@ -135,7 +135,7 @@ public TabSettingsGeneral(Action reloadTweetDeck, Action reloadColumns, UpdateCh daysOfWeek.Add(new DayOfWeekItem("Friday", DayOfWeek.Friday)); daysOfWeek.Add(new DayOfWeekItem("Saturday", DayOfWeek.Saturday)); daysOfWeek.Add(new DayOfWeekItem("Sunday", DayOfWeek.Sunday)); - comboBoxFirstDayOfWeek.SelectedItem = daysOfWeek.OfType<DayOfWeekItem>().FirstOrDefault(dow => dow.Id == Config.CalendarFirstDay) ?? daysOfWeek[0]; + comboBoxFirstDayOfWeek.SelectedItem = daysOfWeek.OfType<DayOfWeekItem>().FirstOrDefault(static dow => dow.Id == Config.CalendarFirstDay) ?? daysOfWeek[0]; } public override void OnReady() { @@ -219,7 +219,7 @@ private void checkHideTweetsByNftUsers_CheckedChanged(object? sender, EventArgs private void checkAnimatedAvatars_CheckedChanged(object? sender, EventArgs e) { Config.EnableAnimatedImages = checkAnimatedAvatars.Checked; - BrowserProcessHandler.UpdatePrefs().ContinueWith(task => reloadColumns()); + BrowserProcessHandler.UpdatePrefs().ContinueWith(_ => reloadColumns()); } #endregion @@ -241,11 +241,11 @@ private void updates_CheckFinished(object? sender, UpdateCheckEventArgs e) { if (e.EventId == updateCheckEventId) { btnCheckUpdates.Enabled = true; - e.Result.Handle(update => { + e.Result.Handle(static update => { if (update.VersionTag == Program.VersionTag) { FormMessage.Information("No Updates Available", "Your version of TweetDuck is up to date.", FormMessage.OK); } - }, ex => { + }, static ex => { App.ErrorHandler.HandleException("Update Check Error", "An error occurred while checking for updates.", true, ex); }); } @@ -264,7 +264,7 @@ private void UpdateBrowserPathSelection() { comboBoxCustomBrowser.SelectedIndex = browserListIndexDefault; } else { - WindowsUtils.Browser? browserInfo = comboBoxCustomBrowser.Items.OfType<WindowsUtils.Browser>().FirstOrDefault(browser => browser.Path == Config.BrowserPath); + WindowsUtils.Browser? browserInfo = comboBoxCustomBrowser.Items.OfType<WindowsUtils.Browser>().FirstOrDefault(static browser => browser.Path == Config.BrowserPath); if (browserInfo == null || Config.BrowserPathArgs != null) { comboBoxCustomBrowser.SelectedIndex = browserListIndexCustom; @@ -368,7 +368,7 @@ private void UpdateSearchEngineSelection() { comboBoxSearchEngine.SelectedIndex = searchEngineIndexDefault; } else { - SearchEngine? engineInfo = comboBoxSearchEngine.Items.OfType<SearchEngine>().FirstOrDefault(engine => engine.Url == Config.SearchEngineUrl); + SearchEngine? engineInfo = comboBoxSearchEngine.Items.OfType<SearchEngine>().FirstOrDefault(static engine => engine.Url == Config.SearchEngineUrl); if (engineInfo == null) { comboBoxSearchEngine.SelectedIndex = searchEngineIndexCustom; diff --git a/windows/TweetDuck/Dialogs/Settings/TabSettingsNotifications.cs b/windows/TweetDuck/Dialogs/Settings/TabSettingsNotifications.cs index 94e95d13..273c8d85 100644 --- a/windows/TweetDuck/Dialogs/Settings/TabSettingsNotifications.cs +++ b/windows/TweetDuck/Dialogs/Settings/TabSettingsNotifications.cs @@ -15,7 +15,7 @@ public TabSettingsNotifications(FormNotificationExample notification) { this.notification = notification; - this.notification.Ready += (sender, args) => { + this.notification.Ready += (_, _) => { this.InvokeAsyncSafe(() => { this.notification.ShowExampleNotification(true); this.notification.Move += notification_Move; @@ -25,7 +25,7 @@ public TabSettingsNotifications(FormNotificationExample notification) { this.notification.Show(); - Disposed += (sender, args) => this.notification.Dispose(); + Disposed += (_, _) => this.notification.Dispose(); // general @@ -45,7 +45,7 @@ public TabSettingsNotifications(FormNotificationExample notification) { comboBoxIdlePause.Items.Add("1 minute"); comboBoxIdlePause.Items.Add("2 minutes"); comboBoxIdlePause.Items.Add("5 minutes"); - comboBoxIdlePause.SelectedIndex = Math.Max(0, Array.FindIndex(IdlePauseSeconds, val => val == Config.NotificationIdlePauseSeconds)); + comboBoxIdlePause.SelectedIndex = Math.Max(0, Array.FindIndex(IdlePauseSeconds, static val => val == Config.NotificationIdlePauseSeconds)); trackBarOpacity.SetValueSafe(Config.NotificationWindowOpacity); labelOpacityValue.Text = Config.NotificationWindowOpacity + "%"; diff --git a/windows/TweetDuck/Management/BrowserCache.cs b/windows/TweetDuck/Management/BrowserCache.cs index 26597084..ccf28660 100644 --- a/windows/TweetDuck/Management/BrowserCache.cs +++ b/windows/TweetDuck/Management/BrowserCache.cs @@ -14,7 +14,7 @@ static class BrowserCache { private static Timer? autoClearTimer; private static long CalculateCacheSize() { - return new DirectoryInfo(CacheFolder).EnumerateFiles().Select(file => { + return new DirectoryInfo(CacheFolder).EnumerateFiles().Select(static file => { try { return file.Length; } catch { @@ -37,7 +37,7 @@ public static void RefreshTimer() { autoClearTimer = null; } else if (shouldRun && autoClearTimer == null) { - autoClearTimer = new Timer(state => { + autoClearTimer = new Timer(static _ => { if (autoClearTimer != null) { try { if (CalculateCacheSize() >= Program.Config.System.ClearCacheThreshold * 1024L * 1024L) { diff --git a/windows/TweetDuck/Management/ClipboardManager.cs b/windows/TweetDuck/Management/ClipboardManager.cs index f170f5e3..07fab0d9 100644 --- a/windows/TweetDuck/Management/ClipboardManager.cs +++ b/windows/TweetDuck/Management/ClipboardManager.cs @@ -7,8 +7,8 @@ namespace TweetDuck.Management { static class ClipboardManager { - private static readonly Lazy<Regex> RegexStripHtmlStyles = new Lazy<Regex>(() => new Regex(@"\s?(?:style|class)="".*?"""), false); - private static readonly Lazy<Regex> RegexOffsetClipboardHtml = new Lazy<Regex>(() => new Regex(@"(?<=EndHTML:|EndFragment:)(\d+)"), false); + private static readonly Lazy<Regex> RegexStripHtmlStyles = new (static () => new Regex(@"\s?(?:style|class)="".*?"""), false); + private static readonly Lazy<Regex> RegexOffsetClipboardHtml = new (static () => new Regex(@"(?<=EndHTML:|EndFragment:)(\d+)"), false); public static void SetText(string text, TextDataFormat format) { if (string.IsNullOrEmpty(text)) { diff --git a/windows/TweetDuck/Management/LockManager.cs b/windows/TweetDuck/Management/LockManager.cs index 1b9c796f..e57ec4c2 100644 --- a/windows/TweetDuck/Management/LockManager.cs +++ b/windows/TweetDuck/Management/LockManager.cs @@ -127,7 +127,7 @@ private static bool CloseProcess(Process process) { else { return false; } - } catch (Exception ex) when (ex is InvalidOperationException || ex is Win32Exception) { + } catch (Exception ex) when (ex is InvalidOperationException or Win32Exception) { bool hasExited = CheckProcessExited(process); process.Dispose(); return hasExited; diff --git a/windows/TweetDuck/Management/ProfileManager.cs b/windows/TweetDuck/Management/ProfileManager.cs index 7713fbe6..ebef2a99 100644 --- a/windows/TweetDuck/Management/ProfileManager.cs +++ b/windows/TweetDuck/Management/ProfileManager.cs @@ -176,7 +176,7 @@ public bool Import(Items items) { Expires = DateTime.Now.Add(TimeSpan.FromDays(365 * 5)), HttpOnly = true, Secure = true - }).ContinueWith(t => { + }).ContinueWith(_ => { // ReSharper disable once AccessToDisposedClosure // ReSharper disable once ConvertToLambdaExpression return cookies.FlushStoreAsync(); diff --git a/windows/TweetDuck/Program.cs b/windows/TweetDuck/Program.cs index 867ceb3d..7e32e8cc 100644 --- a/windows/TweetDuck/Program.cs +++ b/windows/TweetDuck/Program.cs @@ -135,7 +135,7 @@ public void Launch(ResourceCache resourceCache, PluginManager pluginManager) { Cef.Initialize(settings, false, new BrowserProcessHandler()); - Win.Application.ApplicationExit += (sender, args) => ExitCleanup(); + Win.Application.ApplicationExit += static (_, _) => ExitCleanup(); var updateCheckClient = new UpdateCheckClient(Path.Combine(storagePath, InstallerFolder)); var mainForm = new FormBrowser(resourceCache, pluginManager, updateCheckClient, lockManager.WindowRestoreMessage); Win.Application.Run(mainForm); diff --git a/windows/TweetDuck/Reporter.cs b/windows/TweetDuck/Reporter.cs index 25bd9f88..e5262c2a 100644 --- a/windows/TweetDuck/Reporter.cs +++ b/windows/TweetDuck/Reporter.cs @@ -47,7 +47,7 @@ public void HandleException(string caption, string message, bool canIgnore, Exce UseVisualStyleBackColor = true }; - btnOpenLog.Click += (sender, args) => { + btnOpenLog.Click += static (_, _) => { if (!OpenLogFile()) { FormMessage.Error("Error Log", "Cannot open error log.", FormMessage.OK); } diff --git a/windows/TweetDuck/TweetDuck.csproj b/windows/TweetDuck/TweetDuck.csproj index 2079a54b..7f86448d 100644 --- a/windows/TweetDuck/TweetDuck.csproj +++ b/windows/TweetDuck/TweetDuck.csproj @@ -5,7 +5,7 @@ <Configurations>Debug;Release</Configurations> <Platforms>x86</Platforms> <RuntimeIdentifier>win7-x86</RuntimeIdentifier> - <LangVersion>8.0</LangVersion> + <LangVersion>10</LangVersion> <Nullable>enable</Nullable> </PropertyGroup> diff --git a/windows/TweetDuck/Utils/BrowserUtils.cs b/windows/TweetDuck/Utils/BrowserUtils.cs index 92c778f6..709e341d 100644 --- a/windows/TweetDuck/Utils/BrowserUtils.cs +++ b/windows/TweetDuck/Utils/BrowserUtils.cs @@ -50,7 +50,7 @@ public static void SetupDockOnLoad(IBrowserComponent browserComponent, ChromiumW browser.Dock = DockStyle.None; browser.Location = ControlExtensions.InvisibleLocation; - browserComponent.BrowserLoaded += (sender, args) => { + browserComponent.BrowserLoaded += (_, _) => { browser.InvokeAsyncSafe(() => { browser.Location = Point.Empty; browser.Dock = DockStyle.Fill; @@ -68,9 +68,9 @@ void UpdateZoomLevel(object? sender, EventArgs args) { } Config.ZoomLevelChanged += UpdateZoomLevel; - browser.Disposed += (sender, args) => Config.ZoomLevelChanged -= UpdateZoomLevel; + browser.Disposed += (_, _) => Config.ZoomLevelChanged -= UpdateZoomLevel; - browser.FrameLoadStart += (sender, args) => { + browser.FrameLoadStart += static (_, args) => { if (args.Frame.IsMain && Config.ZoomLevel != 100) { SetZoomLevel(args.Browser.GetHost(), Config.ZoomLevel); } diff --git a/windows/TweetDuck/Utils/NativeMethods.cs b/windows/TweetDuck/Utils/NativeMethods.cs index 2315a358..9adee06e 100644 --- a/windows/TweetDuck/Utils/NativeMethods.cs +++ b/windows/TweetDuck/Utils/NativeMethods.cs @@ -8,8 +8,8 @@ namespace TweetDuck.Utils { [SuppressMessage("ReSharper", "MemberCanBePrivate.Local")] [SuppressMessage("ReSharper", "InconsistentNaming")] static class NativeMethods { - private static readonly IntPtr HWND_BROADCAST = new IntPtr(0xFFFF); - public static readonly IntPtr HOOK_HANDLED = new IntPtr(-1); + private static readonly IntPtr HWND_BROADCAST = new (0xFFFF); + public static readonly IntPtr HOOK_HANDLED = new (-1); public const int HWND_TOPMOST = -1; public const uint SWP_NOACTIVATE = 0x0010; diff --git a/windows/TweetImpl.CefSharp/Adapters/CefAdapter.cs b/windows/TweetImpl.CefSharp/Adapters/CefAdapter.cs index 1dbd2804..59a74144 100644 --- a/windows/TweetImpl.CefSharp/Adapters/CefAdapter.cs +++ b/windows/TweetImpl.CefSharp/Adapters/CefAdapter.cs @@ -4,7 +4,7 @@ namespace TweetImpl.CefSharp.Adapters { sealed class CefAdapter : ICefAdapter { - public static CefAdapter Instance { get; } = new CefAdapter(); + public static CefAdapter Instance { get; } = new (); private CefAdapter() {} diff --git a/windows/TweetImpl.CefSharp/Adapters/CefDragDataAdapter.cs b/windows/TweetImpl.CefSharp/Adapters/CefDragDataAdapter.cs index bd3d17bb..fbe000df 100644 --- a/windows/TweetImpl.CefSharp/Adapters/CefDragDataAdapter.cs +++ b/windows/TweetImpl.CefSharp/Adapters/CefDragDataAdapter.cs @@ -3,7 +3,7 @@ namespace TweetImpl.CefSharp.Adapters { sealed class CefDragDataAdapter : IDragDataAdapter<IDragData> { - public static CefDragDataAdapter Instance { get; } = new CefDragDataAdapter(); + public static CefDragDataAdapter Instance { get; } = new (); private CefDragDataAdapter() {} diff --git a/windows/TweetImpl.CefSharp/Adapters/CefErrorCodeAdapter.cs b/windows/TweetImpl.CefSharp/Adapters/CefErrorCodeAdapter.cs index f63ff5d6..c26024a5 100644 --- a/windows/TweetImpl.CefSharp/Adapters/CefErrorCodeAdapter.cs +++ b/windows/TweetImpl.CefSharp/Adapters/CefErrorCodeAdapter.cs @@ -4,7 +4,7 @@ namespace TweetImpl.CefSharp.Adapters { sealed class CefErrorCodeAdapter : IErrorCodeAdapter<CefErrorCode> { - public static CefErrorCodeAdapter Instance { get; } = new CefErrorCodeAdapter(); + public static CefErrorCodeAdapter Instance { get; } = new (); private CefErrorCodeAdapter() {} diff --git a/windows/TweetImpl.CefSharp/Adapters/CefFileDialogCallbackAdapter.cs b/windows/TweetImpl.CefSharp/Adapters/CefFileDialogCallbackAdapter.cs index e9b294cd..b3b93154 100644 --- a/windows/TweetImpl.CefSharp/Adapters/CefFileDialogCallbackAdapter.cs +++ b/windows/TweetImpl.CefSharp/Adapters/CefFileDialogCallbackAdapter.cs @@ -4,7 +4,7 @@ namespace TweetImpl.CefSharp.Adapters { sealed class CefFileDialogCallbackAdapter : IFileDialogCallbackAdapter<IFileDialogCallback> { - public static CefFileDialogCallbackAdapter Instance { get; } = new CefFileDialogCallbackAdapter(); + public static CefFileDialogCallbackAdapter Instance { get; } = new (); private CefFileDialogCallbackAdapter() {} diff --git a/windows/TweetImpl.CefSharp/Adapters/CefFrameAdapter.cs b/windows/TweetImpl.CefSharp/Adapters/CefFrameAdapter.cs index c1a2a091..2f70fd8c 100644 --- a/windows/TweetImpl.CefSharp/Adapters/CefFrameAdapter.cs +++ b/windows/TweetImpl.CefSharp/Adapters/CefFrameAdapter.cs @@ -3,7 +3,7 @@ namespace TweetImpl.CefSharp.Adapters { sealed class CefFrameAdapter : IFrameAdapter<IFrame> { - public static CefFrameAdapter Instance { get; } = new CefFrameAdapter(); + public static CefFrameAdapter Instance { get; } = new (); private CefFrameAdapter() {} diff --git a/windows/TweetImpl.CefSharp/Adapters/CefJsDialogCallbackAdapter.cs b/windows/TweetImpl.CefSharp/Adapters/CefJsDialogCallbackAdapter.cs index c0fbec2f..f9a8ef6c 100644 --- a/windows/TweetImpl.CefSharp/Adapters/CefJsDialogCallbackAdapter.cs +++ b/windows/TweetImpl.CefSharp/Adapters/CefJsDialogCallbackAdapter.cs @@ -3,7 +3,7 @@ namespace TweetImpl.CefSharp.Adapters { sealed class CefJsDialogCallbackAdapter : IJsDialogCallbackAdapter<IJsDialogCallback> { - public static CefJsDialogCallbackAdapter Instance { get; } = new CefJsDialogCallbackAdapter(); + public static CefJsDialogCallbackAdapter Instance { get; } = new (); private CefJsDialogCallbackAdapter() {} diff --git a/windows/TweetImpl.CefSharp/Adapters/CefMenuModelAdapter.cs b/windows/TweetImpl.CefSharp/Adapters/CefMenuModelAdapter.cs index 03b300eb..3a117777 100644 --- a/windows/TweetImpl.CefSharp/Adapters/CefMenuModelAdapter.cs +++ b/windows/TweetImpl.CefSharp/Adapters/CefMenuModelAdapter.cs @@ -3,7 +3,7 @@ namespace TweetImpl.CefSharp.Adapters { sealed class CefMenuModelAdapter : IMenuModelAdapter<IMenuModel> { - public static CefMenuModelAdapter Instance { get; } = new CefMenuModelAdapter(); + public static CefMenuModelAdapter Instance { get; } = new (); private CefMenuModelAdapter() {} diff --git a/windows/TweetImpl.CefSharp/Adapters/CefRequestAdapter.cs b/windows/TweetImpl.CefSharp/Adapters/CefRequestAdapter.cs index 6e9edce7..1e946d82 100644 --- a/windows/TweetImpl.CefSharp/Adapters/CefRequestAdapter.cs +++ b/windows/TweetImpl.CefSharp/Adapters/CefRequestAdapter.cs @@ -3,7 +3,7 @@ namespace TweetImpl.CefSharp.Adapters { sealed class CefRequestAdapter : IRequestAdapter<IRequest> { - public static CefRequestAdapter Instance { get; } = new CefRequestAdapter(); + public static CefRequestAdapter Instance { get; } = new (); private CefRequestAdapter() {} diff --git a/windows/TweetImpl.CefSharp/Adapters/CefResponseAdapter.cs b/windows/TweetImpl.CefSharp/Adapters/CefResponseAdapter.cs index a655dd71..2b4ef459 100644 --- a/windows/TweetImpl.CefSharp/Adapters/CefResponseAdapter.cs +++ b/windows/TweetImpl.CefSharp/Adapters/CefResponseAdapter.cs @@ -3,7 +3,7 @@ namespace TweetImpl.CefSharp.Adapters { sealed class CefResponseAdapter : IResponseAdapter<IResponse> { - public static CefResponseAdapter Instance { get; } = new CefResponseAdapter(); + public static CefResponseAdapter Instance { get; } = new (); private CefResponseAdapter() {} diff --git a/windows/TweetImpl.CefSharp/Component/BrowserComponentBase.cs b/windows/TweetImpl.CefSharp/Component/BrowserComponentBase.cs index ac69f118..b0e8ed20 100644 --- a/windows/TweetImpl.CefSharp/Component/BrowserComponentBase.cs +++ b/windows/TweetImpl.CefSharp/Component/BrowserComponentBase.cs @@ -12,7 +12,7 @@ namespace TweetImpl.CefSharp.Component { public abstract class BrowserComponentBase : BrowserComponent<IFrame, IRequest> { public delegate CefContextMenuHandler CreateContextMenu(IContextMenuHandler? handler); - public ResourceHandlerRegistry<IResourceHandler> ResourceHandlerRegistry { get; } = new ResourceHandlerRegistry<IResourceHandler>(CefResourceHandlerFactory.Instance); + public ResourceHandlerRegistry<IResourceHandler> ResourceHandlerRegistry { get; } = new (CefResourceHandlerFactory.Instance); private readonly ChromiumWebBrowser browser; private readonly CreateContextMenu createContextMenu; diff --git a/windows/TweetImpl.CefSharp/Dialogs/FileDialogOpener.cs b/windows/TweetImpl.CefSharp/Dialogs/FileDialogOpener.cs index b19998fc..16237b3d 100644 --- a/windows/TweetImpl.CefSharp/Dialogs/FileDialogOpener.cs +++ b/windows/TweetImpl.CefSharp/Dialogs/FileDialogOpener.cs @@ -7,7 +7,7 @@ namespace TweetImpl.CefSharp.Dialogs { sealed class FileDialogOpener : IFileDialogOpener { - public static FileDialogOpener Instance { get; } = new FileDialogOpener(); + public static FileDialogOpener Instance { get; } = new (); private FileDialogOpener() {} @@ -17,7 +17,7 @@ public void OpenFile(string title, bool multiple, List<FileDialogFilter> filters DereferenceLinks = true, Multiselect = multiple, Title = title, - Filter = string.Join("|", filters.Select(filter => filter.JoinFullNameAndPattern("|"))) + Filter = string.Join("|", filters.Select(static filter => filter.JoinFullNameAndPattern("|"))) }; if (dialog.ShowDialog() == DialogResult.OK) { diff --git a/windows/TweetImpl.CefSharp/Handlers/CefByteArrayResourceHandler.cs b/windows/TweetImpl.CefSharp/Handlers/CefByteArrayResourceHandler.cs index 79a28fd0..ec37362e 100644 --- a/windows/TweetImpl.CefSharp/Handlers/CefByteArrayResourceHandler.cs +++ b/windows/TweetImpl.CefSharp/Handlers/CefByteArrayResourceHandler.cs @@ -8,7 +8,7 @@ namespace TweetImpl.CefSharp.Handlers { public sealed class CefByteArrayResourceHandler : IResourceHandler { - private static readonly ByteArrayResourceHandlerLogic.WriteToOut<Stream> WriteToOut = delegate (Stream dataOut, byte[] dataIn, int position, int length) { + private static readonly ByteArrayResourceHandlerLogic.WriteToOut<Stream> WriteToOut = static delegate (Stream dataOut, byte[] dataIn, int position, int length) { dataOut.Write(dataIn, position, length); }; diff --git a/windows/TweetImpl.CefSharp/Handlers/CefResourceHandlerFactory.cs b/windows/TweetImpl.CefSharp/Handlers/CefResourceHandlerFactory.cs index bbcffcbe..d78c057c 100644 --- a/windows/TweetImpl.CefSharp/Handlers/CefResourceHandlerFactory.cs +++ b/windows/TweetImpl.CefSharp/Handlers/CefResourceHandlerFactory.cs @@ -4,7 +4,7 @@ namespace TweetImpl.CefSharp.Handlers { sealed class CefResourceHandlerFactory : IResourceHandlerFactory<IResourceHandler> { - public static CefResourceHandlerFactory Instance { get; } = new CefResourceHandlerFactory(); + public static CefResourceHandlerFactory Instance { get; } = new (); private CefResourceHandlerFactory() {} diff --git a/windows/TweetImpl.CefSharp/TweetImpl.CefSharp.csproj b/windows/TweetImpl.CefSharp/TweetImpl.CefSharp.csproj index b916b4c6..f1323170 100644 --- a/windows/TweetImpl.CefSharp/TweetImpl.CefSharp.csproj +++ b/windows/TweetImpl.CefSharp/TweetImpl.CefSharp.csproj @@ -5,7 +5,7 @@ <Configurations>Debug;Release</Configurations> <Platforms>x86</Platforms> <RuntimeIdentifier>win7-x86</RuntimeIdentifier> - <LangVersion>8.0</LangVersion> + <LangVersion>10</LangVersion> <Nullable>enable</Nullable> </PropertyGroup>