1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-04-23 12:15:48 +02:00

Update all projects to C# 10

This commit is contained in:
chylex 2022-07-02 20:35:40 +02:00
parent bee894bfbb
commit b5bffdb95b
Signed by: chylex
GPG Key ID: 4DE42C8F19A80548
59 changed files with 116 additions and 117 deletions

View File

@ -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

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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; }

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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();

View File

@ -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");

View File

@ -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>

View File

@ -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) {

View File

@ -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();
}

View File

@ -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);

View File

@ -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;
};

View File

@ -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() {}

View File

@ -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();

View File

@ -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();

View File

@ -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);
};

View File

@ -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) {

View File

@ -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;

View File

@ -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) {

View File

@ -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
}
}

View File

@ -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));

View File

@ -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;
}
}
}

View File

@ -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; }");
}

View File

@ -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;

View File

@ -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;

View File

@ -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();
};

View File

@ -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;
}

View File

@ -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 {

View File

@ -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 {

View File

@ -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;

View File

@ -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) {

View File

@ -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;

View File

@ -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 + "%";

View File

@ -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) {

View File

@ -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)) {

View File

@ -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;

View File

@ -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();

View File

@ -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);

View File

@ -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);
}

View File

@ -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>

View File

@ -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);
}

View File

@ -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;

View File

@ -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() {}

View File

@ -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() {}

View File

@ -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() {}

View File

@ -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() {}

View File

@ -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() {}

View File

@ -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() {}

View File

@ -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() {}

View File

@ -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() {}

View File

@ -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() {}

View File

@ -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;

View File

@ -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) {

View File

@ -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);
};

View File

@ -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() {}

View File

@ -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>