From a807aa9e12f86c03d3e0c3ffca969184e7287f14 Mon Sep 17 00:00:00 2001 From: leo Date: Sun, 14 Jul 2024 15:55:15 +0800 Subject: [PATCH] code_style: remove all IDE warnings --- src/App.axaml.cs | 10 +- src/Commands/CompareRevisions.cs | 5 +- src/Resources/Styles.axaml | 16 ++ src/ViewModels/ChangeTreeNode.cs | 145 +++++++++++++ src/ViewModels/Preference.cs | 12 +- src/ViewModels/RevisionFileTreeNode.cs | 32 +++ src/Views/About.axaml | 1 - src/Views/About.axaml.cs | 16 +- src/Views/AddRemote.axaml | 4 +- src/Views/AddRemote.axaml.cs | 16 +- src/Views/AddSubmodule.axaml | 2 - src/Views/AddWorktree.axaml | 3 - src/Views/AddWorktree.axaml.cs | 4 +- src/Views/Apply.axaml | 3 +- src/Views/Apply.axaml.cs | 13 +- src/Views/Archive.axaml | 6 +- src/Views/Archive.axaml.cs | 16 +- src/Views/Askpass.axaml | 1 - src/Views/Askpass.axaml.cs | 8 +- src/Views/AssumeUnchangedManager.axaml.cs | 4 +- src/Views/AutoFocusBehaviour.cs | 10 +- src/Views/Avatar.cs | 6 +- src/Views/Blame.axaml | 3 - src/Views/Blame.axaml.cs | 52 ++--- src/Views/BranchCompare.axaml | 2 - src/Views/BranchCompare.axaml.cs | 15 +- src/Views/BranchTree.axaml.cs | 2 +- src/Views/CaptionButtons.axaml | 3 - src/Views/CaptionButtons.axaml.cs | 6 +- src/Views/CaptionButtonsMacOS.axaml.cs | 6 +- src/Views/ChangeCollectionView.axaml | 10 +- src/Views/ChangeCollectionView.axaml.cs | 198 +++--------------- src/Views/ChangeStatusIcon.cs | 2 +- src/Views/ChangeViewModeSwitcher.axaml | 1 - src/Views/CherryPick.axaml | 5 +- src/Views/Cleanup.axaml | 2 - src/Views/Clone.axaml.cs | 11 +- src/Views/CommitBaseInfo.axaml.cs | 8 +- src/Views/CommitChanges.axaml | 1 - src/Views/CommitChanges.axaml.cs | 12 +- src/Views/CommitMessageTextBox.axaml.cs | 4 +- src/Views/CreateBranch.axaml | 4 +- src/Views/DeleteMultipleBranches.axaml | 3 - src/Views/DeleteSubmodule.axaml | 4 +- src/Views/DeleteTag.axaml | 4 +- src/Views/EditRemote.axaml | 4 +- src/Views/EditRemote.axaml.cs | 11 +- src/Views/FastForwardWithoutCheckout.axaml | 1 - src/Views/Fetch.axaml | 5 +- src/Views/FileHistories.axaml.cs | 15 +- src/Views/GitFlowFinish.axaml | 6 +- src/Views/GitFlowStart.axaml | 2 - src/Views/Histories.axaml | 4 +- src/Views/Histories.axaml.cs | 25 +-- src/Views/Hotkeys.axaml.cs | 4 +- src/Views/ImageDiffView.axaml | 12 +- src/Views/ImageDiffView.axaml.cs | 16 +- src/Views/InitGitFlow.axaml | 2 - src/Views/InteractiveRebase.axaml.cs | 15 +- src/Views/LFSLocks.axaml | 1 - src/Views/LFSLocks.axaml.cs | 4 +- src/Views/LFSTrackCustomPattern.axaml | 2 - src/Views/Launcher.axaml.cs | 49 +++-- src/Views/LauncherTabBar.axaml | 2 - src/Views/LauncherTabBar.axaml.cs | 62 +++--- src/Views/LoadingIcon.axaml | 1 - src/Views/LoadingIcon.axaml.cs | 7 +- src/Views/NameHighlightedTextBlock.cs | 11 +- src/Views/PopupRunningStatus.axaml | 10 +- src/Views/PopupRunningStatus.axaml.cs | 15 +- src/Views/Preference.axaml | 48 ++--- src/Views/Preference.axaml.cs | 21 +- src/Views/Pull.axaml | 5 +- src/Views/Push.axaml | 5 +- src/Views/PushTag.axaml | 5 +- src/Views/RemoveWorktree.axaml | 3 - src/Views/RenameBranch.axaml | 6 +- src/Views/Repository.axaml | 19 +- src/Views/Repository.axaml.cs | 75 +++---- src/Views/RepositoryConfigure.axaml | 6 +- src/Views/Revert.axaml | 5 +- src/Views/RevisionCompare.axaml | 2 +- src/Views/RevisionFileTreeView.axaml | 2 +- src/Views/RevisionFileTreeView.axaml.cs | 110 ++++------ src/Views/RevisionFiles.axaml.cs | 26 +-- src/Views/SelfUpdate.axaml.cs | 12 +- ...ml => StandaloneCommitMessageEditor.axaml} | 3 +- ...=> StandaloneCommitMessageEditor.axaml.cs} | 17 +- src/Views/StashChanges.axaml | 9 +- src/Views/StashesPage.axaml | 3 +- src/Views/Statistics.axaml.cs | 10 +- src/Views/TextDiffView.axaml.cs | 130 ++++++------ src/Views/Welcome.axaml.cs | 85 ++++---- src/Views/WorkingCopy.axaml.cs | 8 +- 94 files changed, 785 insertions(+), 807 deletions(-) create mode 100644 src/ViewModels/ChangeTreeNode.cs create mode 100644 src/ViewModels/RevisionFileTreeNode.cs rename src/Views/{CodeEditor.axaml => StandaloneCommitMessageEditor.axaml} (95%) rename src/Views/{CodeEditor.axaml.cs => StandaloneCommitMessageEditor.axaml.cs} (68%) diff --git a/src/App.axaml.cs b/src/App.axaml.cs index db3c12a0..50a51207 100644 --- a/src/App.axaml.cs +++ b/src/App.axaml.cs @@ -5,7 +5,6 @@ using System.Net.Http; using System.Reflection; using System.Text; using System.Text.Json; -using System.Text.RegularExpressions; using System.Threading.Tasks; using System.Windows.Input; @@ -45,12 +44,12 @@ namespace SourceGit [STAThread] public static void Main(string[] args) { - AppDomain.CurrentDomain.UnhandledException += (sender, e) => + AppDomain.CurrentDomain.UnhandledException += (_, e) => { LogException(e.ExceptionObject as Exception); }; - TaskScheduler.UnobservedTaskException += (sender, e) => + TaskScheduler.UnobservedTaskException += (_, e) => { LogException(e.Exception); e.SetObserved(); @@ -333,7 +332,8 @@ namespace SourceGit private static void LogException(Exception ex) { - if (ex == null) return; + if (ex == null) + return; var builder = new StringBuilder(); builder.Append($"Crash::: {ex.GetType().FullName}: {ex.Message}\n\n"); @@ -467,7 +467,7 @@ namespace SourceGit if (!File.Exists(file)) Environment.Exit(-1); - desktop.MainWindow = new Views.CodeEditor(file); + desktop.MainWindow = new Views.StandaloneCommitMessageEditor(file); return true; } diff --git a/src/Commands/CompareRevisions.cs b/src/Commands/CompareRevisions.cs index a9efb36c..860cd34a 100644 --- a/src/Commands/CompareRevisions.cs +++ b/src/Commands/CompareRevisions.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Text.RegularExpressions; namespace SourceGit.Commands @@ -18,7 +19,7 @@ namespace SourceGit.Commands public List Result() { Exec(); - _changes.Sort((l, r) => l.Path.CompareTo(r.Path)); + _changes.Sort((l, r) => string.Compare(l.Path, r.Path, StringComparison.Ordinal)); return _changes; } diff --git a/src/Resources/Styles.axaml b/src/Resources/Styles.axaml index 27f858a0..346c8f1c 100644 --- a/src/Resources/Styles.axaml +++ b/src/Resources/Styles.axaml @@ -169,6 +169,9 @@ + + + +