Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade Avalonia v11 #141

Draft
wants to merge 16 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
148 changes: 148 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
# Top-most EditorConfig file
root = true

# All generic files should use MSDOS style endings, not Unix (lf)
[*]
end_of_line = crlf
indent_style = tab
indent_size = 4
guidelines = 110

[*.{ps1,psd1,psm1}]
indent_style = space
indent_size = 4
trim_trailing_whitespace = true
[*.il]
indent_style = space
indent_size = 2
[*.{yml,yaml}]
indent_style = space
indent_size = 2
[*.csproj]
indent_style = space
indent_size = 2
[*.config]
indent_style = space
indent_size = 2
[*.nuspec]
indent_style = space
indent_size = 2
[*.vsixmanifest]
indent_style = space
indent_size = 2
[*.vsct]
indent_style = space
indent_size = 2
[*.md]
indent_style = space
indent_size = 2

[*.{cs,csx}]
tab_width = 4
indent_size = 4
indent_style = tab
end_of_line = crlf
charset = utf-8-bom
trim_trailing_whitespace = true
insert_final_newline = true

# New line preferences
csharp_new_line_before_open_brace = methods, types, control_blocks, local_functions
csharp_new_line_before_else = true
csharp_new_line_before_catch = true
csharp_new_line_before_finally = true
csharp_new_line_before_members_in_object_initializers = false
csharp_new_line_before_members_in_anonymous_types = false
csharp_new_line_within_query_expression_clauses = false

# Indentation preferences
csharp_indent_block_contents = true
csharp_indent_braces = false
csharp_indent_case_contents = true
csharp_indent_case_contents_when_block = false
csharp_indent_switch_labels = true
csharp_indent_labels = one_less

# Avoid 'this.' in generated code unless absolutely necessary, but allow developers to use it
dotnet_style_qualification_for_field = false:silent
dotnet_style_qualification_for_property = false:silent
dotnet_style_qualification_for_method = false:silent
dotnet_style_qualification_for_event = false:silent

# Do not use 'var' when generating code, but allow developers to use it
csharp_style_var_for_built_in_types = false:silent
csharp_style_var_when_type_is_apparent = false:silent
csharp_style_var_elsewhere = false:silent

# Use language keywords instead of BCL types when generating code, but allow developers to use either
dotnet_style_predefined_type_for_locals_parameters_members = true:silent
dotnet_style_predefined_type_for_member_access = true:silent

# Using directives
dotnet_sort_system_directives_first = true
dotnet_separate_import_directive_groups = true

# Wrapping
csharp_preserve_single_line_blocks = true
csharp_preserve_single_line_statements = false

# Code style
csharp_prefer_braces = true:silent

# Expression-level preferences
dotnet_style_object_initializer = true:suggestion
dotnet_style_collection_initializer = true:suggestion
dotnet_style_explicit_tuple_names = true:suggestion
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_null_propagation = true:suggestion

# Expression-bodied members
csharp_style_expression_bodied_methods = false:silent
csharp_style_expression_bodied_constructors = false:silent
csharp_style_expression_bodied_operators = false:silent
csharp_style_expression_bodied_properties = true:silent
csharp_style_expression_bodied_indexers = true:silent
csharp_style_expression_bodied_accessors = true:silent

# Pattern matching
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
csharp_style_inlined_variable_declaration = true:suggestion

# Null checking preferences
csharp_style_throw_expression = true:suggestion
csharp_style_conditional_delegate_call = true:suggestion

# Space preferences
csharp_space_after_cast = false
csharp_space_after_colon_in_inheritance_clause = true
csharp_space_after_comma = true
csharp_space_after_dot = false
csharp_space_after_keywords_in_control_flow_statements = true
csharp_space_after_semicolon_in_for_statement = true
csharp_space_around_binary_operators = before_and_after
csharp_space_around_declaration_statements = do_not_ignore
csharp_space_before_colon_in_inheritance_clause = true
csharp_space_before_comma = false
csharp_space_before_dot = false
csharp_space_before_open_square_brackets = false
csharp_space_before_semicolon_in_for_statement = false
csharp_space_between_empty_square_brackets = false
csharp_space_between_method_call_empty_parameter_list_parentheses = false
csharp_space_between_method_call_name_and_opening_parenthesis = false
csharp_space_between_method_call_parameter_list_parentheses = false
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
csharp_space_between_method_declaration_name_and_open_parenthesis = false
csharp_space_between_method_declaration_parameter_list_parentheses = false
csharp_space_between_parentheses = false
csharp_space_between_square_brackets = false

## Suppressions for ILSpy coding style

# IDE2002:Consecutive braces must not have blank line between them
dotnet_diagnostic.IDE2002.severity = none

# IDE2003: Blank line required between block and subsequent statement
# dotnet_diagnostic.IDE2003.severity = error
dotnet_style_allow_statement_immediately_after_block_experimental = false:none
dotnet_diagnostic.IDE2003.severity = none
4 changes: 2 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
</PropertyGroup>

<PropertyGroup>
<AvaloniaVersion>0.10.13</AvaloniaVersion>
<AvaloniaEditVersion>0.10.12.2</AvaloniaEditVersion>
<AvaloniaVersion>11.0.0</AvaloniaVersion>
<AvaloniaEditVersion>11.0.0</AvaloniaEditVersion>
</PropertyGroup>

</Project>
7 changes: 3 additions & 4 deletions ILSpy.Core/AvalonEdit/TextMarkerService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,8 @@ public void Remove(ITextMarker marker)
/// </summary>
internal void Redraw(ISegment segment)
{
textView.Redraw(segment, DispatcherPriority.Normal);
if (RedrawRequested != null)
RedrawRequested(this, EventArgs.Empty);
textView.Redraw(segment);
RedrawRequested?.Invoke(this, EventArgs.Empty);
}

public event EventHandler RedrawRequested;
Expand All @@ -137,7 +136,7 @@ protected override void ColorizeLine(DocumentLine line)
Math.Min(marker.EndOffset, lineEnd),
element => {
if (foregroundBrush != null) {
element.TextRunProperties.ForegroundBrush = foregroundBrush;
element.TextRunProperties.SetForegroundBrush(foregroundBrush);
}
// TODO: change font style
//string tf = element.TextRunProperties.Typeface;
Expand Down
20 changes: 12 additions & 8 deletions ILSpy.Core/ContextMenuEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,13 @@
// Context menu is shown only when the ContextMenu property is not null before the
// ContextMenuOpening event handler is called.
treeView.ContextMenu = new ContextMenu();
treeView.ContextMenu.ContextMenuOpening += provider.treeView_ContextMenuOpening;

Check failure on line 139 in ILSpy.Core/ContextMenuEntry.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

'ContextMenu' does not contain a definition for 'ContextMenuOpening' and no accessible extension method 'ContextMenuOpening' accepting a first argument of type 'ContextMenu' could be found (are you missing a using directive or an assembly reference?)

if (textView != null) {
// Context menu is shown only when the ContextMenu property is not null before the
// ContextMenuOpening event handler is called.
textView.ContextMenu = new ContextMenu();
textView.ContextMenu.ContextMenuOpening += provider.textView_ContextMenuOpening;

Check failure on line 145 in ILSpy.Core/ContextMenuEntry.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

'ContextMenu' does not contain a definition for 'ContextMenuOpening' and no accessible extension method 'ContextMenuOpening' accepting a first argument of type 'ContextMenu' could be found (are you missing a using directive or an assembly reference?)
}
}

Expand All @@ -150,7 +150,7 @@
{
var provider = new ContextMenuProvider(listBox);
listBox.ContextMenu = new ContextMenu();
listBox.ContextMenu.ContextMenuOpening += provider.listBox_ContextMenuOpening;

Check failure on line 153 in ILSpy.Core/ContextMenuEntry.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

'ContextMenu' does not contain a definition for 'ContextMenuOpening' and no accessible extension method 'ContextMenuOpening' accepting a first argument of type 'ContextMenu' could be found (are you missing a using directive or an assembly reference?)
}

readonly SharpTreeView treeView;
Expand Down Expand Up @@ -181,9 +181,10 @@
e.Cancel = true; // don't show the menu
return;
}

ContextMenu menu = (ContextMenu)sender;
if (ShowContextMenu(context, out IEnumerable<IControl> items))
menu.Items = items;
if (ShowContextMenu(context, out IEnumerable<Control> items))
menu.ItemsSource = items;
else
// hide the context menu.
e.Cancel = true;
Expand All @@ -193,8 +194,8 @@
{
TextViewContext context = TextViewContext.Create(textView: textView);
ContextMenu menu = (ContextMenu)sender;
if (ShowContextMenu(context, out IEnumerable<IControl> items))
menu.Items = items;
if (ShowContextMenu(context, out IEnumerable<Control> items))
menu.ItemsSource = items;
else
// hide the context menu.
e.Cancel = true;
Expand All @@ -204,16 +205,16 @@
{
TextViewContext context = TextViewContext.Create(listBox: listBox);
ContextMenu menu = (ContextMenu)sender;
if (ShowContextMenu(context, out IEnumerable<IControl> items))
menu.Items = items;
if (ShowContextMenu(context, out IEnumerable<Control> items))
menu.ItemsSource = items;
else
// hide the context menu.
e.Cancel = true;
}

bool ShowContextMenu(TextViewContext context, out IEnumerable<IControl> menuItems)
bool ShowContextMenu(TextViewContext context, out IEnumerable<Control> menuItems)
{
List<IControl> items = new List<IControl>();
List<Control> items = new List<Control>();
foreach (var category in entries.OrderBy(c => c.Metadata.Order).GroupBy(c => c.Metadata.Category)) {
bool needSeparatorForCategory = items.Count > 0;
foreach (var entryPair in category) {
Expand All @@ -223,6 +224,7 @@
items.Add(new Separator());
needSeparatorForCategory = false;
}

MenuItem menuItem = new MenuItem();
menuItem.Header = MainWindow.GetResourceString(entryPair.Metadata.Header);
if (!string.IsNullOrEmpty(entryPair.Metadata.Icon)) {
Expand All @@ -232,6 +234,7 @@
Source = Images.LoadImage(entry, entryPair.Metadata.Icon)
};
}

if (entryPair.Value.IsEnabled(context)) {
menuItem.Click += delegate { entry.Execute(context); };
} else
Expand All @@ -240,6 +243,7 @@
}
}
}

menuItems = items;
return items.Count > 0;
}
Expand Down
2 changes: 1 addition & 1 deletion ILSpy.Core/Controls/CustomDialog.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public CustomDialog(string caption, string message, int acceptButton = -1, int c
this.WindowStartupLocation = WindowStartupLocation.CenterOwner;
this.Width = buttonLabels.Length * (100+ 10);

buttons.Items = buttonLabels;
buttons.ItemsSource = buttonLabels;


label.Text = message;
Expand Down
6 changes: 0 additions & 6 deletions ILSpy.Core/Controls/DialogWindow.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reactive.Linq;
using System.Text;
using System.Threading.Tasks;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Styling;
Expand Down
9 changes: 6 additions & 3 deletions ILSpy.Core/Controls/ResourceObjectTable.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public partial class ResourceObjectTable : UserControl, IRoutedCommandBindable
public ResourceObjectTable(IEnumerable resources, ContentPresenter contentPresenter)
{
InitializeComponent();
resourceListView.Items = resources;
resourceListView.ItemsSource = resources;
}

private void InitializeComponent()
Expand All @@ -67,12 +67,15 @@ void ExecuteCopy(object sender, ExecutedRoutedEventArgs args)
{
sb.AppendLine(item.ToString());
}
App.Current.Clipboard.SetTextAsync(sb.ToString());

//// App.Current.Clipboard.SetTextAsync(sb.ToString());
var clipboard = TopLevel.GetTopLevel(this)?.Clipboard;
clipboard.SetTextAsync(sb.ToString());
}

void CanExecuteCopy(object sender, CanExecuteRoutedEventArgs args)
{
args.CanExecute = true;
}
}
}
}
9 changes: 6 additions & 3 deletions ILSpy.Core/Controls/ResourceStringTable.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public partial class ResourceStringTable : UserControl, IRoutedCommandBindable
public ResourceStringTable(IEnumerable strings, ContentPresenter contentPresenter)
{
InitializeComponent();
resourceListView.Items = strings;
resourceListView.ItemsSource = strings;
}

private void InitializeComponent()
Expand All @@ -69,12 +69,15 @@ void ExecuteCopy(object sender, ExecutedRoutedEventArgs args)
{
sb.AppendLine(item.ToString());
}
App.Current.Clipboard.SetTextAsync(sb.ToString());

////App.Current.Clipboard.SetTextAsync(sb.ToString());
var clipboard = TopLevel.GetTopLevel(this)?.Clipboard;
clipboard.SetTextAsync(sb.ToString());
}

void CanExecuteCopy(object sender, CanExecuteRoutedEventArgs args)
{
args.CanExecute = true;
}
}
}
}
14 changes: 7 additions & 7 deletions ILSpy.Core/Controls/SearchBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ public class SearchBox : TextBox
{
#region Dependency properties

public static StyledProperty<IBitmap> SearchIconProperty = AvaloniaProperty.Register<SearchBox, IBitmap>(nameof(SearchIcon));
public static StyledProperty<Bitmap> SearchIconProperty = AvaloniaProperty.Register<SearchBox, Bitmap>(nameof(SearchIcon));

public static StyledProperty<IBitmap> ClearSearchIconProperty = AvaloniaProperty.Register<SearchBox, IBitmap>(nameof(ClearSearchIcon));
public static StyledProperty<Bitmap> ClearSearchIconProperty = AvaloniaProperty.Register<SearchBox, Bitmap>(nameof(ClearSearchIcon));

public static StyledProperty<IBrush> WatermarkColorProperty = AvaloniaProperty.Register<SearchBox, IBrush>(nameof(WatermarkColor));

Expand Down Expand Up @@ -65,13 +65,13 @@ public TimeSpan UpdateDelay
set { SetValue(UpdateDelayProperty, value); }
}

public IBitmap SearchIcon
public Bitmap SearchIcon
{
get { return GetValue(SearchIconProperty); }
set { SetValue(SearchIconProperty, value); }
}

public IBitmap ClearSearchIcon
public Bitmap ClearSearchIcon
{
get { return GetValue(ClearSearchIconProperty); }
set { SetValue(ClearSearchIconProperty, value); }
Expand Down Expand Up @@ -99,9 +99,9 @@ protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
}
}

protected override void OnPropertyChanged<T>(AvaloniaPropertyChangedEventArgs<T> change)
{
base.OnPropertyChanged(change);
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
{
base.OnPropertyChanged(change);

if (change.Property == TextProperty)
{
Expand Down
4 changes: 2 additions & 2 deletions ILSpy.Core/CreateListDialog.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ private void InitializeComponent()
//ListName.TextInput += TextBox_TextChanged;
ListName.GetObservable(TextBox.TextProperty).Subscribe(text => TextBox_TextChanged(this, new TextInputEventArgs{Text = text}));

TemplateApplied += (sender, e) => Application.Current.FocusManager.Focus(ListName);
TemplateApplied += (sender, e) => ListName.Focus();
}

private void TextBox_TextChanged(object sender, TextInputEventArgs e)
Expand Down Expand Up @@ -69,4 +69,4 @@ public string NewListName
}

}
}
}
Loading
Loading