code_style: run dotnet format to apply code style rules

This commit is contained in:
leo 2024-07-10 12:11:51 +08:00
parent 0ba58a6e9b
commit e5462f0086
No known key found for this signature in database
15 changed files with 50 additions and 50 deletions

View file

@ -50,9 +50,9 @@ namespace SourceGit
} }
[JsonSourceGenerationOptions( [JsonSourceGenerationOptions(
WriteIndented = true, WriteIndented = true,
IgnoreReadOnlyFields = true, IgnoreReadOnlyFields = true,
IgnoreReadOnlyProperties = true, IgnoreReadOnlyProperties = true,
Converters = [ Converters = [
typeof(ColorConverter), typeof(ColorConverter),
typeof(FontFamilyConverter), typeof(FontFamilyConverter),

View file

@ -458,7 +458,7 @@ namespace SourceGit
var args = desktop.Args; var args = desktop.Args;
if (args.Length != 1 || !args[0].StartsWith("Enter passphrase", StringComparison.Ordinal)) if (args.Length != 1 || !args[0].StartsWith("Enter passphrase", StringComparison.Ordinal))
return false; return false;
desktop.MainWindow = new Views.Askpass(args[0]); desktop.MainWindow = new Views.Askpass(args[0]);
return true; return true;
} }

View file

@ -82,7 +82,7 @@ namespace SourceGit.Commands
var rs = cmd.ReadToEnd(); var rs = cmd.ReadToEnd();
if (rs.IsSuccess) if (rs.IsSuccess)
{ {
var lines = rs.StdOut.Split(new char[] {'\n', '\r'}, StringSplitOptions.RemoveEmptyEntries); var lines = rs.StdOut.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
foreach (var line in lines) foreach (var line in lines)
{ {
var match = REG_LOCK().Match(line); var match = REG_LOCK().Match(line);

View file

@ -22,7 +22,7 @@ namespace SourceGit.Converters
public static readonly FuncValueConverter<int, bool> IsSubjectLengthBad = public static readonly FuncValueConverter<int, bool> IsSubjectLengthBad =
new FuncValueConverter<int, bool>(v => v > ViewModels.Preference.Instance.SubjectGuideLength); new FuncValueConverter<int, bool>(v => v > ViewModels.Preference.Instance.SubjectGuideLength);
public static readonly FuncValueConverter<int, bool> IsSubjectLengthGood = public static readonly FuncValueConverter<int, bool> IsSubjectLengthGood =
new FuncValueConverter<int, bool>(v => v <= ViewModels.Preference.Instance.SubjectGuideLength); new FuncValueConverter<int, bool>(v => v <= ViewModels.Preference.Instance.SubjectGuideLength);

View file

@ -19,7 +19,6 @@ namespace SourceGit.Models
public bool IsMerged { get; set; } = false; public bool IsMerged { get; set; } = false;
public Thickness Margin { get; set; } = new Thickness(0); public Thickness Margin { get; set; } = new Thickness(0);
public string AuthorTimeStr => DateTime.UnixEpoch.AddSeconds(AuthorTime).ToLocalTime().ToString("yyyy/MM/dd HH:mm:ss"); public string AuthorTimeStr => DateTime.UnixEpoch.AddSeconds(AuthorTime).ToLocalTime().ToString("yyyy/MM/dd HH:mm:ss");
public string CommitterTimeStr => DateTime.UnixEpoch.AddSeconds(CommitterTime).ToLocalTime().ToString("yyyy/MM/dd HH:mm:ss"); public string CommitterTimeStr => DateTime.UnixEpoch.AddSeconds(CommitterTime).ToLocalTime().ToString("yyyy/MM/dd HH:mm:ss");
public string AuthorTimeShortStr => DateTime.UnixEpoch.AddSeconds(AuthorTime).ToLocalTime().ToString("yyyy/MM/dd"); public string AuthorTimeShortStr => DateTime.UnixEpoch.AddSeconds(AuthorTime).ToLocalTime().ToString("yyyy/MM/dd");

View file

@ -26,7 +26,7 @@ namespace SourceGit.Models
if (Branch.StartsWith("refs/heads/", System.StringComparison.Ordinal)) if (Branch.StartsWith("refs/heads/", System.StringComparison.Ordinal))
return $"({Branch.Substring(11)})"; return $"({Branch.Substring(11)})";
if (Branch.StartsWith("refs/remotes/", System.StringComparison.Ordinal)) if (Branch.StartsWith("refs/remotes/", System.StringComparison.Ordinal))
return $"({Branch.Substring(13)})"; return $"({Branch.Substring(13)})";

View file

@ -18,19 +18,19 @@ namespace SourceGit.ViewModels
public bool IsFiltered { get; set; } = false; public bool IsFiltered { get; set; } = false;
public bool IsSelected { get; set; } = false; public bool IsSelected { get; set; } = false;
public List<BranchTreeNode> Children { get; private set; } = new List<BranchTreeNode>(); public List<BranchTreeNode> Children { get; private set; } = new List<BranchTreeNode>();
public bool IsExpanded public bool IsExpanded
{ {
get => _isExpanded; get => _isExpanded;
set => SetProperty(ref _isExpanded, value); set => SetProperty(ref _isExpanded, value);
} }
public CornerRadius CornerRadius public CornerRadius CornerRadius
{ {
get => _cornerRadius; get => _cornerRadius;
set => SetProperty(ref _cornerRadius, value); set => SetProperty(ref _cornerRadius, value);
} }
public bool IsBranch public bool IsBranch
{ {
get => Backend is Models.Branch; get => Backend is Models.Branch;
@ -55,7 +55,7 @@ namespace SourceGit.ViewModels
{ {
get => Backend is Models.Branch b ? b.FriendlyName : null; get => Backend is Models.Branch b ? b.FriendlyName : null;
} }
private bool _isExpanded = false; private bool _isExpanded = false;
private CornerRadius _cornerRadius = new CornerRadius(4); private CornerRadius _cornerRadius = new CornerRadius(4);
@ -118,11 +118,11 @@ namespace SourceGit.ViewModels
{ {
if (node.Backend is Models.Branch) if (node.Backend is Models.Branch)
continue; continue;
var path = prefix + "/" + node.Name; var path = prefix + "/" + node.Name;
if (node.IsExpanded) if (node.IsExpanded)
_expanded.Add(path); _expanded.Add(path);
CollectExpandedNodes(node.Children, path); CollectExpandedNodes(node.Children, path);
} }
} }
@ -197,7 +197,7 @@ namespace SourceGit.ViewModels
if (l.Backend is Models.Branch) if (l.Backend is Models.Branch)
return r.Backend is Models.Branch ? string.Compare(l.Name, r.Name, StringComparison.Ordinal) : 1; return r.Backend is Models.Branch ? string.Compare(l.Name, r.Name, StringComparison.Ordinal) : 1;
return r.Backend is Models.Branch ? -1 : string.Compare(l.Name, r.Name, StringComparison.Ordinal); return r.Backend is Models.Branch ? -1 : string.Compare(l.Name, r.Name, StringComparison.Ordinal);
}); });

View file

@ -32,7 +32,7 @@ namespace SourceGit.ViewModels
{ {
Pages = new AvaloniaList<LauncherPage>(); Pages = new AvaloniaList<LauncherPage>();
AddNewTab(); AddNewTab();
if (!string.IsNullOrEmpty(startupRepo)) if (!string.IsNullOrEmpty(startupRepo))
{ {
var root = new Commands.QueryRepositoryRootPath(startupRepo).Result(); var root = new Commands.QueryRepositoryRootPath(startupRepo).Result();
@ -272,8 +272,9 @@ namespace SourceGit.ViewModels
public void DispatchNotification(string pageId, string message, bool isError) public void DispatchNotification(string pageId, string message, bool isError)
{ {
var notification = new Notification() { var notification = new Notification()
IsError = isError, {
IsError = isError,
Message = message, Message = message,
}; };

View file

@ -496,7 +496,7 @@ namespace SourceGit.ViewModels
private bool _restoreTabs = false; private bool _restoreTabs = false;
private bool _useFixedTabWidth = true; private bool _useFixedTabWidth = true;
private bool _check4UpdatesOnStartup = true; private bool _check4UpdatesOnStartup = true;
private bool _useTwoColumnsLayoutInHistories = false; private bool _useTwoColumnsLayoutInHistories = false;
private bool _useSideBySideDiff = false; private bool _useSideBySideDiff = false;
private bool _useSyntaxHighlighting = false; private bool _useSyntaxHighlighting = false;

View file

@ -644,7 +644,7 @@ namespace SourceGit.ViewModels
} }
lfs.Items.Add(new MenuItem() { Header = "-" }); lfs.Items.Add(new MenuItem() { Header = "-" });
} }
var lfsLock = new MenuItem(); var lfsLock = new MenuItem();
lfsLock.Header = App.Text("GitLFS.Locks.Lock"); lfsLock.Header = App.Text("GitLFS.Locks.Lock");
@ -678,7 +678,7 @@ namespace SourceGit.ViewModels
}; };
lfsLock.Items.Add(lockRemote); lfsLock.Items.Add(lockRemote);
} }
} }
lfs.Items.Add(lfsLock); lfs.Items.Add(lfsLock);
var lfsUnlock = new MenuItem(); var lfsUnlock = new MenuItem();
@ -713,7 +713,7 @@ namespace SourceGit.ViewModels
}; };
lfsUnlock.Items.Add(unlockRemote); lfsUnlock.Items.Add(unlockRemote);
} }
} }
lfs.Items.Add(lfsUnlock); lfs.Items.Add(lfsUnlock);
menu.Items.Add(lfs); menu.Items.Add(lfs);
@ -1005,7 +1005,7 @@ namespace SourceGit.ViewModels
}; };
lfsLock.Items.Add(lockRemote); lfsLock.Items.Add(lockRemote);
} }
} }
lfs.Items.Add(lfsLock); lfs.Items.Add(lfsLock);
var lfsUnlock = new MenuItem(); var lfsUnlock = new MenuItem();
@ -1040,7 +1040,7 @@ namespace SourceGit.ViewModels
}; };
lfsUnlock.Items.Add(unlockRemote); lfsUnlock.Items.Add(unlockRemote);
} }
} }
lfs.Items.Add(lfsUnlock); lfs.Items.Add(lfsUnlock);
menu.Items.Add(lfs); menu.Items.Add(lfs);

View file

@ -24,7 +24,7 @@ namespace SourceGit.Views
get => GetValue(NodeProperty); get => GetValue(NodeProperty);
set => SetValue(NodeProperty, value); set => SetValue(NodeProperty, value);
} }
public static readonly StyledProperty<bool> IsExpandedProperty = public static readonly StyledProperty<bool> IsExpandedProperty =
AvaloniaProperty.Register<BranchTreeNodeIcon, bool>(nameof(IsExpanded)); AvaloniaProperty.Register<BranchTreeNodeIcon, bool>(nameof(IsExpanded));
@ -51,21 +51,21 @@ namespace SourceGit.Views
if (node.Backend is Models.Remote) if (node.Backend is Models.Remote)
{ {
CreateContent(12, new Thickness(0,2,0,0), "Icons.Remote"); CreateContent(12, new Thickness(0, 2, 0, 0), "Icons.Remote");
} }
else if (node.Backend is Models.Branch branch) else if (node.Backend is Models.Branch branch)
{ {
if (branch.IsCurrent) if (branch.IsCurrent)
CreateContent(12, new Thickness(0,2,0,0), "Icons.Check"); CreateContent(12, new Thickness(0, 2, 0, 0), "Icons.Check");
else else
CreateContent(12, new Thickness(2,0,0,0), "Icons.Branch"); CreateContent(12, new Thickness(2, 0, 0, 0), "Icons.Branch");
} }
else else
{ {
if (node.IsExpanded) if (node.IsExpanded)
CreateContent(10, new Thickness(0,2,0,0), "Icons.Folder.Open"); CreateContent(10, new Thickness(0, 2, 0, 0), "Icons.Folder.Open");
else else
CreateContent(10, new Thickness(0,2,0,0), "Icons.Folder.Fill"); CreateContent(10, new Thickness(0, 2, 0, 0), "Icons.Folder.Fill");
} }
} }
@ -74,7 +74,7 @@ namespace SourceGit.Views
var geo = this.FindResource(iconKey) as StreamGeometry; var geo = this.FindResource(iconKey) as StreamGeometry;
if (geo == null) if (geo == null)
return; return;
Content = new Path() Content = new Path()
{ {
Width = size, Width = size,
@ -86,7 +86,7 @@ namespace SourceGit.Views
}; };
} }
} }
public partial class BranchTree : UserControl public partial class BranchTree : UserControl
{ {
public static readonly StyledProperty<List<ViewModels.BranchTreeNode>> NodesProperty = public static readonly StyledProperty<List<ViewModels.BranchTreeNode>> NodesProperty =
@ -103,7 +103,7 @@ namespace SourceGit.Views
get; get;
private set; private set;
} = new AvaloniaList<ViewModels.BranchTreeNode>(); } = new AvaloniaList<ViewModels.BranchTreeNode>();
public static readonly RoutedEvent<RoutedEventArgs> SelectionChangedEvent = public static readonly RoutedEvent<RoutedEventArgs> SelectionChangedEvent =
RoutedEvent.Register<BranchTree, RoutedEventArgs>(nameof(SelectionChanged), RoutingStrategies.Tunnel | RoutingStrategies.Bubble); RoutedEvent.Register<BranchTree, RoutedEventArgs>(nameof(SelectionChanged), RoutingStrategies.Tunnel | RoutingStrategies.Bubble);
@ -180,7 +180,7 @@ namespace SourceGit.Views
if (item is ViewModels.BranchTreeNode node) if (item is ViewModels.BranchTreeNode node)
node.IsSelected = false; node.IsSelected = false;
} }
var selected = BranchesPresenter.SelectedItems; var selected = BranchesPresenter.SelectedItems;
if (selected == null || selected.Count == 0) if (selected == null || selected.Count == 0)
return; return;
@ -207,16 +207,16 @@ namespace SourceGit.Views
prev = row; prev = row;
} }
RaiseEvent(new RoutedEventArgs(SelectionChangedEvent)); RaiseEvent(new RoutedEventArgs(SelectionChangedEvent));
} }
private void OnTreeContextRequested(object _1, ContextRequestedEventArgs _2) private void OnTreeContextRequested(object _1, ContextRequestedEventArgs _2)
{ {
var repo = DataContext as ViewModels.Repository; var repo = DataContext as ViewModels.Repository;
if (repo?.Settings == null) if (repo?.Settings == null)
return; return;
var selected = BranchesPresenter.SelectedItems; var selected = BranchesPresenter.SelectedItems;
if (selected == null || selected.Count == 0) if (selected == null || selected.Count == 0)
return; return;
@ -280,7 +280,7 @@ namespace SourceGit.Views
var idx = rows.IndexOf(node); var idx = rows.IndexOf(node);
if (idx == -1) if (idx == -1)
return; return;
if (node.IsExpanded) if (node.IsExpanded)
{ {
var subtree = new List<ViewModels.BranchTreeNode>(); var subtree = new List<ViewModels.BranchTreeNode>();
@ -305,7 +305,7 @@ namespace SourceGit.Views
} }
} }
} }
private void OnToggleFilter(object sender, RoutedEventArgs e) private void OnToggleFilter(object sender, RoutedEventArgs e)
{ {
if (sender is ToggleButton toggle && DataContext is ViewModels.Repository repo) if (sender is ToggleButton toggle && DataContext is ViewModels.Repository repo)
@ -316,7 +316,7 @@ namespace SourceGit.Views
e.Handled = true; e.Handled = true;
} }
private void MakeRows(List<ViewModels.BranchTreeNode> rows, List<ViewModels.BranchTreeNode> nodes, int depth) private void MakeRows(List<ViewModels.BranchTreeNode> rows, List<ViewModels.BranchTreeNode> nodes, int depth)
{ {
foreach (var node in nodes) foreach (var node in nodes)
@ -326,7 +326,7 @@ namespace SourceGit.Views
if (!node.IsExpanded || node.Backend is Models.Branch) if (!node.IsExpanded || node.Backend is Models.Branch)
continue; continue;
MakeRows(rows, node.Children, depth + 1); MakeRows(rows, node.Children, depth + 1);
} }
} }
@ -338,7 +338,7 @@ namespace SourceGit.Views
outs.Add(branch); outs.Add(branch);
return; return;
} }
foreach (var sub in node.Children) foreach (var sub in node.Children)
CollectBranchesInNode(outs, sub); CollectBranchesInNode(outs, sub);
} }

View file

@ -127,7 +127,7 @@ namespace SourceGit.Views
Cursor = new Cursor(StandardCursorType.SizeWestEast); Cursor = new Cursor(StandardCursorType.SizeWestEast);
e.Pointer.Capture(this); e.Pointer.Capture(this);
e.Handled = true; e.Handled = true;
} }
} }
protected override void OnPointerReleased(PointerReleasedEventArgs e) protected override void OnPointerReleased(PointerReleasedEventArgs e)
@ -163,7 +163,7 @@ namespace SourceGit.Views
_lastInSlider = false; _lastInSlider = false;
Cursor = null; Cursor = null;
} }
} }
} }
} }

View file

@ -21,7 +21,7 @@ namespace SourceGit.Views
Close(); Close();
} }
private void OnMoveItemUp(object sender, RoutedEventArgs e) private void OnMoveItemUp(object sender, RoutedEventArgs e)
{ {
if (sender is Control control && DataContext is ViewModels.InteractiveRebase vm) if (sender is Control control && DataContext is ViewModels.InteractiveRebase vm)
{ {
@ -39,7 +39,7 @@ namespace SourceGit.Views
} }
} }
private void OnDataGridKeyDown(object sender, KeyEventArgs e) private void OnDataGridKeyDown(object sender, KeyEventArgs e)
{ {
var datagrid = sender as DataGrid; var datagrid = sender as DataGrid;
var item = datagrid.SelectedItem as ViewModels.InteractiveRebaseItem; var item = datagrid.SelectedItem as ViewModels.InteractiveRebaseItem;

View file

@ -182,7 +182,7 @@ namespace SourceGit.Views
private void EndMoveWindow(object sender, PointerReleasedEventArgs e) private void EndMoveWindow(object sender, PointerReleasedEventArgs e)
{ {
_pressedTitleBar = false; _pressedTitleBar = false;
} }
private void OnPopupSure(object sender, RoutedEventArgs e) private void OnPopupSure(object sender, RoutedEventArgs e)
{ {

View file

@ -65,7 +65,7 @@ namespace SourceGit.Views
private void OnSearchCommitPanelPropertyChanged(object sender, AvaloniaPropertyChangedEventArgs e) private void OnSearchCommitPanelPropertyChanged(object sender, AvaloniaPropertyChangedEventArgs e)
{ {
if (e.Property == IsVisibleProperty && sender is Grid { IsVisible: true}) if (e.Property == IsVisibleProperty && sender is Grid { IsVisible: true })
txtSearchCommitsBox.Focus(); txtSearchCommitsBox.Focus();
} }
@ -86,7 +86,7 @@ namespace SourceGit.Views
{ {
repo.NavigateToCommit(commit.SHA); repo.NavigateToCommit(commit.SHA);
} }
e.Handled = true; e.Handled = true;
} }
@ -101,7 +101,7 @@ namespace SourceGit.Views
remoteBranchTree.UnselectAll(); remoteBranchTree.UnselectAll();
tagsList.SelectedItem = null; tagsList.SelectedItem = null;
} }
private void OnRemoteBranchTreeSelectionChanged(object _1, RoutedEventArgs _2) private void OnRemoteBranchTreeSelectionChanged(object _1, RoutedEventArgs _2)
{ {
localBranchTree.UnselectAll(); localBranchTree.UnselectAll();