diff --git a/src/App.Commands.cs b/src/App.Commands.cs index f26919c73..df0b96fb1 100644 --- a/src/App.Commands.cs +++ b/src/App.Commands.cs @@ -22,7 +22,7 @@ public Command(Action action) public bool CanExecute(object parameter) => _action != null; public void Execute(object parameter) => _action?.Invoke(parameter); - private Action _action = null; + private readonly Action _action; } public static bool IsCheckForUpdateCommandVisible diff --git a/src/App.axaml.cs b/src/App.axaml.cs index f5c0559a1..b962bae91 100644 --- a/src/App.axaml.cs +++ b/src/App.axaml.cs @@ -703,10 +703,10 @@ private string FixFontFamilyName(string input) [GeneratedRegex(@"^[a-z]+\s+([a-fA-F0-9]{4,40})(\s+.*)?$")] private static partial Regex REG_REBASE_TODO(); - private Models.IpcChannel _ipcChannel = null; - private ViewModels.Launcher _launcher = null; - private ResourceDictionary _activeLocale = null; - private ResourceDictionary _themeOverrides = null; - private ResourceDictionary _fontsOverrides = null; + private Models.IpcChannel _ipcChannel; + private ViewModels.Launcher _launcher; + private ResourceDictionary _activeLocale; + private ResourceDictionary _themeOverrides; + private ResourceDictionary _fontsOverrides; } } diff --git a/src/Commands/Blame.cs b/src/Commands/Blame.cs index bd2c6df84..de038b42a 100644 --- a/src/Commands/Blame.cs +++ b/src/Commands/Blame.cs @@ -90,7 +90,7 @@ private void ParseLine(string line) private readonly StringBuilder _content = new StringBuilder(); private readonly string _dateFormat = Models.DateTimeFormat.Active.DateOnly; private string _lastSHA = string.Empty; - private bool _needUnifyCommitSHA = false; + private bool _needUnifyCommitSHA; private int _minSHALen = 64; } } diff --git a/src/Commands/Command.cs b/src/Commands/Command.cs index f54d24b22..2f7ab25dc 100644 --- a/src/Commands/Command.cs +++ b/src/Commands/Command.cs @@ -12,7 +12,7 @@ public partial class Command { public class Result { - public bool IsSuccess { get; set; } = false; + public bool IsSuccess { get; set; } public string StdOut { get; set; } = string.Empty; public string StdErr { get; set; } = string.Empty; @@ -27,7 +27,7 @@ public enum EditorType } public string Context { get; set; } = string.Empty; - public string WorkingDirectory { get; set; } = null; + public string WorkingDirectory { get; set; } public EditorType Editor { get; set; } = EditorType.CoreEditor; public string SSHKey { get; set; } = string.Empty; public string Args { get; set; } = string.Empty; @@ -35,7 +35,7 @@ public enum EditorType // Only used in `ExecAsync` mode. public CancellationToken CancellationToken { get; set; } = CancellationToken.None; public bool RaiseError { get; set; } = true; - public Models.ICommandLog Log { get; set; } = null; + public Models.ICommandLog Log { get; set; } public void Exec() { diff --git a/src/Commands/Config.cs b/src/Commands/Config.cs index 84858454a..26ddf7268 100644 --- a/src/Commands/Config.cs +++ b/src/Commands/Config.cs @@ -60,6 +60,6 @@ public async Task SetAsync(string key, string value, bool allowEmpty = fal return await ExecAsync().ConfigureAwait(false); } - private bool _isLocal = false; + private readonly bool _isLocal; } } diff --git a/src/Commands/Diff.cs b/src/Commands/Diff.cs index 3eae1b54b..a94f7d3e6 100644 --- a/src/Commands/Diff.cs +++ b/src/Commands/Diff.cs @@ -262,8 +262,8 @@ private void ProcessInlineHighlights() private readonly Models.DiffResult _result = new Models.DiffResult(); private readonly List _deleted = new List(); private readonly List _added = new List(); - private Models.TextDiffLine _last = null; - private int _oldLine = 0; - private int _newLine = 0; + private Models.TextDiffLine _last; + private int _oldLine; + private int _newLine; } } diff --git a/src/Commands/QueryCommits.cs b/src/Commands/QueryCommits.cs index 9493b3399..ad1526f89 100644 --- a/src/Commands/QueryCommits.cs +++ b/src/Commands/QueryCommits.cs @@ -145,9 +145,9 @@ private async Task MarkFirstMergedAsync() } } - private List _commits = new List(); - private Models.Commit _current = null; - private bool _findFirstMerged = false; - private bool _isHeadFound = false; + private readonly List _commits = new List(); + private readonly bool _findFirstMerged; + private Models.Commit _current; + private bool _isHeadFound; } } diff --git a/src/Commands/QueryCommitsForInteractiveRebase.cs b/src/Commands/QueryCommitsForInteractiveRebase.cs index 81e28d4fc..ccb7e7b88 100644 --- a/src/Commands/QueryCommitsForInteractiveRebase.cs +++ b/src/Commands/QueryCommitsForInteractiveRebase.cs @@ -89,8 +89,8 @@ private void ParseParent(string data) _current.Commit.Parents.AddRange(data.Split(' ', StringSplitOptions.RemoveEmptyEntries)); } - private List _commits = []; - private Models.InteractiveCommit _current = null; + private readonly List _commits = []; private readonly string _boundary; + private Models.InteractiveCommit _current; } } diff --git a/src/Models/AvatarManager.cs b/src/Models/AvatarManager.cs index 65786e386..a3c0a916c 100644 --- a/src/Models/AvatarManager.cs +++ b/src/Models/AvatarManager.cs @@ -30,17 +30,17 @@ public static AvatarManager Instance } } - private static AvatarManager _instance = null; + private static AvatarManager _instance; [GeneratedRegex(@"^(?:(\d+)\+)?(.+?)@.+\.github\.com$")] private static partial Regex REG_GITHUB_USER_EMAIL(); private readonly Lock _synclock = new(); + private readonly List _avatars = new List(); + private readonly Dictionary _resources = new Dictionary(); + private readonly HashSet _requesting = new HashSet(); + private readonly HashSet _defaultAvatars = new HashSet(); private string _storePath; - private List _avatars = new List(); - private Dictionary _resources = new Dictionary(); - private HashSet _requesting = new HashSet(); - private HashSet _defaultAvatars = new HashSet(); public void Start() { diff --git a/src/Models/Blame.cs b/src/Models/Blame.cs index 3eb8d8bf3..ed869a92f 100644 --- a/src/Models/Blame.cs +++ b/src/Models/Blame.cs @@ -4,7 +4,7 @@ namespace SourceGit.Models { public class BlameLineInfo { - public bool IsFirstInGroup { get; set; } = false; + public bool IsFirstInGroup { get; set; } public string CommitSHA { get; set; } = string.Empty; public string Author { get; set; } = string.Empty; public string Time { get; set; } = string.Empty; @@ -15,6 +15,6 @@ public class BlameData public string File { get; set; } = string.Empty; public List LineInfos { get; set; } = new List(); public string Content { get; set; } = string.Empty; - public bool IsBinary { get; set; } = false; + public bool IsBinary { get; set; } } } diff --git a/src/Models/Change.cs b/src/Models/Change.cs index 2ad448add..c08866308 100644 --- a/src/Models/Change.cs +++ b/src/Models/Change.cs @@ -45,7 +45,7 @@ public class Change public ChangeState WorkTree { get; set; } = ChangeState.None; public string Path { get; set; } = ""; public string OriginalPath { get; set; } = ""; - public ChangeDataForAmend DataForAmend { get; set; } = null; + public ChangeDataForAmend DataForAmend { get; set; } public ConflictReason ConflictReason { get; set; } = ConflictReason.None; public bool IsConflicted => WorkTree == ChangeState.Conflicted; diff --git a/src/Models/Commit.cs b/src/Models/Commit.cs index ac38c2438..e6e483304 100644 --- a/src/Models/Commit.cs +++ b/src/Models/Commit.cs @@ -29,9 +29,9 @@ public static double OpacityForNotMerged public string SHA { get; set; } = string.Empty; public User Author { get; set; } = User.Invalid; - public ulong AuthorTime { get; set; } = 0; + public ulong AuthorTime { get; set; } public User Committer { get; set; } = User.Invalid; - public ulong CommitterTime { get; set; } = 0; + public ulong CommitterTime { get; set; } public string Subject { get; set; } = string.Empty; public List Parents { get; set; } = new(); public List Decorators { get; set; } = new(); @@ -42,11 +42,11 @@ public static double OpacityForNotMerged public string AuthorTimeShortStr => DateTime.UnixEpoch.AddSeconds(AuthorTime).ToLocalTime().ToString(DateTimeFormat.Active.DateOnly); public string CommitterTimeShortStr => DateTime.UnixEpoch.AddSeconds(CommitterTime).ToLocalTime().ToString(DateTimeFormat.Active.DateOnly); - public bool IsMerged { get; set; } = false; + public bool IsMerged { get; set; } public bool IsCommitterVisible => !Author.Equals(Committer) || AuthorTime != CommitterTime; public bool IsCurrentHead => Decorators.Find(x => x.Type is DecoratorType.CurrentBranchHead or DecoratorType.CurrentCommitHead) != null; - public int Color { get; set; } = 0; + public int Color { get; set; } public double Opacity => IsMerged ? 1 : OpacityForNotMerged; public FontWeight FontWeight => IsCurrentHead ? FontWeight.Bold : FontWeight.Regular; public Thickness Margin { get; set; } = new(0); diff --git a/src/Models/CommitGraph.cs b/src/Models/CommitGraph.cs index cb5696101..54a176c73 100644 --- a/src/Models/CommitGraph.cs +++ b/src/Models/CommitGraph.cs @@ -243,7 +243,7 @@ public void Recycle(int idx) _colorsQueue.Enqueue(idx); } - private Queue _colorsQueue = new Queue(); + private readonly Queue _colorsQueue = new Queue(); } private class PathHelper @@ -372,11 +372,11 @@ private void Add(double x, double y) } } - private double _lastY = 0; - private double _endY = 0; + private double _lastY; + private double _endY; } - private static int s_penCount = 0; + private static int s_penCount; private static readonly List s_defaultPenColors = [ Colors.Orange, Colors.ForestGreen, diff --git a/src/Models/CommitLink.cs b/src/Models/CommitLink.cs index 08caad8d1..c2a70fa37 100644 --- a/src/Models/CommitLink.cs +++ b/src/Models/CommitLink.cs @@ -5,8 +5,8 @@ namespace SourceGit.Models { public class CommitLink { - public string Name { get; set; } = null; - public string URLPrefix { get; set; } = null; + public string Name { get; set; } + public string URLPrefix { get; set; } public CommitLink(string name, string prefix) { diff --git a/src/Models/Count.cs b/src/Models/Count.cs index d48b0c083..ccc9ac4f5 100644 --- a/src/Models/Count.cs +++ b/src/Models/Count.cs @@ -4,7 +4,7 @@ namespace SourceGit.Models { public class Count : IDisposable { - public int Value { get; set; } = 0; + public int Value { get; set; } public Count(int value) { diff --git a/src/Models/CustomAction.cs b/src/Models/CustomAction.cs index 1ed65b8b3..71d835757 100644 --- a/src/Models/CustomAction.cs +++ b/src/Models/CustomAction.cs @@ -55,7 +55,7 @@ public bool BoolValue private string _label = string.Empty; private string _description = string.Empty; private string _stringValue = string.Empty; - private bool _boolValue = false; + private bool _boolValue; } public class CustomAction : ObservableObject diff --git a/src/Models/DateTimeFormat.cs b/src/Models/DateTimeFormat.cs index 16276c40c..a3e272413 100644 --- a/src/Models/DateTimeFormat.cs +++ b/src/Models/DateTimeFormat.cs @@ -23,7 +23,7 @@ public static int ActiveIndex { get; set; - } = 0; + } public static DateTimeFormat Active { diff --git a/src/Models/DiffOption.cs b/src/Models/DiffOption.cs index 37c89b72c..9084074fb 100644 --- a/src/Models/DiffOption.cs +++ b/src/Models/DiffOption.cs @@ -112,8 +112,8 @@ public override string ToString() return builder.ToString(); } - private readonly Change _workingCopyChange = null; - private readonly bool _isUnstaged = false; + private readonly Change _workingCopyChange; + private readonly bool _isUnstaged; private readonly string _path; private readonly string _orgPath = string.Empty; private readonly string _extra = string.Empty; diff --git a/src/Models/DiffResult.cs b/src/Models/DiffResult.cs index 95ffa99f1..2963336c7 100644 --- a/src/Models/DiffResult.cs +++ b/src/Models/DiffResult.cs @@ -26,10 +26,10 @@ public class TextDiffLine { public TextDiffLineType Type { get; set; } = TextDiffLineType.None; public string Content { get; set; } = ""; - public int OldLineNumber { get; set; } = 0; - public int NewLineNumber { get; set; } = 0; + public int OldLineNumber { get; set; } + public int NewLineNumber { get; set; } public List Highlights { get; set; } = new List(); - public bool NoNewLineEndOfFile { get; set; } = false; + public bool NoNewLineEndOfFile { get; set; } public string OldLine => OldLineNumber == 0 ? string.Empty : OldLineNumber.ToString(); public string NewLine => NewLineNumber == 0 ? string.Empty : NewLineNumber.ToString(); @@ -46,12 +46,12 @@ public TextDiffLine(TextDiffLineType type, string content, int oldLine, int newL public class TextDiffSelection { - public int StartLine { get; set; } = 0; - public int EndLine { get; set; } = 0; - public bool HasChanges { get; set; } = false; - public bool HasLeftChanges { get; set; } = false; - public int IgnoredAdds { get; set; } = 0; - public int IgnoredDeletes { get; set; } = 0; + public int StartLine { get; set; } + public int EndLine { get; set; } + public bool HasChanges { get; set; } + public bool HasLeftChanges { get; set; } + public int IgnoredAdds { get; set; } + public int IgnoredDeletes { get; set; } public bool IsInRange(int idx) { @@ -66,8 +66,8 @@ public partial class TextDiff public Vector ScrollOffset { get; set; } = Vector.Zero; public int MaxLineNumber = 0; - public string Repo { get; set; } = null; - public DiffOption Option { get; set; } = null; + public string Repo { get; set; } + public DiffOption Option { get; set; } public TextDiffSelection MakeSelection(int startLine, int endLine, bool isCombined, bool isOldSide) { @@ -612,17 +612,17 @@ public class LFSDiff public class BinaryDiff { - public long OldSize { get; set; } = 0; - public long NewSize { get; set; } = 0; + public long OldSize { get; set; } + public long NewSize { get; set; } } public class ImageDiff { - public Bitmap Old { get; set; } = null; - public Bitmap New { get; set; } = null; + public Bitmap Old { get; set; } + public Bitmap New { get; set; } - public long OldFileSize { get; set; } = 0; - public long NewFileSize { get; set; } = 0; + public long OldFileSize { get; set; } + public long NewFileSize { get; set; } public string OldImageSize => Old != null ? $"{Old.PixelSize.Width} x {Old.PixelSize.Height}" : "0 x 0"; public string NewImageSize => New != null ? $"{New.PixelSize.Width} x {New.PixelSize.Height}" : "0 x 0"; @@ -632,20 +632,20 @@ public class NoOrEOLChange; public class SubmoduleDiff { - public RevisionSubmodule Old { get; set; } = null; - public RevisionSubmodule New { get; set; } = null; + public RevisionSubmodule Old { get; set; } + public RevisionSubmodule New { get; set; } } public class DiffResult { - public bool IsBinary { get; set; } = false; - public bool IsLFS { get; set; } = false; + public bool IsBinary { get; set; } + public bool IsLFS { get; set; } public string OldHash { get; set; } = string.Empty; public string NewHash { get; set; } = string.Empty; public string OldMode { get; set; } = string.Empty; public string NewMode { get; set; } = string.Empty; - public TextDiff TextDiff { get; set; } = null; - public LFSDiff LFSDiff { get; set; } = null; + public TextDiff TextDiff { get; set; } + public LFSDiff LFSDiff { get; set; } public string FileModeChange { diff --git a/src/Models/ExternalTool.cs b/src/Models/ExternalTool.cs index 1ccacd358..f7133529e 100644 --- a/src/Models/ExternalTool.cs +++ b/src/Models/ExternalTool.cs @@ -13,7 +13,7 @@ namespace SourceGit.Models public class ExternalTool { public string Name { get; private set; } - public Bitmap IconImage { get; private set; } = null; + public Bitmap IconImage { get; private set; } public ExternalTool(string name, string icon, string execFile, Func execArgsGenerator = null) { @@ -44,14 +44,14 @@ public void Open(string repo) }); } - private string _execFile = string.Empty; - private Func _execArgsGenerator = null; + private readonly string _execFile = string.Empty; + private readonly Func _execArgsGenerator; } public class JetBrainsState { [JsonPropertyName("version")] - public int Version { get; set; } = 0; + public int Version { get; set; } [JsonPropertyName("appVersion")] public string AppVersion { get; set; } = string.Empty; [JsonPropertyName("tools")] @@ -184,6 +184,6 @@ public void FindJetBrainsFromToolbox(Func platformFinder) } } - private ExternalToolPaths _customPaths = null; + private readonly ExternalToolPaths _customPaths; } } diff --git a/src/Models/IpcChannel.cs b/src/Models/IpcChannel.cs index 001c65a65..ee5de5c91 100644 --- a/src/Models/IpcChannel.cs +++ b/src/Models/IpcChannel.cs @@ -93,8 +93,8 @@ private async void StartServer() } } - private FileStream _singletonLock = null; - private NamedPipeServerStream _server = null; - private CancellationTokenSource _cancellationTokenSource = null; + private readonly FileStream _singletonLock; + private readonly NamedPipeServerStream _server; + private readonly CancellationTokenSource _cancellationTokenSource; } } diff --git a/src/Models/IssueTrackerRule.cs b/src/Models/IssueTrackerRule.cs index 40bb295a3..fc9ced674 100644 --- a/src/Models/IssueTrackerRule.cs +++ b/src/Models/IssueTrackerRule.cs @@ -73,6 +73,6 @@ public void Matches(InlineElementCollector outs, string message) private string _name; private string _regexString; private string _urlTemplate; - private Regex _regex = null; + private Regex _regex; } } diff --git a/src/Models/LFSLock.cs b/src/Models/LFSLock.cs index 0a328cfb2..4c5127a83 100644 --- a/src/Models/LFSLock.cs +++ b/src/Models/LFSLock.cs @@ -4,6 +4,6 @@ public class LFSLock { public string File { get; set; } = string.Empty; public string User { get; set; } = string.Empty; - public long ID { get; set; } = 0; + public long ID { get; set; } } } diff --git a/src/Models/LFSObject.cs b/src/Models/LFSObject.cs index 8bc2dda28..b700c6261 100644 --- a/src/Models/LFSObject.cs +++ b/src/Models/LFSObject.cs @@ -8,7 +8,7 @@ public partial class LFSObject private static partial Regex REG_FORMAT(); public string Oid { get; set; } = string.Empty; - public long Size { get; set; } = 0; + public long Size { get; set; } public static LFSObject Parse(string content) { diff --git a/src/Models/Notification.cs b/src/Models/Notification.cs index 473947b0f..e511719e8 100644 --- a/src/Models/Notification.cs +++ b/src/Models/Notification.cs @@ -2,7 +2,7 @@ { public class Notification { - public bool IsError { get; set; } = false; + public bool IsError { get; set; } public string Message { get; set; } = string.Empty; } } diff --git a/src/Models/OpenAI.cs b/src/Models/OpenAI.cs index f8d76328d..e9c154176 100644 --- a/src/Models/OpenAI.cs +++ b/src/Models/OpenAI.cs @@ -91,10 +91,10 @@ private void OnReceive(string text) [GeneratedRegex(@"<(think|thought|thinking|thought_chain)>.*?", RegexOptions.Singleline)] private static partial Regex REG_COT(); - private Action _onUpdate = null; - private StringBuilder _thinkTail = new StringBuilder(); - private HashSet _thinkTags = ["think", "thought", "thinking", "thought_chain"]; - private bool _hasTrimmedStart = false; + private readonly Action _onUpdate; + private readonly StringBuilder _thinkTail = new StringBuilder(); + private readonly HashSet _thinkTags = ["think", "thought", "thinking", "thought_chain"]; + private bool _hasTrimmedStart; } public class OpenAIService : ObservableObject diff --git a/src/Models/RepositorySettings.cs b/src/Models/RepositorySettings.cs index 4e51b368a..14d7b5f2d 100644 --- a/src/Models/RepositorySettings.cs +++ b/src/Models/RepositorySettings.cs @@ -18,25 +18,25 @@ public bool EnableReflog { get; set; - } = false; + } public bool EnableFirstParentInHistories { get; set; - } = false; + } public bool EnableTopoOrderInHistories { get; set; - } = false; + } public bool OnlyHighlightCurrentBranchInHistories { get; set; - } = false; + } public BranchSortMode LocalBranchSortMode { @@ -66,13 +66,13 @@ public bool EnableForceOnFetch { get; set; - } = false; + } public bool FetchWithoutTags { get; set; - } = false; + } public bool PreferRebaseInsteadOfMerge { @@ -90,7 +90,7 @@ public bool PushAllTags { get; set; - } = false; + } public bool PushToRemoteWhenCreateTag { @@ -102,7 +102,7 @@ public bool PushToRemoteWhenDeleteTag { get; set; - } = false; + } public bool CheckoutBranchOnCreateBranch { @@ -150,7 +150,7 @@ public bool EnableAutoFetch { get; set; - } = false; + } public int AutoFetchInterval { @@ -162,7 +162,7 @@ public bool EnableSignOffForCommit { get; set; - } = false; + } public bool IncludeUntrackedWhenStash { @@ -174,13 +174,13 @@ public bool OnlyStagedWhenStash { get; set; - } = false; + } public int ChangesAfterStashing { get; set; - } = 0; + } public string PreferredOpenAIService { @@ -198,25 +198,25 @@ public bool IsRemotesExpandedInSideBar { get; set; - } = false; + } public bool IsTagsExpandedInSideBar { get; set; - } = false; + } public bool IsSubmodulesExpandedInSideBar { get; set; - } = false; + } public bool IsWorktreeExpandedInSideBar { get; set; - } = false; + } public List ExpandedBranchNodesInSideBar { @@ -228,7 +228,7 @@ public int PreferredMergeMode { get; set; - } = 0; + } public string LastCommitMessage { diff --git a/src/Models/RevisionFile.cs b/src/Models/RevisionFile.cs index 29a23efa7..9f34f48a4 100644 --- a/src/Models/RevisionFile.cs +++ b/src/Models/RevisionFile.cs @@ -6,7 +6,7 @@ namespace SourceGit.Models { public class RevisionBinaryFile { - public long Size { get; set; } = 0; + public long Size { get; set; } } public class RevisionImageFile @@ -37,7 +37,7 @@ public class RevisionLFSObject public class RevisionSubmodule { - public Commit Commit { get; set; } = null; - public CommitFullMessage FullMessage { get; set; } = null; + public Commit Commit { get; set; } + public CommitFullMessage FullMessage { get; set; } } } diff --git a/src/Models/Stash.cs b/src/Models/Stash.cs index bc01e9db1..b1b063fbd 100644 --- a/src/Models/Stash.cs +++ b/src/Models/Stash.cs @@ -8,7 +8,7 @@ public class Stash public string Name { get; set; } = ""; public string SHA { get; set; } = ""; public List Parents { get; set; } = []; - public ulong Time { get; set; } = 0; + public ulong Time { get; set; } public string Message { get; set; } = ""; public string Subject diff --git a/src/Models/Statistics.cs b/src/Models/Statistics.cs index 700c9311b..777d78378 100644 --- a/src/Models/Statistics.cs +++ b/src/Models/Statistics.cs @@ -26,7 +26,7 @@ public class StatisticsAuthor(User user, int count) public class StatisticsReport { - public int Total { get; set; } = 0; + public int Total { get; set; } public List Authors { get; set; } = new(); public List Series { get; set; } = new(); public List XAxes { get; set; } = new(); @@ -171,11 +171,11 @@ public void ChangeAuthor(StatisticsAuthor author) } private static readonly string[] WEEKDAYS = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"]; - private StatisticsMode _mode; - private Dictionary _mapUsers = new(); - private Dictionary _mapSamples = new(); - private Dictionary> _mapUserSamples = new(); - private StatisticsAuthor _selectedAuthor = null; + private readonly StatisticsMode _mode; + private readonly Dictionary _mapUsers = new(); + private readonly Dictionary _mapSamples = new(); + private readonly Dictionary> _mapUserSamples = new(); + private StatisticsAuthor _selectedAuthor; private uint _fillColor = 255; } diff --git a/src/Models/Tag.cs b/src/Models/Tag.cs index 87944637a..3cbe55751 100644 --- a/src/Models/Tag.cs +++ b/src/Models/Tag.cs @@ -11,9 +11,9 @@ public enum TagSortMode public class Tag : ObservableObject { public string Name { get; set; } = string.Empty; - public bool IsAnnotated { get; set; } = false; + public bool IsAnnotated { get; set; } public string SHA { get; set; } = string.Empty; - public ulong CreatorDate { get; set; } = 0; + public ulong CreatorDate { get; set; } public string Message { get; set; } = string.Empty; public FilterMode FilterMode diff --git a/src/Models/TemplateEngine.cs b/src/Models/TemplateEngine.cs index 87822fb11..44381dbd1 100644 --- a/src/Models/TemplateEngine.cs +++ b/src/Models/TemplateEngine.cs @@ -342,7 +342,7 @@ private static string EvalVariable(Context context, RegexVariable variable) return variable.regex.Replace(str, variable.replacement); } - private int _pos = 0; + private int _pos; private char[] _chars = []; private readonly List _tokens = []; diff --git a/src/Models/Watcher.cs b/src/Models/Watcher.cs index 9ba7ee9cb..9d9fb46b8 100644 --- a/src/Models/Watcher.cs +++ b/src/Models/Watcher.cs @@ -275,17 +275,17 @@ private void HandleWorkingCopyFileChanged(string name) _updateWC = DateTime.Now.AddSeconds(1).ToFileTime(); } - private readonly IRepository _repo = null; - private List _watchers = []; - private Timer _timer = null; - private int _lockCount = 0; - private long _updateWC = 0; - private long _updateBranch = 0; - private long _updateSubmodules = 0; - private long _updateStashes = 0; - private long _updateTags = 0; + private readonly IRepository _repo; + private readonly List _watchers = []; + private Timer _timer; + private int _lockCount; + private long _updateWC; + private long _updateBranch; + private long _updateSubmodules; + private long _updateStashes; + private long _updateTags; private readonly Lock _lockSubmodule = new(); - private List _submodules = new List(); + private readonly List _submodules = new List(); } } diff --git a/src/Models/Worktree.cs b/src/Models/Worktree.cs index 26f88a8a8..a036cad30 100644 --- a/src/Models/Worktree.cs +++ b/src/Models/Worktree.cs @@ -9,8 +9,8 @@ public class Worktree : ObservableObject public string FullPath { get; set; } = string.Empty; public string RelativePath { get; set; } = string.Empty; public string Head { get; set; } = string.Empty; - public bool IsBare { get; set; } = false; - public bool IsDetached { get; set; } = false; + public bool IsBare { get; set; } + public bool IsDetached { get; set; } public bool IsLocked { @@ -35,6 +35,6 @@ public string Name } } - private bool _isLocked = false; + private bool _isLocked; } } diff --git a/src/Native/OS.cs b/src/Native/OS.cs index 27fce1c3f..051574609 100644 --- a/src/Native/OS.cs +++ b/src/Native/OS.cs @@ -232,8 +232,8 @@ private static void UpdateGitVersion() [GeneratedRegex(@"^git version[\s\w]*(\d+)\.(\d+)[\.\-](\d+).*$")] private static partial Regex REG_GIT_VERSION(); - private static IBackend _backend = null; + private static readonly IBackend _backend; private static string _gitExecutable = string.Empty; - private static bool _enableSystemWindowFrame = false; + private static bool _enableSystemWindowFrame; } } diff --git a/src/ViewModels/AIAssistant.cs b/src/ViewModels/AIAssistant.cs index 920fafcf5..bee94b709 100644 --- a/src/ViewModels/AIAssistant.cs +++ b/src/ViewModels/AIAssistant.cs @@ -69,12 +69,12 @@ private void Gen() }, _cancel.Token); } - private readonly Repository _repo = null; - private Models.OpenAIService _service = null; - private List _changes = null; - private Action _onApply = null; - private CancellationTokenSource _cancel = null; - private bool _isGenerating = false; + private readonly Repository _repo; + private readonly Models.OpenAIService _service; + private readonly List _changes; + private readonly Action _onApply; + private CancellationTokenSource _cancel; + private bool _isGenerating; private string _text = string.Empty; } } diff --git a/src/ViewModels/AddRemote.cs b/src/ViewModels/AddRemote.cs index 5a6c019fc..fcd88ec1a 100644 --- a/src/ViewModels/AddRemote.cs +++ b/src/ViewModels/AddRemote.cs @@ -118,10 +118,10 @@ public override async Task Sure() return succ; } - private readonly Repository _repo = null; + private readonly Repository _repo; private string _name = string.Empty; private string _url = string.Empty; - private bool _useSSH = false; + private bool _useSSH; private string _sshkey = string.Empty; } } diff --git a/src/ViewModels/AddSubmodule.cs b/src/ViewModels/AddSubmodule.cs index 313b2e8e2..5091c4e43 100644 --- a/src/ViewModels/AddSubmodule.cs +++ b/src/ViewModels/AddSubmodule.cs @@ -68,7 +68,7 @@ public override async Task Sure() return succ; } - private readonly Repository _repo = null; + private readonly Repository _repo; private string _url = string.Empty; private string _relativePath = string.Empty; } diff --git a/src/ViewModels/AddWorktree.cs b/src/ViewModels/AddWorktree.cs index 3c3d69ff5..7542275d8 100644 --- a/src/ViewModels/AddWorktree.cs +++ b/src/ViewModels/AddWorktree.cs @@ -124,10 +124,10 @@ public override async Task Sure() return succ; } - private Repository _repo = null; + private readonly Repository _repo; private string _path = string.Empty; private bool _createNewBranch = true; private string _selectedBranch = string.Empty; - private bool _setTrackingBranch = false; + private bool _setTrackingBranch; } } diff --git a/src/ViewModels/Apply.cs b/src/ViewModels/Apply.cs index 709a66fd6..70137fa2c 100644 --- a/src/ViewModels/Apply.cs +++ b/src/ViewModels/Apply.cs @@ -58,7 +58,7 @@ public override async Task Sure() return succ; } - private readonly Repository _repo = null; + private readonly Repository _repo; private string _patchFile = string.Empty; private bool _ignoreWhiteSpace = true; } diff --git a/src/ViewModels/ApplyStash.cs b/src/ViewModels/ApplyStash.cs index b21d6fe80..0872d55fd 100644 --- a/src/ViewModels/ApplyStash.cs +++ b/src/ViewModels/ApplyStash.cs @@ -20,7 +20,7 @@ public bool DropAfterApply { get; set; - } = false; + } public ApplyStash(Repository repo, Models.Stash stash) { diff --git a/src/ViewModels/Archive.cs b/src/ViewModels/Archive.cs index 6f86357df..73516175a 100644 --- a/src/ViewModels/Archive.cs +++ b/src/ViewModels/Archive.cs @@ -64,8 +64,8 @@ public override async Task Sure() return succ; } - private readonly Repository _repo = null; - private string _saveFile; + private readonly Repository _repo; private readonly string _revision; + private string _saveFile; } } diff --git a/src/ViewModels/Blame.cs b/src/ViewModels/Blame.cs index affe40d92..d4ab93e96 100644 --- a/src/ViewModels/Blame.cs +++ b/src/ViewModels/Blame.cs @@ -164,13 +164,13 @@ private void SetBlameData(string commitSHA) }, token); } - private string _repo; + private readonly string _repo; + private readonly List _navigationHistory = []; + private readonly Dictionary _commits = new(); + private readonly Dictionary _commitMessages = new(); private Models.Commit _revision; - private CancellationTokenSource _cancellationSource = null; - private int _navigationActiveIndex = 0; - private List _navigationHistory = []; - private Models.BlameData _data = null; - private Dictionary _commits = new(); - private Dictionary _commitMessages = new(); + private CancellationTokenSource _cancellationSource; + private int _navigationActiveIndex; + private Models.BlameData _data; } } diff --git a/src/ViewModels/BlockNavigation.cs b/src/ViewModels/BlockNavigation.cs index 4a51244cb..a8f91903f 100644 --- a/src/ViewModels/BlockNavigation.cs +++ b/src/ViewModels/BlockNavigation.cs @@ -8,8 +8,8 @@ public class BlockNavigation : ObservableObject { public class Block { - public int Start { get; set; } = 0; - public int End { get; set; } = 0; + public int Start { get; set; } + public int End { get; set; } public Block(int start, int end) { diff --git a/src/ViewModels/BranchCompare.cs b/src/ViewModels/BranchCompare.cs index 2d339cad3..f554b54b0 100644 --- a/src/ViewModels/BranchCompare.cs +++ b/src/ViewModels/BranchCompare.cs @@ -252,15 +252,15 @@ private void RefreshVisible() } } - private string _repo; - private Models.Branch _based = null; - private Models.Branch _to = null; - private Models.Commit _baseHead = null; - private Models.Commit _toHead = null; - private List _changes = null; - private List _visibleChanges = null; - private List _selectedChanges = null; + private readonly string _repo; + private Models.Branch _based; + private Models.Branch _to; + private Models.Commit _baseHead; + private Models.Commit _toHead; + private List _changes; + private List _visibleChanges; + private List _selectedChanges; private string _searchFilter = string.Empty; - private DiffContext _diffContext = null; + private DiffContext _diffContext; } } diff --git a/src/ViewModels/BranchTreeNode.cs b/src/ViewModels/BranchTreeNode.cs index 5c5d2de1d..96656ff2e 100644 --- a/src/ViewModels/BranchTreeNode.cs +++ b/src/ViewModels/BranchTreeNode.cs @@ -9,12 +9,12 @@ public class BranchTreeNode : ObservableObject { public string Name { get; private set; } = string.Empty; public string Path { get; private set; } = string.Empty; - public object Backend { get; private set; } = null; - public ulong TimeToSort { get; private set; } = 0; - public int Depth { get; set; } = 0; - public bool IsSelected { get; set; } = false; + public object Backend { get; private set; } + public ulong TimeToSort { get; private set; } + public int Depth { get; set; } + public bool IsSelected { get; set; } public List Children { get; private set; } = new List(); - public int Counter { get; set; } = 0; + public int Counter { get; set; } public Models.FilterMode FilterMode { @@ -69,7 +69,7 @@ public string Tooltip } private Models.FilterMode _filterMode = Models.FilterMode.None; - private bool _isExpanded = false; + private bool _isExpanded; private CornerRadius _cornerRadius = new CornerRadius(4); public class Builder diff --git a/src/ViewModels/ChangeTreeNode.cs b/src/ViewModels/ChangeTreeNode.cs index 4d71a153b..9197f4c9a 100644 --- a/src/ViewModels/ChangeTreeNode.cs +++ b/src/ViewModels/ChangeTreeNode.cs @@ -7,8 +7,8 @@ namespace SourceGit.ViewModels public class ChangeTreeNode : ObservableObject { public string FullPath { get; set; } - public int Depth { get; private set; } = 0; - public Models.Change Change { get; set; } = null; + public int Depth { get; private set; } + public Models.Change Change { get; set; } public List Children { get; set; } = new List(); public bool IsFolder diff --git a/src/ViewModels/Checkout.cs b/src/ViewModels/Checkout.cs index ce6195b8d..1bc36f93a 100644 --- a/src/ViewModels/Checkout.cs +++ b/src/ViewModels/Checkout.cs @@ -113,6 +113,6 @@ public override async Task Sure() return succ; } - private readonly Repository _repo = null; + private readonly Repository _repo; } } diff --git a/src/ViewModels/CheckoutCommit.cs b/src/ViewModels/CheckoutCommit.cs index a77a72356..d9dcd7dc5 100644 --- a/src/ViewModels/CheckoutCommit.cs +++ b/src/ViewModels/CheckoutCommit.cs @@ -104,6 +104,6 @@ public override async Task Sure() return succ; } - private readonly Repository _repo = null; + private readonly Repository _repo; } } diff --git a/src/ViewModels/CherryPick.cs b/src/ViewModels/CherryPick.cs index ca525e0ac..77c1ccb28 100644 --- a/src/ViewModels/CherryPick.cs +++ b/src/ViewModels/CherryPick.cs @@ -100,6 +100,6 @@ public override async Task Sure() return true; } - private readonly Repository _repo = null; + private readonly Repository _repo; } } diff --git a/src/ViewModels/Cleanup.cs b/src/ViewModels/Cleanup.cs index c8788d681..fb4ebd65a 100644 --- a/src/ViewModels/Cleanup.cs +++ b/src/ViewModels/Cleanup.cs @@ -26,6 +26,6 @@ public override async Task Sure() return true; } - private readonly Repository _repo = null; + private readonly Repository _repo; } } diff --git a/src/ViewModels/ClearStashes.cs b/src/ViewModels/ClearStashes.cs index 6178d5efd..dc1cadadc 100644 --- a/src/ViewModels/ClearStashes.cs +++ b/src/ViewModels/ClearStashes.cs @@ -26,6 +26,6 @@ public override async Task Sure() return true; } - private readonly Repository _repo = null; + private readonly Repository _repo; } } diff --git a/src/ViewModels/Clone.cs b/src/ViewModels/Clone.cs index b3aadb581..03e7243d1 100644 --- a/src/ViewModels/Clone.cs +++ b/src/ViewModels/Clone.cs @@ -166,9 +166,9 @@ public override async Task Sure() return true; } - private string _pageId = string.Empty; + private readonly string _pageId = string.Empty; private string _remote = string.Empty; - private bool _useSSH = false; + private bool _useSSH; private string _sshKey = string.Empty; private string _parentFolder = string.Empty; private string _local = string.Empty; diff --git a/src/ViewModels/CommandLog.cs b/src/ViewModels/CommandLog.cs index 1accc2263..eedb6a18d 100644 --- a/src/ViewModels/CommandLog.cs +++ b/src/ViewModels/CommandLog.cs @@ -28,7 +28,7 @@ public bool IsComplete { get; private set; - } = false; + } public string Content { diff --git a/src/ViewModels/CommitDetail.cs b/src/ViewModels/CommitDetail.cs index 3fce223b8..2034484dd 100644 --- a/src/ViewModels/CommitDetail.cs +++ b/src/ViewModels/CommitDetail.cs @@ -1060,25 +1060,25 @@ private async Task ResetToParentRevisionAsync(Models.Change change) [GeneratedRegex(@"\b([0-9a-fA-F]{6,40})\b")] private static partial Regex REG_SHA_FORMAT(); - private Repository _repo = null; - private bool _rememberActivePageIndex = true; - private int _activePageIndex = 0; - private Models.Commit _commit = null; - private Models.CommitFullMessage _fullMessage = null; - private Models.CommitSignInfo _signInfo = null; - private List _children = null; - private List _changes = null; - private List _visibleChanges = null; - private List _selectedChanges = null; + private Repository _repo; + private readonly bool _rememberActivePageIndex = true; + private int _activePageIndex; + private Models.Commit _commit; + private Models.CommitFullMessage _fullMessage; + private Models.CommitSignInfo _signInfo; + private List _children; + private List _changes; + private List _visibleChanges; + private List _selectedChanges; private string _searchChangeFilter = string.Empty; - private DiffContext _diffContext = null; + private DiffContext _diffContext; private string _viewRevisionFilePath = string.Empty; - private object _viewRevisionFileContent = null; - private CancellationTokenSource _cancellationSource = null; - private bool _requestingRevisionFiles = false; - private List _revisionFiles = null; + private object _viewRevisionFileContent; + private CancellationTokenSource _cancellationSource; + private bool _requestingRevisionFiles; + private List _revisionFiles; private string _revisionFileSearchFilter = string.Empty; - private List _revisionFileSearchSuggestion = null; - private bool _canOpenRevisionFileWithDefaultEditor = false; + private List _revisionFileSearchSuggestion; + private bool _canOpenRevisionFileWithDefaultEditor; } } diff --git a/src/ViewModels/ConfigureWorkspace.cs b/src/ViewModels/ConfigureWorkspace.cs index 638caf5df..97ed53566 100644 --- a/src/ViewModels/ConfigureWorkspace.cs +++ b/src/ViewModels/ConfigureWorkspace.cs @@ -79,7 +79,7 @@ public void MoveSelectedDown() Preferences.Instance.Workspaces.Insert(idx + 1, _selected); } - private Workspace _selected = null; - private bool _canDeleteSelected = false; + private Workspace _selected; + private bool _canDeleteSelected; } } diff --git a/src/ViewModels/Conflict.cs b/src/ViewModels/Conflict.cs index 7a14c7065..4579d315c 100644 --- a/src/ViewModels/Conflict.cs +++ b/src/ViewModels/Conflict.cs @@ -51,13 +51,13 @@ public bool IsResolved { get; private set; - } = false; + } public bool CanUseExternalMergeTool { get; private set; - } = false; + } public Conflict(Repository repo, WorkingCopy wc, Models.Change change) { @@ -116,7 +116,7 @@ public async void OpenExternalMergeTool() await _wc.UseExternalMergeTool(_change); } - private WorkingCopy _wc = null; - private Models.Change _change = null; + private readonly WorkingCopy _wc; + private readonly Models.Change _change; } } diff --git a/src/ViewModels/ConventionalCommitMessageBuilder.cs b/src/ViewModels/ConventionalCommitMessageBuilder.cs index d002a77d9..b4676f212 100644 --- a/src/ViewModels/ConventionalCommitMessageBuilder.cs +++ b/src/ViewModels/ConventionalCommitMessageBuilder.cs @@ -102,7 +102,7 @@ public bool Apply() return true; } - private Action _onApply = null; + private readonly Action _onApply; private Models.ConventionalCommitType _type = Models.ConventionalCommitType.Supported[0]; private string _scope = string.Empty; private string _description = string.Empty; diff --git a/src/ViewModels/CreateBranch.cs b/src/ViewModels/CreateBranch.cs index 537a8d798..cf57f3335 100644 --- a/src/ViewModels/CreateBranch.cs +++ b/src/ViewModels/CreateBranch.cs @@ -221,9 +221,9 @@ public override async Task Sure() return true; } - private readonly Repository _repo = null; - private string _name = null; - private readonly string _baseOnRevision = null; - private bool _allowOverwrite = false; + private readonly Repository _repo; + private readonly string _baseOnRevision; + private string _name; + private bool _allowOverwrite; } } diff --git a/src/ViewModels/CreateGroup.cs b/src/ViewModels/CreateGroup.cs index eb8ef2b5c..7e986a616 100644 --- a/src/ViewModels/CreateGroup.cs +++ b/src/ViewModels/CreateGroup.cs @@ -32,7 +32,7 @@ public override Task Sure() return Task.FromResult(true); } - private readonly RepositoryNode _parent = null; + private readonly RepositoryNode _parent; private string _name = string.Empty; } } diff --git a/src/ViewModels/CreateTag.cs b/src/ViewModels/CreateTag.cs index 85e2b9736..21666a02f 100644 --- a/src/ViewModels/CreateTag.cs +++ b/src/ViewModels/CreateTag.cs @@ -37,7 +37,7 @@ public bool SignTag { get; set; - } = false; + } public bool PushToRemotes { @@ -102,7 +102,7 @@ public override async Task Sure() return succ; } - private readonly Repository _repo = null; + private readonly Repository _repo; private string _tagName = string.Empty; private bool _annotated = true; private readonly string _basedOn; diff --git a/src/ViewModels/DeleteBranch.cs b/src/ViewModels/DeleteBranch.cs index a764c68d3..406952794 100644 --- a/src/ViewModels/DeleteBranch.cs +++ b/src/ViewModels/DeleteBranch.cs @@ -85,7 +85,7 @@ private async Task DeleteRemoteBranchAsync(Models.Branch branch, CommandLog log) .ConfigureAwait(false); } - private readonly Repository _repo = null; - private bool _alsoDeleteTrackingRemote = false; + private readonly Repository _repo; + private bool _alsoDeleteTrackingRemote; } } diff --git a/src/ViewModels/DeleteMultipleBranches.cs b/src/ViewModels/DeleteMultipleBranches.cs index ba6d774c6..3d4c7c8f1 100644 --- a/src/ViewModels/DeleteMultipleBranches.cs +++ b/src/ViewModels/DeleteMultipleBranches.cs @@ -54,7 +54,7 @@ public override async Task Sure() return true; } - private Repository _repo = null; - private bool _isLocal = false; + private readonly Repository _repo; + private readonly bool _isLocal; } } diff --git a/src/ViewModels/DeleteRemote.cs b/src/ViewModels/DeleteRemote.cs index 595a7d52b..4810478fe 100644 --- a/src/ViewModels/DeleteRemote.cs +++ b/src/ViewModels/DeleteRemote.cs @@ -34,6 +34,6 @@ public override async Task Sure() return succ; } - private readonly Repository _repo = null; + private readonly Repository _repo; } } diff --git a/src/ViewModels/DeleteSubmodule.cs b/src/ViewModels/DeleteSubmodule.cs index 34a77c6e1..2e3bf09a2 100644 --- a/src/ViewModels/DeleteSubmodule.cs +++ b/src/ViewModels/DeleteSubmodule.cs @@ -33,6 +33,6 @@ public override async Task Sure() return succ; } - private readonly Repository _repo = null; + private readonly Repository _repo; } } diff --git a/src/ViewModels/DeleteTag.cs b/src/ViewModels/DeleteTag.cs index b283a8374..8aa596a0b 100644 --- a/src/ViewModels/DeleteTag.cs +++ b/src/ViewModels/DeleteTag.cs @@ -46,6 +46,6 @@ public override async Task Sure() return succ; } - private readonly Repository _repo = null; + private readonly Repository _repo; } } diff --git a/src/ViewModels/DiffContext.cs b/src/ViewModels/DiffContext.cs index 025ceddd4..ff4f6a6df 100644 --- a/src/ViewModels/DiffContext.cs +++ b/src/ViewModels/DiffContext.cs @@ -282,11 +282,11 @@ public bool IsSame(Info other) } private readonly string _repo; - private readonly Models.DiffOption _option = null; + private readonly Models.DiffOption _option; private string _fileModeChange = string.Empty; private int _unifiedLines = 4; - private bool _isTextDiff = false; - private object _content = null; - private Info _info = null; + private bool _isTextDiff; + private object _content; + private Info _info; } } diff --git a/src/ViewModels/DirHistories.cs b/src/ViewModels/DirHistories.cs index 6b4aa0393..b64538d3e 100644 --- a/src/ViewModels/DirHistories.cs +++ b/src/ViewModels/DirHistories.cs @@ -84,11 +84,11 @@ public string GetCommitFullMessage(Models.Commit commit) return msg; } - private Repository _repo = null; + private readonly Repository _repo; private bool _isLoading = true; private List _commits = []; - private Models.Commit _selectedCommit = null; - private CommitDetail _detail = null; - private Dictionary _cachedCommitFullMessage = new(); + private Models.Commit _selectedCommit; + private CommitDetail _detail; + private readonly Dictionary _cachedCommitFullMessage = new(); } } diff --git a/src/ViewModels/Discard.cs b/src/ViewModels/Discard.cs index 1fcda9049..5e2c87af0 100644 --- a/src/ViewModels/Discard.cs +++ b/src/ViewModels/Discard.cs @@ -9,7 +9,7 @@ public bool IncludeIgnored { get; set; - } = false; + } } public class DiscardSingleFile @@ -27,7 +27,7 @@ public int Count { get; set; - } = 0; + } } public class Discard : Popup @@ -75,7 +75,7 @@ public override async Task Sure() return true; } - private readonly Repository _repo = null; - private readonly List _changes = null; + private readonly Repository _repo; + private readonly List _changes; } } diff --git a/src/ViewModels/EditRemote.cs b/src/ViewModels/EditRemote.cs index 4c7e3237a..26bd9c677 100644 --- a/src/ViewModels/EditRemote.cs +++ b/src/ViewModels/EditRemote.cs @@ -127,11 +127,11 @@ public override async Task Sure() return true; } - private readonly Repository _repo = null; - private readonly Models.Remote _remote = null; - private string _name = null; - private string _url = null; - private bool _useSSH = false; + private readonly Repository _repo; + private readonly Models.Remote _remote; + private string _name; + private string _url; + private bool _useSSH; private string _sshkey = string.Empty; } } diff --git a/src/ViewModels/EditRepositoryNode.cs b/src/ViewModels/EditRepositoryNode.cs index 38d072a14..00f16089d 100644 --- a/src/ViewModels/EditRepositoryNode.cs +++ b/src/ViewModels/EditRepositoryNode.cs @@ -54,10 +54,10 @@ public override Task Sure() return Task.FromResult(true); } - private RepositoryNode _node = null; - private string _id = null; - private string _name = null; - private bool _isRepository = false; - private int _bookmark = 0; + private readonly RepositoryNode _node; + private string _id; + private string _name; + private bool _isRepository; + private int _bookmark; } } diff --git a/src/ViewModels/ExecuteCustomAction.cs b/src/ViewModels/ExecuteCustomAction.cs index fb0f2f819..2862d2343 100644 --- a/src/ViewModels/ExecuteCustomAction.cs +++ b/src/ViewModels/ExecuteCustomAction.cs @@ -33,7 +33,7 @@ public class CustomActionControlPathSelector : ObservableObject, ICustomActionCo { public string Label { get; set; } = string.Empty; public string Placeholder { get; set; } = string.Empty; - public bool IsFolder { get; set; } = false; + public bool IsFolder { get; set; } public string Path { @@ -289,6 +289,6 @@ private async Task RunAsync(string args, Models.ICommandLog log) } } - private readonly Repository _repo = null; + private readonly Repository _repo; } } diff --git a/src/ViewModels/Fetch.cs b/src/ViewModels/Fetch.cs index 0930e7773..39389b279 100644 --- a/src/ViewModels/Fetch.cs +++ b/src/ViewModels/Fetch.cs @@ -91,7 +91,7 @@ public override async Task Sure() return true; } - private readonly Repository _repo = null; + private readonly Repository _repo; private bool _fetchAllRemotes; } } diff --git a/src/ViewModels/FetchInto.cs b/src/ViewModels/FetchInto.cs index 3a0879b9e..5e4bcb39f 100644 --- a/src/ViewModels/FetchInto.cs +++ b/src/ViewModels/FetchInto.cs @@ -41,6 +41,6 @@ public override async Task Sure() return true; } - private readonly Repository _repo = null; + private readonly Repository _repo; } } diff --git a/src/ViewModels/FileHistories.cs b/src/ViewModels/FileHistories.cs index 0f50d256f..4d51de867 100644 --- a/src/ViewModels/FileHistories.cs +++ b/src/ViewModels/FileHistories.cs @@ -41,7 +41,6 @@ public FileHistoriesSingleRevision(Repository repo, string file, Models.Commit r _file = file; _revision = revision; _isDiffMode = prevIsDiffMode; - _viewContent = null; RefreshViewContent(); } @@ -164,11 +163,11 @@ private void SetViewContentAsDiff() ViewContent = new DiffContext(_repo.FullPath, option, _viewContent as DiffContext); } - private Repository _repo = null; - private string _file = null; - private Models.Commit _revision = null; - private bool _isDiffMode = false; - private object _viewContent = null; + private readonly Repository _repo; + private readonly string _file; + private readonly Models.Commit _revision; + private bool _isDiffMode; + private object _viewContent; } public class FileHistoriesCompareRevisions : ObservableObject @@ -230,12 +229,12 @@ private void RefreshViewContent() }); } - private Repository _repo = null; - private string _file = null; - private Models.Commit _startPoint = null; - private Models.Commit _endPoint = null; + private readonly Repository _repo; + private readonly string _file; + private Models.Commit _startPoint; + private Models.Commit _endPoint; private List _changes = []; - private DiffContext _viewContent = null; + private DiffContext _viewContent; } public class FileHistories : ObservableObject @@ -323,11 +322,11 @@ public string GetCommitFullMessage(Models.Commit commit) return msg; } - private readonly Repository _repo = null; + private readonly Repository _repo; private bool _isLoading = true; private bool _prevIsDiffMode = true; - private List _commits = null; - private Dictionary _fullCommitMessages = new(); - private object _viewContent = null; + private List _commits; + private readonly Dictionary _fullCommitMessages = new(); + private object _viewContent; } } diff --git a/src/ViewModels/FilterModeInGraph.cs b/src/ViewModels/FilterModeInGraph.cs index 9930b8164..847b7c2f6 100644 --- a/src/ViewModels/FilterModeInGraph.cs +++ b/src/ViewModels/FilterModeInGraph.cs @@ -55,8 +55,8 @@ private void SetFilterMode(Models.FilterMode mode) } } - private Repository _repo = null; - private object _target = null; + private readonly Repository _repo; + private readonly object _target; private Models.FilterMode _mode = Models.FilterMode.None; } } diff --git a/src/ViewModels/GitFlowFinish.cs b/src/ViewModels/GitFlowFinish.cs index 959fa10e0..4de5177c8 100644 --- a/src/ViewModels/GitFlowFinish.cs +++ b/src/ViewModels/GitFlowFinish.cs @@ -19,19 +19,19 @@ public bool Squash { get; set; - } = false; + } public bool AutoPush { get; set; - } = false; + } public bool KeepBranch { get; set; - } = false; + } public GitFlowFinish(Repository repo, Models.Branch branch, Models.GitFlowBranchType type) { diff --git a/src/ViewModels/GitFlowStart.cs b/src/ViewModels/GitFlowStart.cs index e6055f8e7..b063227c6 100644 --- a/src/ViewModels/GitFlowStart.cs +++ b/src/ViewModels/GitFlowStart.cs @@ -64,6 +64,6 @@ public override async Task Sure() } private readonly Repository _repo; - private string _name = null; + private string _name; } } diff --git a/src/ViewModels/Histories.cs b/src/ViewModels/Histories.cs index f0bf8bef5..d09d4966c 100644 --- a/src/ViewModels/Histories.cs +++ b/src/ViewModels/Histories.cs @@ -1231,15 +1231,15 @@ private string GetPatchFileName(string dir, Models.Commit commit, int index = 0) return Path.Combine(dir, builder.ToString()); } - private Repository _repo = null; + private Repository _repo; private bool _isLoading = true; private List _commits = new List(); - private Models.CommitGraph _graph = null; - private Models.Commit _autoSelectedCommit = null; - private long _navigationId = 0; - private IDisposable _detailContext = null; + private Models.CommitGraph _graph; + private Models.Commit _autoSelectedCommit; + private long _navigationId; + private IDisposable _detailContext; - private Models.Bisect _bisect = null; + private Models.Bisect _bisect; private GridLength _leftArea = new GridLength(1, GridUnitType.Star); private GridLength _rightArea = new GridLength(1, GridUnitType.Star); diff --git a/src/ViewModels/Init.cs b/src/ViewModels/Init.cs index 7f349917f..fcffc134a 100644 --- a/src/ViewModels/Init.cs +++ b/src/ViewModels/Init.cs @@ -45,8 +45,8 @@ public override async Task Sure() return succ; } - private readonly string _pageId = null; - private string _targetPath = null; - private readonly RepositoryNode _parentNode = null; + private readonly string _pageId; + private readonly RepositoryNode _parentNode; + private string _targetPath; } } diff --git a/src/ViewModels/InteractiveRebase.cs b/src/ViewModels/InteractiveRebase.cs index 4e5b5c889..241479404 100644 --- a/src/ViewModels/InteractiveRebase.cs +++ b/src/ViewModels/InteractiveRebase.cs @@ -242,8 +242,8 @@ private void UpdateItems() } } - private Repository _repo = null; - private bool _isLoading = false; - private InteractiveRebaseItem _selectedItem = null; + private readonly Repository _repo; + private bool _isLoading; + private InteractiveRebaseItem _selectedItem; } } diff --git a/src/ViewModels/LFSFetch.cs b/src/ViewModels/LFSFetch.cs index c73f2aa8f..e1e063eb5 100644 --- a/src/ViewModels/LFSFetch.cs +++ b/src/ViewModels/LFSFetch.cs @@ -34,6 +34,6 @@ public override async Task Sure() return true; } - private readonly Repository _repo = null; + private readonly Repository _repo; } } diff --git a/src/ViewModels/LFSLocks.cs b/src/ViewModels/LFSLocks.cs index 800ad8204..35463136b 100644 --- a/src/ViewModels/LFSLocks.cs +++ b/src/ViewModels/LFSLocks.cs @@ -12,7 +12,7 @@ public bool HasValidUserName { get; private set; - } = false; + } public bool IsLoading { @@ -95,12 +95,12 @@ private void UpdateVisibleLocks() VisibleLocks = visible; } - private Repository _repo; - private string _remote; + private readonly Repository _repo; + private readonly string _remote; private bool _isLoading = true; private List _cachedLocks = []; private List _visibleLocks = []; - private bool _showOnlyMyLocks = false; + private bool _showOnlyMyLocks; private string _userName; } } diff --git a/src/ViewModels/LFSPrune.cs b/src/ViewModels/LFSPrune.cs index c5337b6c2..452513e5d 100644 --- a/src/ViewModels/LFSPrune.cs +++ b/src/ViewModels/LFSPrune.cs @@ -24,6 +24,6 @@ public override async Task Sure() return true; } - private readonly Repository _repo = null; + private readonly Repository _repo; } } diff --git a/src/ViewModels/LFSPull.cs b/src/ViewModels/LFSPull.cs index 8c034b8f3..725e45206 100644 --- a/src/ViewModels/LFSPull.cs +++ b/src/ViewModels/LFSPull.cs @@ -34,6 +34,6 @@ public override async Task Sure() return true; } - private readonly Repository _repo = null; + private readonly Repository _repo; } } diff --git a/src/ViewModels/LFSPush.cs b/src/ViewModels/LFSPush.cs index cd69b5086..6ea587b23 100644 --- a/src/ViewModels/LFSPush.cs +++ b/src/ViewModels/LFSPush.cs @@ -34,6 +34,6 @@ public override async Task Sure() return true; } - private readonly Repository _repo = null; + private readonly Repository _repo; } } diff --git a/src/ViewModels/LFSTrackCustomPattern.cs b/src/ViewModels/LFSTrackCustomPattern.cs index f9fa47546..55341f5cd 100644 --- a/src/ViewModels/LFSTrackCustomPattern.cs +++ b/src/ViewModels/LFSTrackCustomPattern.cs @@ -16,7 +16,7 @@ public bool IsFilename { get; set; - } = false; + } public LFSTrackCustomPattern(Repository repo) { @@ -38,7 +38,7 @@ public override async Task Sure() return succ; } - private readonly Repository _repo = null; + private readonly Repository _repo; private string _pattern = string.Empty; } } diff --git a/src/ViewModels/Launcher.cs b/src/ViewModels/Launcher.cs index b079ccf61..436a8c6fb 100644 --- a/src/ViewModels/Launcher.cs +++ b/src/ViewModels/Launcher.cs @@ -606,10 +606,10 @@ private void UpdateTitle() } } - private Workspace _activeWorkspace = null; - private LauncherPage _activePage = null; - private bool _ignoreIndexChange = false; + private Workspace _activeWorkspace; + private LauncherPage _activePage; + private bool _ignoreIndexChange; private string _title = string.Empty; - private IDisposable _switcher = null; + private IDisposable _switcher; } } diff --git a/src/ViewModels/LauncherPage.cs b/src/ViewModels/LauncherPage.cs index 0b4b3d8ad..a8da39fe3 100644 --- a/src/ViewModels/LauncherPage.cs +++ b/src/ViewModels/LauncherPage.cs @@ -130,10 +130,10 @@ public void CancelPopup() Popup = null; } - private RepositoryNode _node = null; - private object _data = null; - private IBrush _dirtyBrush = null; + private RepositoryNode _node; + private object _data; + private IBrush _dirtyBrush; private Models.DirtyState _dirtyState = Models.DirtyState.None; - private Popup _popup = null; + private Popup _popup; } } diff --git a/src/ViewModels/LauncherPageSwitcher.cs b/src/ViewModels/LauncherPageSwitcher.cs index 5f53021d6..43c53e43d 100644 --- a/src/ViewModels/LauncherPageSwitcher.cs +++ b/src/ViewModels/LauncherPageSwitcher.cs @@ -75,9 +75,9 @@ private void UpdateVisiblePages() SelectedPage = visible.Count > 0 ? visible[0] : null; } - private Launcher _launcher = null; + private readonly Launcher _launcher; private List _visiblePages = []; private string _searchFilter = string.Empty; - private LauncherPage _selectedPage = null; + private LauncherPage _selectedPage; } } diff --git a/src/ViewModels/Merge.cs b/src/ViewModels/Merge.cs index 3ccf6a6fe..6eaf1c98d 100644 --- a/src/ViewModels/Merge.cs +++ b/src/ViewModels/Merge.cs @@ -24,7 +24,7 @@ public bool Edit { get; set; - } = false; + } public Merge(Repository repo, Models.Branch source, string into, bool forceFastForward) { @@ -99,7 +99,7 @@ private Models.MergeMode AutoSelectMergeMode() return Models.MergeMode.Supported[preferredMergeModeIdx]; } - private readonly Repository _repo = null; + private readonly Repository _repo; private readonly string _sourceName; } } diff --git a/src/ViewModels/MergeMultiple.cs b/src/ViewModels/MergeMultiple.cs index 03f199a87..da98f3a22 100644 --- a/src/ViewModels/MergeMultiple.cs +++ b/src/ViewModels/MergeMultiple.cs @@ -86,6 +86,6 @@ Models.DecoratorType.RemoteBranchHead or return ret; } - private readonly Repository _repo = null; + private readonly Repository _repo; } } diff --git a/src/ViewModels/MoveRepositoryNode.cs b/src/ViewModels/MoveRepositoryNode.cs index 0c213058b..b9cd54a95 100644 --- a/src/ViewModels/MoveRepositoryNode.cs +++ b/src/ViewModels/MoveRepositoryNode.cs @@ -9,7 +9,7 @@ public class MoveRepositoryNode : Popup public RepositoryNode Target { get; - } = null; + } public List Rows { @@ -64,6 +64,6 @@ private void MakeRows(List collection, int depth) } } - private RepositoryNode _selected = null; + private RepositoryNode _selected; } } diff --git a/src/ViewModels/Popup.cs b/src/ViewModels/Popup.cs index 942d33f9f..422d72fde 100644 --- a/src/ViewModels/Popup.cs +++ b/src/ViewModels/Popup.cs @@ -49,7 +49,7 @@ private void SetDescription(string data) ProgressDescription = desc; } - private bool _inProgress = false; + private bool _inProgress; private string _progressDescription = string.Empty; } } diff --git a/src/ViewModels/Preferences.cs b/src/ViewModels/Preferences.cs index 8e5f24c50..e69727205 100644 --- a/src/ViewModels/Preferences.cs +++ b/src/ViewModels/Preferences.cs @@ -180,7 +180,7 @@ public bool ShowTagsAsTree { get; set; - } = false; + } public bool ShowTagsInGraph { @@ -192,7 +192,7 @@ public bool ShowSubmodulesAsTree { get; set; - } = false; + } public bool UseTwoColumnsLayoutInHistories { @@ -659,7 +659,7 @@ private bool RemoveInvalidRepositoriesRecursive(List collection) return changed; } - private static Preferences _instance = null; + private static Preferences _instance; private bool _isLoading = true; private bool _isReadonly = true; @@ -677,24 +677,24 @@ private bool RemoveInvalidRepositoriesRecursive(List collection) private int _maxHistoryCommits = 20000; private int _subjectGuideLength = 50; private bool _useFixedTabWidth = true; - private bool _showAuthorTimeInGraph = false; - private bool _showChildren = false; + private bool _showAuthorTimeInGraph; + private bool _showChildren; private bool _check4UpdatesOnStartup = true; - private double _lastCheckUpdateTime = 0; + private double _lastCheckUpdateTime; private string _ignoreUpdateTag = string.Empty; private bool _showTagsInGraph = true; - private bool _useTwoColumnsLayoutInHistories = false; - private bool _displayTimeAsPeriodInHistories = false; - private bool _useSideBySideDiff = false; - private bool _ignoreWhitespaceChangesInDiff = false; - private bool _useSyntaxHighlighting = false; - private bool _enableDiffViewWordWrap = false; - private bool _showHiddenSymbolsInDiffView = false; - private bool _useFullTextDiff = false; - private bool _useBlockNavigationInDiffView = false; - private int _lfsImageActiveIdx = 0; + private bool _useTwoColumnsLayoutInHistories; + private bool _displayTimeAsPeriodInHistories; + private bool _useSideBySideDiff; + private bool _ignoreWhitespaceChangesInDiff; + private bool _useSyntaxHighlighting; + private bool _enableDiffViewWordWrap; + private bool _showHiddenSymbolsInDiffView; + private bool _useFullTextDiff; + private bool _useBlockNavigationInDiffView; + private int _lfsImageActiveIdx; private Models.ChangeViewMode _unstagedChangeViewMode = Models.ChangeViewMode.List; private Models.ChangeViewMode _stagedChangeViewMode = Models.ChangeViewMode.List; @@ -704,7 +704,7 @@ private bool RemoveInvalidRepositoriesRecursive(List collection) private string _gitDefaultCloneDir = string.Empty; private int _shellOrTerminal = -1; - private int _externalMergeToolType = 0; + private int _externalMergeToolType; private string _externalMergeToolPath = string.Empty; private uint _statisticsSampleColor = 0xFF00FF00; diff --git a/src/ViewModels/PruneRemote.cs b/src/ViewModels/PruneRemote.cs index 56ba598de..699ad7381 100644 --- a/src/ViewModels/PruneRemote.cs +++ b/src/ViewModels/PruneRemote.cs @@ -32,6 +32,6 @@ public override async Task Sure() return succ; } - private readonly Repository _repo = null; + private readonly Repository _repo; } } diff --git a/src/ViewModels/PruneWorktrees.cs b/src/ViewModels/PruneWorktrees.cs index cce335276..791ee1a79 100644 --- a/src/ViewModels/PruneWorktrees.cs +++ b/src/ViewModels/PruneWorktrees.cs @@ -26,6 +26,6 @@ public override async Task Sure() return true; } - private readonly Repository _repo = null; + private readonly Repository _repo; } } diff --git a/src/ViewModels/Pull.cs b/src/ViewModels/Pull.cs index 9372f309f..5dcba7231 100644 --- a/src/ViewModels/Pull.cs +++ b/src/ViewModels/Pull.cs @@ -42,7 +42,7 @@ public bool DiscardLocalChanges { get; set; - } = false; + } public bool UseRebase { @@ -211,9 +211,9 @@ private void PostRemoteSelected() SelectedBranch = null; } - private readonly Repository _repo = null; - private Models.Remote _selectedRemote = null; - private List _remoteBranches = null; - private Models.Branch _selectedBranch = null; + private readonly Repository _repo; + private Models.Remote _selectedRemote; + private List _remoteBranches; + private Models.Branch _selectedBranch; } } diff --git a/src/ViewModels/Push.cs b/src/ViewModels/Push.cs index 85969ee5a..3fb2993cb 100644 --- a/src/ViewModels/Push.cs +++ b/src/ViewModels/Push.cs @@ -229,11 +229,11 @@ private void AutoSelectBranchByRemote() SelectedRemoteBranch = fake; } - private readonly Repository _repo = null; - private Models.Branch _selectedLocalBranch = null; - private Models.Remote _selectedRemote = null; + private readonly Repository _repo; + private Models.Branch _selectedLocalBranch; + private Models.Remote _selectedRemote; private List _remoteBranches = []; - private Models.Branch _selectedRemoteBranch = null; - private bool _isSetTrackOptionVisible = false; + private Models.Branch _selectedRemoteBranch; + private bool _isSetTrackOptionVisible; } } diff --git a/src/ViewModels/PushTag.cs b/src/ViewModels/PushTag.cs index f2bb4500b..66fa2c434 100644 --- a/src/ViewModels/PushTag.cs +++ b/src/ViewModels/PushTag.cs @@ -67,7 +67,7 @@ public override async Task Sure() return succ; } - private readonly Repository _repo = null; - private bool _pushAllRemotes = false; + private readonly Repository _repo; + private bool _pushAllRemotes; } } diff --git a/src/ViewModels/RemoveWorktree.cs b/src/ViewModels/RemoveWorktree.cs index a78cedc2f..c79f0d798 100644 --- a/src/ViewModels/RemoveWorktree.cs +++ b/src/ViewModels/RemoveWorktree.cs @@ -13,7 +13,7 @@ public bool Force { get; set; - } = false; + } public RemoveWorktree(Repository repo, Models.Worktree target) { @@ -38,6 +38,6 @@ public override async Task Sure() return succ; } - private readonly Repository _repo = null; + private readonly Repository _repo; } } diff --git a/src/ViewModels/Repository.cs b/src/ViewModels/Repository.cs index 0bf077286..3042563f6 100644 --- a/src/ViewModels/Repository.cs +++ b/src/ViewModels/Repository.cs @@ -470,7 +470,7 @@ public int CommitDetailActivePageIndex { get; set; - } = 0; + } public AvaloniaList Logs { @@ -3049,51 +3049,51 @@ private async void AutoFetchImpl(object sender) private string _fullpath = string.Empty; private string _gitDir = string.Empty; - private Models.RepositorySettings _settings = null; + private Models.RepositorySettings _settings; private Models.FilterMode _historiesFilterMode = Models.FilterMode.None; - private bool _hasAllowedSignersFile = false; + private bool _hasAllowedSignersFile; - private Models.Watcher _watcher = null; - private Histories _histories = null; - private WorkingCopy _workingCopy = null; - private StashesPage _stashesPage = null; - private int _selectedViewIndex = 0; - private object _selectedView = null; + private Models.Watcher _watcher; + private Histories _histories; + private WorkingCopy _workingCopy; + private StashesPage _stashesPage; + private int _selectedViewIndex; + private object _selectedView; - private int _localBranchesCount = 0; - private int _localChangesCount = 0; - private int _stashesCount = 0; + private int _localBranchesCount; + private int _localChangesCount; + private int _stashesCount; - private bool _isSearching = false; - private bool _isSearchLoadingVisible = false; + private bool _isSearching; + private bool _isSearchLoadingVisible; private int _searchCommitFilterType = (int)Models.CommitSearchMethod.ByMessage; - private bool _onlySearchCommitsInCurrentBranch = false; + private bool _onlySearchCommitsInCurrentBranch; private string _searchCommitFilter = string.Empty; private List _searchedCommits = new List(); - private Models.Commit _selectedSearchedCommit = null; - private bool _requestingWorktreeFiles = false; - private List _worktreeFiles = null; - private List _matchedFilesForSearching = null; + private Models.Commit _selectedSearchedCommit; + private bool _requestingWorktreeFiles; + private List _worktreeFiles; + private List _matchedFilesForSearching; private string _filter = string.Empty; private readonly Lock _lockRemotes = new(); private List _remotes = new List(); private List _branches = new List(); - private Models.Branch _currentBranch = null; + private Models.Branch _currentBranch; private List _localBranchTrees = new List(); private List _remoteBranchTrees = new List(); private List _worktrees = new List(); private List _tags = new List(); - private object _visibleTags = null; + private object _visibleTags; private List _submodules = new List(); - private object _visibleSubmodules = null; + private object _visibleSubmodules; - private bool _isAutoFetching = false; - private Timer _autoFetchTimer = null; + private bool _isAutoFetching; + private Timer _autoFetchTimer; private DateTime _lastFetchTime = DateTime.MinValue; private Models.BisectState _bisectState = Models.BisectState.None; - private bool _isBisectCommandRunning = false; + private bool _isBisectCommandRunning; private string _navigateToCommitDelayed = string.Empty; } diff --git a/src/ViewModels/RepositoryConfigure.cs b/src/ViewModels/RepositoryConfigure.cs index 4bf5731f2..2fc5a44b8 100644 --- a/src/ViewModels/RepositoryConfigure.cs +++ b/src/ViewModels/RepositoryConfigure.cs @@ -335,11 +335,11 @@ private async Task SetIfChangedAsync(string key, string value, string defValue) await new Commands.Config(_repo.FullPath).SetAsync(key, value); } - private readonly Repository _repo = null; - private readonly Dictionary _cached = null; + private readonly Repository _repo; + private readonly Dictionary _cached; private string _httpProxy; - private Models.CommitTemplate _selectedCommitTemplate = null; - private Models.IssueTrackerRule _selectedIssueTrackerRule = null; - private Models.CustomAction _selectedCustomAction = null; + private Models.CommitTemplate _selectedCommitTemplate; + private Models.IssueTrackerRule _selectedIssueTrackerRule; + private Models.CustomAction _selectedCustomAction; } } diff --git a/src/ViewModels/RepositoryNode.cs b/src/ViewModels/RepositoryNode.cs index c65d1dbd0..73ea5229f 100644 --- a/src/ViewModels/RepositoryNode.cs +++ b/src/ViewModels/RepositoryNode.cs @@ -60,7 +60,7 @@ public int Depth { get; set; - } = 0; + } public List SubNodes { @@ -105,9 +105,9 @@ public void Delete() private string _id = string.Empty; private string _name = string.Empty; - private bool _isRepository = false; - private int _bookmark = 0; - private bool _isExpanded = false; + private bool _isRepository; + private int _bookmark; + private bool _isExpanded; private bool _isVisible = true; } } diff --git a/src/ViewModels/Reset.cs b/src/ViewModels/Reset.cs index 5a628b1ea..de662c895 100644 --- a/src/ViewModels/Reset.cs +++ b/src/ViewModels/Reset.cs @@ -45,6 +45,6 @@ public override async Task Sure() return succ; } - private readonly Repository _repo = null; + private readonly Repository _repo; } } diff --git a/src/ViewModels/ResetWithoutCheckout.cs b/src/ViewModels/ResetWithoutCheckout.cs index e1cfd7304..8dcc325d7 100644 --- a/src/ViewModels/ResetWithoutCheckout.cs +++ b/src/ViewModels/ResetWithoutCheckout.cs @@ -48,7 +48,7 @@ public override async Task Sure() return succ; } - private readonly Repository _repo = null; + private readonly Repository _repo; private readonly string _revision; } } diff --git a/src/ViewModels/Revert.cs b/src/ViewModels/Revert.cs index b39076a09..6ca91d521 100644 --- a/src/ViewModels/Revert.cs +++ b/src/ViewModels/Revert.cs @@ -40,6 +40,6 @@ public override async Task Sure() return true; } - private readonly Repository _repo = null; + private readonly Repository _repo; } } diff --git a/src/ViewModels/RevisionCompare.cs b/src/ViewModels/RevisionCompare.cs index affa79665..e034bc018 100644 --- a/src/ViewModels/RevisionCompare.cs +++ b/src/ViewModels/RevisionCompare.cs @@ -244,12 +244,12 @@ private string GetSHA(object obj) } private string _repo; - private object _startPoint = null; - private object _endPoint = null; - private List _changes = null; - private List _visibleChanges = null; - private List _selectedChanges = null; + private object _startPoint; + private object _endPoint; + private List _changes; + private List _visibleChanges; + private List _selectedChanges; private string _searchFilter = string.Empty; - private DiffContext _diffContext = null; + private DiffContext _diffContext; } } diff --git a/src/ViewModels/RevisionFileTreeNode.cs b/src/ViewModels/RevisionFileTreeNode.cs index 2f94d40d9..51625f450 100644 --- a/src/ViewModels/RevisionFileTreeNode.cs +++ b/src/ViewModels/RevisionFileTreeNode.cs @@ -7,8 +7,8 @@ namespace SourceGit.ViewModels { public class RevisionFileTreeNode : ObservableObject { - public Models.Object Backend { get; set; } = null; - public int Depth { get; set; } = 0; + public Models.Object Backend { get; set; } + public int Depth { get; set; } public List Children { get; set; } = new List(); public string Name @@ -27,6 +27,6 @@ public bool IsExpanded set => SetProperty(ref _isExpanded, value); } - private bool _isExpanded = false; + private bool _isExpanded; } } diff --git a/src/ViewModels/RevisionLFSImage.cs b/src/ViewModels/RevisionLFSImage.cs index 2cdd8e665..ce201a001 100644 --- a/src/ViewModels/RevisionLFSImage.cs +++ b/src/ViewModels/RevisionLFSImage.cs @@ -29,6 +29,6 @@ public RevisionLFSImage(string repo, string file, Models.LFSObject lfs, Models.I }); } - private Models.RevisionImageFile _image = null; + private Models.RevisionImageFile _image; } } diff --git a/src/ViewModels/ScanRepositories.cs b/src/ViewModels/ScanRepositories.cs index b01547707..3c48e83af 100644 --- a/src/ViewModels/ScanRepositories.cs +++ b/src/ViewModels/ScanRepositories.cs @@ -161,7 +161,7 @@ private RepositoryNode FindOrCreateGroup(List collection, string return added; } - private HashSet _managed = new(); - private Models.ScanDir _selected = null; + private readonly HashSet _managed = new(); + private Models.ScanDir _selected; } } diff --git a/src/ViewModels/SelfUpdate.cs b/src/ViewModels/SelfUpdate.cs index 3b471576b..5604fd2cb 100644 --- a/src/ViewModels/SelfUpdate.cs +++ b/src/ViewModels/SelfUpdate.cs @@ -10,6 +10,6 @@ public object Data set => SetProperty(ref _data, value); } - private object _data = null; + private object _data; } } diff --git a/src/ViewModels/SetUpstream.cs b/src/ViewModels/SetUpstream.cs index 8a7611d1a..b5d8aee30 100644 --- a/src/ViewModels/SetUpstream.cs +++ b/src/ViewModels/SetUpstream.cs @@ -72,6 +72,6 @@ public override async Task Sure() } private readonly Repository _repo; - private bool _unset = false; + private bool _unset; } } diff --git a/src/ViewModels/StashChanges.cs b/src/ViewModels/StashChanges.cs index 62e942f75..4d74474f4 100644 --- a/src/ViewModels/StashChanges.cs +++ b/src/ViewModels/StashChanges.cs @@ -152,7 +152,7 @@ private enum DealWithChangesAfterStashing KeepAll, } - private readonly Repository _repo = null; - private readonly List _changes = null; + private readonly Repository _repo; + private readonly List _changes; } } diff --git a/src/ViewModels/StashesPage.cs b/src/ViewModels/StashesPage.cs index 414fb055d..edc9015d4 100644 --- a/src/ViewModels/StashesPage.cs +++ b/src/ViewModels/StashesPage.cs @@ -339,14 +339,14 @@ private void RefreshVisible() } } - private Repository _repo = null; + private Repository _repo; private List _stashes = []; private List _visibleStashes = []; private string _searchFilter = string.Empty; - private Models.Stash _selectedStash = null; - private List _changes = null; + private Models.Stash _selectedStash; + private List _changes; private List _untracked = []; private List _selectedChanges = []; - private DiffContext _diffContext = null; + private DiffContext _diffContext; } } diff --git a/src/ViewModels/Statistics.cs b/src/ViewModels/Statistics.cs index a16c94ecc..e69d9de64 100644 --- a/src/ViewModels/Statistics.cs +++ b/src/ViewModels/Statistics.cs @@ -85,8 +85,8 @@ private void RefreshReport() } private bool _isLoading = true; - private Models.Statistics _data = null; - private Models.StatisticsReport _selectedReport = null; - private int _selectedIndex = 0; + private Models.Statistics _data; + private Models.StatisticsReport _selectedReport; + private int _selectedIndex; } } diff --git a/src/ViewModels/SubmoduleCollection.cs b/src/ViewModels/SubmoduleCollection.cs index ee3406075..4037a2d85 100644 --- a/src/ViewModels/SubmoduleCollection.cs +++ b/src/ViewModels/SubmoduleCollection.cs @@ -9,10 +9,10 @@ namespace SourceGit.ViewModels public class SubmoduleTreeNode : ObservableObject { public string FullPath { get; private set; } = string.Empty; - public int Depth { get; private set; } = 0; - public Models.Submodule Module { get; private set; } = null; + public int Depth { get; private set; } + public Models.Submodule Module { get; private set; } public List Children { get; private set; } = []; - public int Counter = 0; + public int Counter; public bool IsFolder { @@ -116,7 +116,7 @@ private static void InsertFolder(List collection, SubmoduleTr collection.Add(subFolder); } - private bool _isExpanded = false; + private bool _isExpanded; } public class SubmoduleCollectionAsTree diff --git a/src/ViewModels/TagCollection.cs b/src/ViewModels/TagCollection.cs index 0848be1d8..ca3c07c40 100644 --- a/src/ViewModels/TagCollection.cs +++ b/src/ViewModels/TagCollection.cs @@ -23,11 +23,11 @@ public TagTreeNodeToolTip(Models.Tag t) public class TagTreeNode : ObservableObject { public string FullPath { get; private set; } - public int Depth { get; private set; } = 0; - public Models.Tag Tag { get; private set; } = null; - public TagTreeNodeToolTip ToolTip { get; private set; } = null; + public int Depth { get; private set; } + public Models.Tag Tag { get; private set; } + public TagTreeNodeToolTip ToolTip { get; private set; } public List Children { get; private set; } = []; - public int Counter { get; set; } = 0; + public int Counter { get; set; } public bool IsFolder { diff --git a/src/ViewModels/TwoSideTextDiff.cs b/src/ViewModels/TwoSideTextDiff.cs index 3fb1e63b3..86a13c191 100644 --- a/src/ViewModels/TwoSideTextDiff.cs +++ b/src/ViewModels/TwoSideTextDiff.cs @@ -12,7 +12,7 @@ public class TwoSideTextDiff : ObservableObject public string File { get; set; } public List Old { get; set; } = new List(); public List New { get; set; } = new List(); - public int MaxLineNumber = 0; + public int MaxLineNumber; public Vector SyncScrollOffset { diff --git a/src/ViewModels/UpdateSubmodules.cs b/src/ViewModels/UpdateSubmodules.cs index 78bb1febd..688054760 100644 --- a/src/ViewModels/UpdateSubmodules.cs +++ b/src/ViewModels/UpdateSubmodules.cs @@ -43,7 +43,7 @@ public bool EnableRemote { get; set; - } = false; + } public UpdateSubmodules(Repository repo, Models.Submodule selected) { @@ -92,7 +92,7 @@ public override async Task Sure() return true; } - private readonly Repository _repo = null; + private readonly Repository _repo; private bool _updateAll = true; } } diff --git a/src/ViewModels/ViewLogs.cs b/src/ViewModels/ViewLogs.cs index 21ab81ab7..68a9b3e36 100644 --- a/src/ViewModels/ViewLogs.cs +++ b/src/ViewModels/ViewLogs.cs @@ -27,7 +27,7 @@ public void ClearAll() Logs.Clear(); } - private Repository _repo = null; - private CommandLog _selectedLog = null; + private readonly Repository _repo; + private CommandLog _selectedLog; } } diff --git a/src/ViewModels/WorkingCopy.cs b/src/ViewModels/WorkingCopy.cs index d8ec3326d..dfd4e45db 100644 --- a/src/ViewModels/WorkingCopy.cs +++ b/src/ViewModels/WorkingCopy.cs @@ -2062,14 +2062,14 @@ private enum CommitCheckPassed FileCount, } - private Repository _repo = null; - private bool _isLoadingData = false; - private bool _isStaging = false; - private bool _isUnstaging = false; - private bool _isCommitting = false; - private bool _useAmend = false; - private bool _resetAuthor = false; - private bool _hasRemotes = false; + private Repository _repo; + private bool _isLoadingData; + private bool _isStaging; + private bool _isUnstaging; + private bool _isCommitting; + private bool _useAmend; + private bool _resetAuthor; + private bool _hasRemotes; private List _cached = []; private List _unstaged = []; private List _visibleUnstaged = []; @@ -2077,11 +2077,11 @@ private enum CommitCheckPassed private List _visibleStaged = []; private List _selectedUnstaged = []; private List _selectedStaged = []; - private object _detailContext = null; + private object _detailContext; private string _filter = string.Empty; private string _commitMessage = string.Empty; - private bool _hasUnsolvedConflicts = false; - private InProgressContext _inProgressContext = null; + private bool _hasUnsolvedConflicts; + private InProgressContext _inProgressContext; } } diff --git a/src/ViewModels/Workspace.cs b/src/ViewModels/Workspace.cs index 3ae935c76..8906efe96 100644 --- a/src/ViewModels/Workspace.cs +++ b/src/ViewModels/Workspace.cs @@ -32,7 +32,7 @@ public int ActiveIdx { get; set; - } = 0; + } public bool IsActive { @@ -59,7 +59,7 @@ public IBrush Brush private string _name = string.Empty; private uint _color = 4278221015; - private bool _isActive = false; + private bool _isActive; private bool _restoreOnStartup = true; private string _defaultCloneDir = string.Empty; } diff --git a/src/ViewModels/WorkspaceSwitcher.cs b/src/ViewModels/WorkspaceSwitcher.cs index 7a2da9bee..fb14aeb57 100644 --- a/src/ViewModels/WorkspaceSwitcher.cs +++ b/src/ViewModels/WorkspaceSwitcher.cs @@ -72,9 +72,9 @@ private void UpdateVisibleWorkspaces() SelectedWorkspace = visible.Count == 0 ? null : visible[0]; } - private Launcher _launcher = null; - private List _visibleWorkspaces = null; + private readonly Launcher _launcher; + private List _visibleWorkspaces; private string _searchFilter = string.Empty; - private Workspace _selectedWorkspace = null; + private Workspace _selectedWorkspace; } } diff --git a/src/Views/AIAssistant.axaml.cs b/src/Views/AIAssistant.axaml.cs index 48dbb9008..4a4398ef2 100644 --- a/src/Views/AIAssistant.axaml.cs +++ b/src/Views/AIAssistant.axaml.cs @@ -106,7 +106,7 @@ private void OnTextViewContextRequested(object sender, ContextRequestedEventArgs e.Handled = true; } - private TextMate.Installation _textMate = null; + private TextMate.Installation _textMate; } public partial class AIAssistant : ChromelessWindow diff --git a/src/Views/Avatar.cs b/src/Views/Avatar.cs index dcb3591da..47a1bac14 100644 --- a/src/Views/Avatar.cs +++ b/src/Views/Avatar.cs @@ -220,6 +220,6 @@ private void OnContextRequested(object sender, ContextRequestedEventArgs e) menu.Open(this); } - private Bitmap _img = null; + private Bitmap _img; } } diff --git a/src/Views/BisectStateIndicator.cs b/src/Views/BisectStateIndicator.cs index 0a581f532..16115cf94 100644 --- a/src/Views/BisectStateIndicator.cs +++ b/src/Views/BisectStateIndicator.cs @@ -132,9 +132,9 @@ private void RenderImpl(DrawingContext context, IBrush brush, Geometry icon, dou context.DrawGeometry(Foreground, null, icon); } - private Geometry _prefix = null; - private Geometry _good = null; - private Geometry _bad = null; + private Geometry _prefix; + private Geometry _good; + private Geometry _bad; private Models.BisectCommitFlag _flags = Models.BisectCommitFlag.None; } } diff --git a/src/Views/Blame.axaml.cs b/src/Views/Blame.axaml.cs index 362dc0247..72c864691 100644 --- a/src/Views/Blame.axaml.cs +++ b/src/Views/Blame.axaml.cs @@ -232,7 +232,7 @@ protected override void OnPointerPressed(PointerPressedEventArgs e) } } - private readonly BlameTextEditor _editor = null; + private readonly BlameTextEditor _editor; } public class VerticalSeparatorMargin : AbstractMargin @@ -253,7 +253,7 @@ protected override Size MeasureOverride(Size availableSize) return new Size(1, 0); } - private readonly BlameTextEditor _editor = null; + private readonly BlameTextEditor _editor; } public static readonly StyledProperty BlameDataProperty = @@ -421,7 +421,7 @@ private void OnTextViewVisualLinesChanged(object sender, EventArgs e) InvalidateVisual(); } - private TextMate.Installation _textMate = null; + private TextMate.Installation _textMate; private string _highlight = string.Empty; } diff --git a/src/Views/BranchTree.axaml.cs b/src/Views/BranchTree.axaml.cs index 891efa4fc..6d41bf99c 100644 --- a/src/Views/BranchTree.axaml.cs +++ b/src/Views/BranchTree.axaml.cs @@ -197,7 +197,7 @@ protected override Size MeasureOverride(Size availableSize) return _label != null ? new Size(_label.Width + 18 /* Padding */ + 16 /* Margin */, 18) : new Size(0, 0); } - private FormattedText _label = null; + private FormattedText _label; } public partial class BranchTree : UserControl @@ -585,6 +585,6 @@ private void FindTreePath(List outPath, List typeof(Window); diff --git a/src/Views/ColorPicker.cs b/src/Views/ColorPicker.cs index 606a913ec..76e3fcab0 100644 --- a/src/Views/ColorPicker.cs +++ b/src/Views/ColorPicker.cs @@ -225,16 +225,16 @@ private Color GetNextColor(HsvColor c, double step) return newColor.ToRgb(); } - private BoxShadows _shadow = BoxShadows.Parse("0 0 6 0 #A9000000"); - - private Rect _colorTableRect = new Rect(0, 0, 32 * 8, 32 * 6); - private RoundedRect _darkestRect = new RoundedRect(new Rect(0, 200, 32, 32), new CornerRadius(4, 0, 0, 4)); - private Rect _darkerRect = new Rect(32, 200, 32, 32); - private Rect _darkRect = new Rect(64, 200, 32, 32); - private Rect _lightRect = new Rect(160, 200, 32, 32); - private Rect _lighterRect = new Rect(192, 200, 32, 32); - private RoundedRect _lightestRect = new RoundedRect(new Rect(224, 200, 32, 32), new CornerRadius(0, 4, 4, 0)); - private Rect? _highlightedTableRect = null; + private readonly BoxShadows _shadow = BoxShadows.Parse("0 0 6 0 #A9000000"); + + private readonly Rect _colorTableRect = new Rect(0, 0, 32 * 8, 32 * 6); + private readonly RoundedRect _darkestRect = new RoundedRect(new Rect(0, 200, 32, 32), new CornerRadius(4, 0, 0, 4)); + private readonly Rect _darkerRect = new Rect(32, 200, 32, 32); + private readonly Rect _darkRect = new Rect(64, 200, 32, 32); + private readonly Rect _lightRect = new Rect(160, 200, 32, 32); + private readonly Rect _lighterRect = new Rect(192, 200, 32, 32); + private readonly RoundedRect _lightestRect = new RoundedRect(new Rect(224, 200, 32, 32), new CornerRadius(0, 4, 4, 0)); + private Rect? _highlightedTableRect; private Color _darkestColor; private Color _darkerColor; diff --git a/src/Views/CommandLogContentPresenter.cs b/src/Views/CommandLogContentPresenter.cs index a2499f8d8..d7ecc43ac 100644 --- a/src/Views/CommandLogContentPresenter.cs +++ b/src/Views/CommandLogContentPresenter.cs @@ -147,6 +147,6 @@ private void OnLogLineReceived(string newline) AppendText(newline); } - private TextMate.Installation _textMate = null; + private TextMate.Installation _textMate; } } diff --git a/src/Views/CommandLogTime.cs b/src/Views/CommandLogTime.cs index 0e51c1e32..5b260af81 100644 --- a/src/Views/CommandLogTime.cs +++ b/src/Views/CommandLogTime.cs @@ -75,6 +75,6 @@ private string GetDisplayText(ViewModels.CommandLog log) return $"{log.StartTime:T} ({duration})"; } - private Timer _refreshTimer = null; + private Timer _refreshTimer; } } diff --git a/src/Views/CommitMessageEditor.axaml.cs b/src/Views/CommitMessageEditor.axaml.cs index ee29fb1c7..66d5a238f 100644 --- a/src/Views/CommitMessageEditor.axaml.cs +++ b/src/Views/CommitMessageEditor.axaml.cs @@ -51,7 +51,7 @@ private void SaveAndClose(object _1, RoutedEventArgs _2) Close(); } - private Action _onSave = null; + private Action _onSave; private bool _shouldExitApp = true; private int _exitCode = -1; } diff --git a/src/Views/CommitMessagePresenter.cs b/src/Views/CommitMessagePresenter.cs index ea1b98f27..16e1323d6 100644 --- a/src/Views/CommitMessagePresenter.cs +++ b/src/Views/CommitMessagePresenter.cs @@ -299,7 +299,7 @@ private void ClearHoveredIssueLink() } } - private Models.InlineElement _lastHover = null; - private Dictionary _inlineCommits = new(); + private Models.InlineElement _lastHover; + private readonly Dictionary _inlineCommits = new(); } } diff --git a/src/Views/CommitRefsPresenter.cs b/src/Views/CommitRefsPresenter.cs index d221c155a..3ad4f628c 100644 --- a/src/Views/CommitRefsPresenter.cs +++ b/src/Views/CommitRefsPresenter.cs @@ -12,12 +12,12 @@ public class CommitRefsPresenter : Control { public class RenderItem { - public Geometry Icon { get; set; } = null; - public FormattedText Label { get; set; } = null; - public IBrush Brush { get; set; } = null; - public bool IsHead { get; set; } = false; - public double Width { get; set; } = 0.0; - public Models.Decorator Decorator { get; set; } = null; + public Geometry Icon { get; set; } + public FormattedText Label { get; set; } + public IBrush Brush { get; set; } + public bool IsHead { get; set; } + public double Width { get; set; } + public Models.Decorator Decorator { get; set; } } public static readonly StyledProperty FontFamilyProperty = @@ -268,6 +268,6 @@ protected override Size MeasureOverride(Size availableSize) return new Size(0, 0); } - private List _items = new List(); + private readonly List _items = new List(); } } diff --git a/src/Views/CommitSubjectPresenter.cs b/src/Views/CommitSubjectPresenter.cs index 5fc4cb5d7..117903425 100644 --- a/src/Views/CommitSubjectPresenter.cs +++ b/src/Views/CommitSubjectPresenter.cs @@ -339,9 +339,9 @@ private void ClearHoveredIssueLink() private class Inline { - public double X { get; set; } = 0; - public FormattedText Text { get; set; } = null; - public Models.InlineElement Element { get; set; } = null; + public double X { get; set; } + public FormattedText Text { get; set; } + public Models.InlineElement Element { get; set; } public Inline(double x, FormattedText text, Models.InlineElement elem) { @@ -351,9 +351,9 @@ public Inline(double x, FormattedText text, Models.InlineElement elem) } } - private Models.InlineElementCollector _elements = new(); - private List _inlines = []; - private Models.InlineElement _lastHover = null; - private bool _needRebuildInlines = false; + private readonly Models.InlineElementCollector _elements = new(); + private readonly List _inlines = []; + private Models.InlineElement _lastHover; + private bool _needRebuildInlines; } } diff --git a/src/Views/CommitTimeTextBlock.cs b/src/Views/CommitTimeTextBlock.cs index f83741776..4e6a3d845 100644 --- a/src/Views/CommitTimeTextBlock.cs +++ b/src/Views/CommitTimeTextBlock.cs @@ -167,6 +167,6 @@ private string GetDisplayText() return App.Text("Period.YearsAgo", diffYear); } - private IDisposable _refreshTimer = null; + private IDisposable _refreshTimer; } } diff --git a/src/Views/Histories.axaml.cs b/src/Views/Histories.axaml.cs index bb9433562..b56cd54dd 100644 --- a/src/Views/Histories.axaml.cs +++ b/src/Views/Histories.axaml.cs @@ -293,8 +293,8 @@ sender is DataGrid grid && } } - private double _lastGraphStartY = 0; - private double _lastGraphClipWidth = 0; - private double _lastGraphRowHeight = 0; + private double _lastGraphStartY; + private double _lastGraphClipWidth; + private double _lastGraphRowHeight; } } diff --git a/src/Views/ImageContainer.cs b/src/Views/ImageContainer.cs index 995f269bf..980be2530 100644 --- a/src/Views/ImageContainer.cs +++ b/src/Views/ImageContainer.cs @@ -49,7 +49,7 @@ protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs chang } } - private DrawingBrush _bgBrush = null; + private DrawingBrush _bgBrush; } public class ImageView : ImageContainer @@ -243,8 +243,8 @@ private void RenderSingleSide(DrawingContext context, Bitmap img, Rect clip) context.DrawImage(img, src, dst); } - private bool _pressedOnSlider = false; - private bool _lastInSlider = false; + private bool _pressedOnSlider; + private bool _lastInSlider; } public class ImageBlendControl : ImageContainer diff --git a/src/Views/LauncherTabBar.axaml.cs b/src/Views/LauncherTabBar.axaml.cs index 64350e42f..2d7b320f7 100644 --- a/src/Views/LauncherTabBar.axaml.cs +++ b/src/Views/LauncherTabBar.axaml.cs @@ -362,8 +362,8 @@ private void UpdateSelectablePages() } } - private bool _pressedTab = false; - private Point _pressedTabPosition = new Point(); - private bool _startDragTab = false; + private bool _pressedTab; + private Point _pressedTabPosition; + private bool _startDragTab; } } diff --git a/src/Views/PopupRunningStatus.axaml.cs b/src/Views/PopupRunningStatus.axaml.cs index 05258799b..0955bf0d7 100644 --- a/src/Views/PopupRunningStatus.axaml.cs +++ b/src/Views/PopupRunningStatus.axaml.cs @@ -63,6 +63,6 @@ private void StopAnim() ProgressBar.IsIndeterminate = false; } - private bool _isUnloading = false; + private bool _isUnloading; } } diff --git a/src/Views/Preferences.axaml.cs b/src/Views/Preferences.axaml.cs index a6b4b7221..ede535ff2 100644 --- a/src/Views/Preferences.axaml.cs +++ b/src/Views/Preferences.axaml.cs @@ -27,7 +27,7 @@ public Models.CRLFMode CRLFMode { get; set; - } = null; + } public bool EnablePruneOnFetch { @@ -93,7 +93,7 @@ public bool EnableHTTPSSLVerify { get; set; - } = false; + } public static readonly StyledProperty SelectedOpenAIServiceProperty = AvaloniaProperty.Register(nameof(SelectedOpenAIService)); diff --git a/src/Views/Repository.axaml.cs b/src/Views/Repository.axaml.cs index 94149325d..d522f163e 100644 --- a/src/Views/Repository.axaml.cs +++ b/src/Views/Repository.axaml.cs @@ -97,7 +97,7 @@ protected override Size MeasureOverride(Size availableSize) return _label != null ? new Size(_label.Width + 18, 18) : new Size(0, 0); } - private FormattedText _label = null; + private FormattedText _label; } public partial class Repository : UserControl diff --git a/src/Views/RevisionFileContentViewer.axaml.cs b/src/Views/RevisionFileContentViewer.axaml.cs index acb2017f3..f38c8f461 100644 --- a/src/Views/RevisionFileContentViewer.axaml.cs +++ b/src/Views/RevisionFileContentViewer.axaml.cs @@ -151,7 +151,7 @@ private void UpdateTextMate() } } - private TextMate.Installation _textMate = null; + private TextMate.Installation _textMate; } public partial class RevisionFileContentViewer : UserControl diff --git a/src/Views/RevisionFileTreeView.axaml.cs b/src/Views/RevisionFileTreeView.axaml.cs index e73e9efb7..147f575f3 100644 --- a/src/Views/RevisionFileTreeView.axaml.cs +++ b/src/Views/RevisionFileTreeView.axaml.cs @@ -387,8 +387,8 @@ private void SortNodes(List nodes) }); } - private List _tree = []; - private bool _disableSelectionChangingEvent = false; - private List _searchResult = []; + private readonly List _tree = []; + private readonly List _searchResult = []; + private bool _disableSelectionChangingEvent; } } diff --git a/src/Views/SelfUpdate.axaml.cs b/src/Views/SelfUpdate.axaml.cs index 97f1bc772..ef50d1bc7 100644 --- a/src/Views/SelfUpdate.axaml.cs +++ b/src/Views/SelfUpdate.axaml.cs @@ -59,7 +59,7 @@ protected override void OnDataContextChanged(EventArgs e) Text = ver.Body; } - private TextMate.Installation _textMate = null; + private TextMate.Installation _textMate; } public partial class SelfUpdate : ChromelessWindow diff --git a/src/Views/TextDiffView.axaml.cs b/src/Views/TextDiffView.axaml.cs index 6b65dba29..5a3ec9721 100644 --- a/src/Views/TextDiffView.axaml.cs +++ b/src/Views/TextDiffView.axaml.cs @@ -25,12 +25,12 @@ namespace SourceGit.Views { public class TextDiffViewChunk { - public double Y { get; set; } = 0.0; - public double Height { get; set; } = 0.0; - public int StartIdx { get; set; } = 0; - public int EndIdx { get; set; } = 0; + public double Y { get; set; } + public double Height { get; set; } + public int StartIdx { get; set; } + public int EndIdx { get; set; } public bool Combined { get; set; } = true; - public bool IsOldSide { get; set; } = false; + public bool IsOldSide { get; set; } public bool ShouldReplace(TextDiffViewChunk old) { @@ -48,8 +48,8 @@ public bool ShouldReplace(TextDiffViewChunk old) public record TextDiffViewRange { - public int StartIdx { get; set; } = 0; - public int EndIdx { get; set; } = 0; + public int StartIdx { get; set; } + public int EndIdx { get; set; } public TextDiffViewRange(int startIdx, int endIdx) { @@ -155,8 +155,8 @@ protected override void OnDataContextChanged(EventArgs e) InvalidateMeasure(); } - private bool _usePresenter = false; - private bool _isOld = false; + private readonly bool _usePresenter; + private readonly bool _isOld; } public class LineModifyTypeMargin : AbstractMargin @@ -341,7 +341,7 @@ private IBrush GetBrushByLineType(Models.TextDiffLineType type) }; } - private ThemedTextDiffPresenter _presenter = null; + private readonly ThemedTextDiffPresenter _presenter; } public class LineStyleTransformer(ThemedTextDiffPresenter presenter) : DocumentColorizingTransformer @@ -1053,10 +1053,10 @@ private async Task CopyWithoutIndicatorsAsync() await App.CopyTextAsync(builder.ToString()); } - private TextMate.Installation _textMate = null; + private TextMate.Installation _textMate; private TextLocation _lastSelectStart = TextLocation.Empty; private TextLocation _lastSelectEnd = TextLocation.Empty; - private LineStyleTransformer _lineStyleTransformer = null; + private readonly LineStyleTransformer _lineStyleTransformer; } public class CombinedTextDiffPresenter : ThemedTextDiffPresenter @@ -1260,7 +1260,7 @@ private void OnTextViewScrollChanged(object sender, ScrollChangedEventArgs e) TrySetChunk(null); } - private ScrollViewer _scrollViewer = null; + private ScrollViewer _scrollViewer; } public class SingleSideTextDiffPresenter : ThemedTextDiffPresenter @@ -1510,7 +1510,7 @@ private void DirectSyncScrollOffset() diff.SyncScrollOffset = _scrollViewer?.Offset ?? Vector.Zero; } - private ScrollViewer _scrollViewer = null; + private ScrollViewer _scrollViewer; } public class TextDiffViewMinimap : Control diff --git a/src/Views/Welcome.axaml.cs b/src/Views/Welcome.axaml.cs index 712e674dd..400c09b2f 100644 --- a/src/Views/Welcome.axaml.cs +++ b/src/Views/Welcome.axaml.cs @@ -277,8 +277,8 @@ private void OnDoubleTappedTreeNode(object sender, TappedEventArgs e) } } - private bool _pressedTreeNode = false; - private Point _pressedTreeNodePosition = new Point(); - private bool _startDragTreeNode = false; + private bool _pressedTreeNode; + private Point _pressedTreeNodePosition; + private bool _startDragTreeNode; } }