diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..fa46e28
--- /dev/null
+++ b/.editorconfig
@@ -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
diff --git a/Directory.Build.props b/Directory.Build.props
index 9825edd..5531e93 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -5,8 +5,8 @@
- 0.10.13
- 0.10.12.2
+ 11.0.0
+ 11.0.0
diff --git a/ILSpy.Core/AvalonEdit/TextMarkerService.cs b/ILSpy.Core/AvalonEdit/TextMarkerService.cs
index e31d3b6..b06d0d8 100644
--- a/ILSpy.Core/AvalonEdit/TextMarkerService.cs
+++ b/ILSpy.Core/AvalonEdit/TextMarkerService.cs
@@ -111,9 +111,8 @@ public void Remove(ITextMarker marker)
///
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;
@@ -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;
diff --git a/ILSpy.Core/ContextMenuEntry.cs b/ILSpy.Core/ContextMenuEntry.cs
index 8fd414d..a6be14a 100644
--- a/ILSpy.Core/ContextMenuEntry.cs
+++ b/ILSpy.Core/ContextMenuEntry.cs
@@ -181,9 +181,10 @@ void treeView_ContextMenuOpening(object sender, CancelEventArgs e)
e.Cancel = true; // don't show the menu
return;
}
+
ContextMenu menu = (ContextMenu)sender;
- if (ShowContextMenu(context, out IEnumerable items))
- menu.Items = items;
+ if (ShowContextMenu(context, out IEnumerable items))
+ menu.ItemsSource = items;
else
// hide the context menu.
e.Cancel = true;
@@ -193,8 +194,8 @@ void textView_ContextMenuOpening(object sender, CancelEventArgs e)
{
TextViewContext context = TextViewContext.Create(textView: textView);
ContextMenu menu = (ContextMenu)sender;
- if (ShowContextMenu(context, out IEnumerable items))
- menu.Items = items;
+ if (ShowContextMenu(context, out IEnumerable items))
+ menu.ItemsSource = items;
else
// hide the context menu.
e.Cancel = true;
@@ -204,16 +205,16 @@ void listBox_ContextMenuOpening(object sender, CancelEventArgs e)
{
TextViewContext context = TextViewContext.Create(listBox: listBox);
ContextMenu menu = (ContextMenu)sender;
- if (ShowContextMenu(context, out IEnumerable items))
- menu.Items = items;
+ if (ShowContextMenu(context, out IEnumerable items))
+ menu.ItemsSource = items;
else
// hide the context menu.
e.Cancel = true;
}
- bool ShowContextMenu(TextViewContext context, out IEnumerable menuItems)
+ bool ShowContextMenu(TextViewContext context, out IEnumerable menuItems)
{
- List items = new List();
+ List items = new List();
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) {
@@ -223,6 +224,7 @@ bool ShowContextMenu(TextViewContext context, out IEnumerable menuItem
items.Add(new Separator());
needSeparatorForCategory = false;
}
+
MenuItem menuItem = new MenuItem();
menuItem.Header = MainWindow.GetResourceString(entryPair.Metadata.Header);
if (!string.IsNullOrEmpty(entryPair.Metadata.Icon)) {
@@ -232,6 +234,7 @@ bool ShowContextMenu(TextViewContext context, out IEnumerable menuItem
Source = Images.LoadImage(entry, entryPair.Metadata.Icon)
};
}
+
if (entryPair.Value.IsEnabled(context)) {
menuItem.Click += delegate { entry.Execute(context); };
} else
@@ -240,6 +243,7 @@ bool ShowContextMenu(TextViewContext context, out IEnumerable menuItem
}
}
}
+
menuItems = items;
return items.Count > 0;
}
diff --git a/ILSpy.Core/Controls/CustomDialog.xaml.cs b/ILSpy.Core/Controls/CustomDialog.xaml.cs
index 393c332..c8d23fb 100644
--- a/ILSpy.Core/Controls/CustomDialog.xaml.cs
+++ b/ILSpy.Core/Controls/CustomDialog.xaml.cs
@@ -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;
diff --git a/ILSpy.Core/Controls/DialogWindow.cs b/ILSpy.Core/Controls/DialogWindow.cs
index 99862ea..2324f59 100644
--- a/ILSpy.Core/Controls/DialogWindow.cs
+++ b/ILSpy.Core/Controls/DialogWindow.cs
@@ -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;
diff --git a/ILSpy.Core/Controls/ResourceObjectTable.xaml.cs b/ILSpy.Core/Controls/ResourceObjectTable.xaml.cs
index cfade13..24248d9 100644
--- a/ILSpy.Core/Controls/ResourceObjectTable.xaml.cs
+++ b/ILSpy.Core/Controls/ResourceObjectTable.xaml.cs
@@ -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()
@@ -67,7 +67,10 @@ 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)
@@ -75,4 +78,4 @@ void CanExecuteCopy(object sender, CanExecuteRoutedEventArgs args)
args.CanExecute = true;
}
}
-}
\ No newline at end of file
+}
diff --git a/ILSpy.Core/Controls/ResourceStringTable.xaml.cs b/ILSpy.Core/Controls/ResourceStringTable.xaml.cs
index e075def..583e531 100644
--- a/ILSpy.Core/Controls/ResourceStringTable.xaml.cs
+++ b/ILSpy.Core/Controls/ResourceStringTable.xaml.cs
@@ -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()
@@ -69,7 +69,10 @@ 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)
@@ -77,4 +80,4 @@ void CanExecuteCopy(object sender, CanExecuteRoutedEventArgs args)
args.CanExecute = true;
}
}
-}
\ No newline at end of file
+}
diff --git a/ILSpy.Core/Controls/SearchBox.cs b/ILSpy.Core/Controls/SearchBox.cs
index f831c61..f887fd0 100644
--- a/ILSpy.Core/Controls/SearchBox.cs
+++ b/ILSpy.Core/Controls/SearchBox.cs
@@ -34,9 +34,9 @@ public class SearchBox : TextBox
{
#region Dependency properties
- public static StyledProperty SearchIconProperty = AvaloniaProperty.Register(nameof(SearchIcon));
+ public static StyledProperty SearchIconProperty = AvaloniaProperty.Register(nameof(SearchIcon));
- public static StyledProperty ClearSearchIconProperty = AvaloniaProperty.Register(nameof(ClearSearchIcon));
+ public static StyledProperty ClearSearchIconProperty = AvaloniaProperty.Register(nameof(ClearSearchIcon));
public static StyledProperty WatermarkColorProperty = AvaloniaProperty.Register(nameof(WatermarkColor));
@@ -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); }
@@ -99,9 +99,9 @@ protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
}
}
- protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
- {
- base.OnPropertyChanged(change);
+ protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
+ {
+ base.OnPropertyChanged(change);
if (change.Property == TextProperty)
{
diff --git a/ILSpy.Core/CreateListDialog.xaml.cs b/ILSpy.Core/CreateListDialog.xaml.cs
index 73799e9..3f9a2f4 100644
--- a/ILSpy.Core/CreateListDialog.xaml.cs
+++ b/ILSpy.Core/CreateListDialog.xaml.cs
@@ -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)
@@ -69,4 +69,4 @@ public string NewListName
}
}
-}
\ No newline at end of file
+}
diff --git a/ILSpy.Core/DebugSteps.xaml.cs b/ILSpy.Core/DebugSteps.xaml.cs
index 5a75367..364815f 100644
--- a/ILSpy.Core/DebugSteps.xaml.cs
+++ b/ILSpy.Core/DebugSteps.xaml.cs
@@ -68,7 +68,7 @@ private void WritingOptions_PropertyChanged(object sender, System.ComponentModel
private void SelectionChanged(object sender, SelectionChangedEventArgs e)
{
Dispatcher.UIThread.InvokeAsync(() => {
- tree.Items = null;
+ tree.ItemsSource = null;
lastSelectedStep = int.MaxValue;
});
}
@@ -94,7 +94,7 @@ private void ILAstStepperUpdated(object sender, EventArgs e)
#if DEBUG
if (language == null) return;
Dispatcher.UIThread.InvokeAsync(() => {
- tree.Items = language.Stepper.Steps;
+ tree.ItemsSource = language.Stepper.Steps;
lastSelectedStep = int.MaxValue;
});
#endif
@@ -164,4 +164,4 @@ private void tree_KeyDown(object sender, KeyEventArgs e)
}
}
}
-}
\ No newline at end of file
+}
diff --git a/ILSpy.Core/ISmartTextOutput.cs b/ILSpy.Core/ISmartTextOutput.cs
index 9e4399e..2e84b29 100644
--- a/ILSpy.Core/ISmartTextOutput.cs
+++ b/ILSpy.Core/ISmartTextOutput.cs
@@ -36,7 +36,7 @@ public interface ISmartTextOutput : ITextOutput
///
/// Inserts an interactive UI element at the current position in the text output.
///
- void AddUIElement(Func element);
+ void AddUIElement(Func element);
void BeginSpan(HighlightingColor highlightingColor);
void EndSpan();
@@ -47,7 +47,7 @@ public static class SmartTextOutputExtensions
///
/// Creates a button.
///
- public static void AddButton(this ISmartTextOutput output, IBitmap icon, string text, EventHandler click)
+ public static void AddButton(this ISmartTextOutput output, Bitmap icon, string text, EventHandler click)
{
output.AddUIElement(
delegate {
@@ -67,6 +67,7 @@ public static void AddButton(this ISmartTextOutput output, IBitmap icon, string
} else {
button.Content = text;
}
+
button.Click += click;
return button;
});
diff --git a/ILSpy.Core/Images/Images.cs b/ILSpy.Core/Images/Images.cs
index e09f3c2..1e9a67a 100644
--- a/ILSpy.Core/Images/Images.cs
+++ b/ILSpy.Core/Images/Images.cs
@@ -27,83 +27,82 @@ namespace ICSharpCode.ILSpy
{
static class Images
{
- static IBitmap LoadBitmap(string name)
+ static Bitmap LoadBitmap(string name)
{
Bitmap image = new Bitmap("Images/" + name + ".png");
//image.Freeze();
return image;
}
- public static readonly IBitmap Breakpoint = LoadBitmap("Breakpoint");
- public static readonly IBitmap CurrentLine = LoadBitmap("CurrentLine");
+ public static readonly Bitmap Breakpoint = LoadBitmap("Breakpoint");
+ public static readonly Bitmap CurrentLine = LoadBitmap("CurrentLine");
- public static readonly IBitmap ViewCode = LoadBitmap("ViewCode");
- public static readonly IBitmap Save = LoadBitmap("SaveFile");
- public static readonly IBitmap OK = LoadBitmap("OK");
+ public static readonly Bitmap ViewCode = LoadBitmap("ViewCode");
+ public static readonly Bitmap Save = LoadBitmap("SaveFile");
+ public static readonly Bitmap OK = LoadBitmap("OK");
- public static readonly IBitmap Delete = LoadBitmap("Delete");
- public static readonly IBitmap Search = LoadBitmap("Search");
+ public static readonly Bitmap Delete = LoadBitmap("Delete");
+ public static readonly Bitmap Search = LoadBitmap("Search");
- public static readonly IBitmap Assembly = LoadBitmap("Assembly");
- public static readonly IBitmap AssemblyWarning = LoadBitmap("AssemblyWarning");
- public static readonly IBitmap AssemblyLoading = LoadBitmap("FindAssembly");
+ public static readonly Bitmap Assembly = LoadBitmap("Assembly");
+ public static readonly Bitmap AssemblyWarning = LoadBitmap("AssemblyWarning");
+ public static readonly Bitmap AssemblyLoading = LoadBitmap("FindAssembly");
- public static readonly IBitmap Library = LoadBitmap("Library");
- public static readonly IBitmap Namespace = LoadBitmap("NameSpace");
+ public static readonly Bitmap Library = LoadBitmap("Library");
+ public static readonly Bitmap Namespace = LoadBitmap("NameSpace");
- public static readonly IBitmap ReferenceFolderOpen = LoadBitmap("ReferenceFolder.Open");
- public static readonly IBitmap ReferenceFolderClosed = LoadBitmap("ReferenceFolder.Closed");
+ public static readonly Bitmap ReferenceFolderOpen = LoadBitmap("ReferenceFolder.Open");
+ public static readonly Bitmap ReferenceFolderClosed = LoadBitmap("ReferenceFolder.Closed");
- public static readonly IBitmap SubTypes = LoadBitmap("SubTypes");
- public static readonly IBitmap SuperTypes = LoadBitmap("SuperTypes");
+ public static readonly Bitmap SubTypes = LoadBitmap("SubTypes");
+ public static readonly Bitmap SuperTypes = LoadBitmap("SuperTypes");
- public static readonly IBitmap FolderOpen = LoadBitmap("Folder.Open");
- public static readonly IBitmap FolderClosed = LoadBitmap("Folder.Closed");
+ public static readonly Bitmap FolderOpen = LoadBitmap("Folder.Open");
+ public static readonly Bitmap FolderClosed = LoadBitmap("Folder.Closed");
- public static readonly IBitmap Resource = LoadBitmap("Resource");
- public static readonly IBitmap ResourceImage = LoadBitmap("ResourceImage");
- public static readonly IBitmap ResourceResourcesFile = LoadBitmap("ResourceResourcesFile");
- public static readonly IBitmap ResourceXml = LoadBitmap("ResourceXml");
- public static readonly IBitmap ResourceXsd = LoadBitmap("ResourceXsd");
- public static readonly IBitmap ResourceXslt = LoadBitmap("ResourceXslt");
+ public static readonly Bitmap Resource = LoadBitmap("Resource");
+ public static readonly Bitmap ResourceImage = LoadBitmap("ResourceImage");
+ public static readonly Bitmap ResourceResourcesFile = LoadBitmap("ResourceResourcesFile");
+ public static readonly Bitmap ResourceXml = LoadBitmap("ResourceXml");
+ public static readonly Bitmap ResourceXsd = LoadBitmap("ResourceXsd");
+ public static readonly Bitmap ResourceXslt = LoadBitmap("ResourceXslt");
- public static readonly IBitmap Class = LoadBitmap("Class");
- public static readonly IBitmap Struct = LoadBitmap("Struct");
- public static readonly IBitmap Interface = LoadBitmap("Interface");
- public static readonly IBitmap Delegate = LoadBitmap("Delegate");
- public static readonly IBitmap Enum = LoadBitmap("Enum");
- public static readonly IBitmap StaticClass = LoadBitmap("StaticClass");
+ public static readonly Bitmap Class = LoadBitmap("Class");
+ public static readonly Bitmap Struct = LoadBitmap("Struct");
+ public static readonly Bitmap Interface = LoadBitmap("Interface");
+ public static readonly Bitmap Delegate = LoadBitmap("Delegate");
+ public static readonly Bitmap Enum = LoadBitmap("Enum");
+ public static readonly Bitmap StaticClass = LoadBitmap("StaticClass");
+ public static readonly Bitmap Field = LoadBitmap("Field");
+ public static readonly Bitmap FieldReadOnly = LoadBitmap("FieldReadOnly");
+ public static readonly Bitmap Literal = LoadBitmap("Literal");
+ public static readonly Bitmap EnumValue = LoadBitmap("EnumValue");
- public static readonly IBitmap Field = LoadBitmap("Field");
- public static readonly IBitmap FieldReadOnly = LoadBitmap("FieldReadOnly");
- public static readonly IBitmap Literal = LoadBitmap("Literal");
- public static readonly IBitmap EnumValue = LoadBitmap("EnumValue");
+ public static readonly Bitmap Method = LoadBitmap("Method");
+ public static readonly Bitmap Constructor = LoadBitmap("Constructor");
+ public static readonly Bitmap VirtualMethod = LoadBitmap("VirtualMethod");
+ public static readonly Bitmap Operator = LoadBitmap("Operator");
+ public static readonly Bitmap ExtensionMethod = LoadBitmap("ExtensionMethod");
+ public static readonly Bitmap PInvokeMethod = LoadBitmap("PInvokeMethod");
- public static readonly IBitmap Method = LoadBitmap("Method");
- public static readonly IBitmap Constructor = LoadBitmap("Constructor");
- public static readonly IBitmap VirtualMethod = LoadBitmap("VirtualMethod");
- public static readonly IBitmap Operator = LoadBitmap("Operator");
- public static readonly IBitmap ExtensionMethod = LoadBitmap("ExtensionMethod");
- public static readonly IBitmap PInvokeMethod = LoadBitmap("PInvokeMethod");
+ public static readonly Bitmap Property = LoadBitmap("Property");
+ public static readonly Bitmap Indexer = LoadBitmap("Indexer");
- public static readonly IBitmap Property = LoadBitmap("Property");
- public static readonly IBitmap Indexer = LoadBitmap("Indexer");
+ public static readonly Bitmap Event = LoadBitmap("Event");
- public static readonly IBitmap Event = LoadBitmap("Event");
+ private static readonly Bitmap OverlayProtected = LoadBitmap("OverlayProtected");
+ private static readonly Bitmap OverlayInternal = LoadBitmap("OverlayInternal");
+ private static readonly Bitmap OverlayProtectedInternal = LoadBitmap("OverlayProtectedInternal");
+ private static readonly Bitmap OverlayPrivate = LoadBitmap("OverlayPrivate");
+ private static readonly Bitmap OverlayPrivateProtected = LoadBitmap("OverlayPrivateProtected");
+ private static readonly Bitmap OverlayCompilerControlled = LoadBitmap("OverlayCompilerControlled");
- private static readonly IBitmap OverlayProtected = LoadBitmap("OverlayProtected");
- private static readonly IBitmap OverlayInternal = LoadBitmap("OverlayInternal");
- private static readonly IBitmap OverlayProtectedInternal = LoadBitmap("OverlayProtectedInternal");
- private static readonly IBitmap OverlayPrivate = LoadBitmap("OverlayPrivate");
- private static readonly IBitmap OverlayPrivateProtected = LoadBitmap("OverlayPrivateProtected");
- private static readonly IBitmap OverlayCompilerControlled = LoadBitmap("OverlayCompilerControlled");
+ private static readonly Bitmap OverlayStatic = LoadBitmap("OverlayStatic");
- private static readonly IBitmap OverlayStatic = LoadBitmap("OverlayStatic");
-
- public static IBitmap LoadImage(object part, string icon)
+ public static Bitmap LoadImage(object part, string icon)
{
- IBitmap image;
+ Bitmap image;
var assembly = part.GetType().Assembly;
if (assembly == typeof(Images).Assembly) {
image = new Bitmap(icon);
@@ -112,20 +111,20 @@ public static IBitmap LoadImage(object part, string icon)
var embededResourceStream = assembly.GetManifestResourceStream(icon);
image = new Bitmap(embededResourceStream);
}
+
return image;
}
-
private static readonly TypeIconCache typeIconCache = new TypeIconCache();
private static readonly MemberIconCache memberIconCache = new MemberIconCache();
- public static IBitmap GetIcon(TypeIcon icon, AccessOverlayIcon overlay, bool isStatic = false)
+ public static Bitmap GetIcon(TypeIcon icon, AccessOverlayIcon overlay, bool isStatic = false)
{
lock (typeIconCache)
return typeIconCache.GetIcon(icon, overlay, isStatic);
}
- public static IBitmap GetIcon(MemberIcon icon, AccessOverlayIcon overlay, bool isStatic)
+ public static Bitmap GetIcon(MemberIcon icon, AccessOverlayIcon overlay, bool isStatic)
{
lock (memberIconCache)
return memberIconCache.GetIcon(icon, overlay, isStatic);
@@ -145,9 +144,9 @@ public TypeIconCache()
PreloadPublicIconToCache(TypeIcon.StaticClass, Images.StaticClass);
}
- protected override IBitmap GetBaseImage(TypeIcon icon)
+ protected override Bitmap GetBaseImage(TypeIcon icon)
{
- IBitmap baseImage;
+ Bitmap baseImage;
switch (icon) {
case TypeIcon.Class:
baseImage = Images.Class;
@@ -194,9 +193,9 @@ public MemberIconCache()
PreloadPublicIconToCache(MemberIcon.Event, Images.Event);
}
- protected override IBitmap GetBaseImage(MemberIcon icon)
+ protected override Bitmap GetBaseImage(MemberIcon icon)
{
- IBitmap baseImage;
+ Bitmap baseImage;
switch (icon) {
case MemberIcon.Field:
baseImage = Images.Field;
@@ -250,7 +249,10 @@ private class WbFb : IFramebufferPlatformSurface
WriteableBitmap _bitmap;
public ILockedFramebuffer Lock() => _bitmap.Lock();
- public WbFb(WriteableBitmap bitmap)
+ // Avalonia v11 - https://github.com/AvaloniaUI/Avalonia/pull/11914
+ public IFramebufferRenderTarget CreateFramebufferRenderTarget() => new FuncFramebufferRenderTarget(Lock);
+
+ public WbFb(WriteableBitmap bitmap)
{
_bitmap = bitmap;
}
@@ -258,39 +260,39 @@ public WbFb(WriteableBitmap bitmap)
private abstract class IconCache
{
- private readonly Dictionary, IBitmap> cache = new Dictionary, IBitmap>();
+ private readonly Dictionary, Bitmap> cache = new Dictionary, Bitmap>();
- protected void PreloadPublicIconToCache(T icon, IBitmap image)
+ protected void PreloadPublicIconToCache(T icon, Bitmap image)
{
var iconKey = new Tuple(icon, AccessOverlayIcon.Public, false);
cache.Add(iconKey, image);
}
- public IBitmap GetIcon(T icon, AccessOverlayIcon overlay, bool isStatic)
+ public Bitmap GetIcon(T icon, AccessOverlayIcon overlay, bool isStatic)
{
var iconKey = new Tuple(icon, overlay, isStatic);
if (cache.ContainsKey(iconKey)) {
return cache[iconKey];
} else {
- IBitmap result = BuildMemberIcon(icon, overlay, isStatic);
+ Bitmap result = BuildMemberIcon(icon, overlay, isStatic);
cache.Add(iconKey, result);
return result;
}
}
- private IBitmap BuildMemberIcon(T icon, AccessOverlayIcon overlay, bool isStatic)
+ private Bitmap BuildMemberIcon(T icon, AccessOverlayIcon overlay, bool isStatic)
{
- IBitmap baseImage = GetBaseImage(icon);
- IBitmap overlayImage = GetOverlayImage(overlay);
+ Bitmap baseImage = GetBaseImage(icon);
+ Bitmap overlayImage = GetOverlayImage(overlay);
return CreateOverlayImage(baseImage, overlayImage, isStatic);
}
- protected abstract IBitmap GetBaseImage(T icon);
+ protected abstract Bitmap GetBaseImage(T icon);
- private static IBitmap GetOverlayImage(AccessOverlayIcon overlay)
+ private static Bitmap GetOverlayImage(AccessOverlayIcon overlay)
{
- IBitmap overlayImage;
+ Bitmap overlayImage;
switch (overlay) {
case AccessOverlayIcon.Public:
overlayImage = null;
@@ -321,11 +323,12 @@ private static IBitmap GetOverlayImage(AccessOverlayIcon overlay)
private static readonly Rect iconRect = new Rect(0, 0, 16, 16);
- private static IBitmap CreateOverlayImage(IBitmap baseImage, IBitmap overlay, bool isStatic)
+ private static Bitmap CreateOverlayImage(Bitmap baseImage, Bitmap overlay, bool isStatic)
{
var image = new WriteableBitmap(new PixelSize(16, 16), new Vector(96, 96), PixelFormat.Rgba8888, AlphaFormat.Unpremul);
- using (var rt = AvaloniaLocator.Current.GetService().CreateRenderTarget(new[] { new WbFb(image)})) {
+ // Avalonia 0.10 - https://github.com/AvaloniaUI/Avalonia/pull/11557
+ using (var rt = AvaloniaLocator.Current.GetService().CreateRenderTarget(new[] { new WbFb(image)})) {
using (var ctx = rt.CreateDrawingContext(null)) {
diff --git a/ILSpy.Core/Languages/CSharpLanguage.cs b/ILSpy.Core/Languages/CSharpLanguage.cs
index 64f7366..fcb7ca6 100644
--- a/ILSpy.Core/Languages/CSharpLanguage.cs
+++ b/ILSpy.Core/Languages/CSharpLanguage.cs
@@ -350,7 +350,7 @@ void AddReferenceAssemblyWarningMessage(PEFile module, ITextOutput output)
}
void AddWarningMessage(PEFile module, ITextOutput output, string line1, string line2 = null,
- string buttonText = null, IBitmap buttonImage = null, EventHandler buttonClickHandler = null)
+ string buttonText = null, Bitmap buttonImage = null, EventHandler buttonClickHandler = null)
{
if (output is ISmartTextOutput fancyOutput)
{
diff --git a/ILSpy.Core/MainWindow.xaml.cs b/ILSpy.Core/MainWindow.xaml.cs
index 9103072..fcfbc62 100644
--- a/ILSpy.Core/MainWindow.xaml.cs
+++ b/ILSpy.Core/MainWindow.xaml.cs
@@ -40,11 +40,13 @@
using Avalonia.Markup.Xaml.Styling;
using Avalonia.Media;
using Avalonia.Media.Imaging;
+using Avalonia.Platform;
using Avalonia.Styling;
using Avalonia.Threading;
using AvaloniaEdit;
using AvaloniaEdit.Highlighting;
using AvaloniaEdit.Highlighting.Xshd;
+using AvaloniaEdit.Utils;
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.Documentation;
using ICSharpCode.Decompiler.Metadata;
@@ -82,7 +84,7 @@ public partial class MainWindow : PlatformDependentWindow, IRoutedCommandBindabl
internal ItemsControl toolBar;
internal ComboBox languageComboBox;
internal ComboBox languageVersionComboBox;
- internal IControl statusBar;
+ internal Control statusBar;
internal TextBlock StatusLabel;
internal Grid mainGrid;
internal ColumnDefinition leftColumn;
@@ -199,7 +201,7 @@ private void InitializeComponent()
}
var themesDropDown = this.Find("Themes");
- themesDropDown.Items = themeNames;
+ themesDropDown.ItemsSource = themeNames;
themesDropDown.SelectionChanged += (sender, e) =>
{
Styles[0] = themes[themesDropDown.SelectedIndex];
@@ -251,14 +253,17 @@ private void MainWindow_KeyDown(object sender, KeyEventArgs e)
private void ApplyTheme()
{
- if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) && Styles.TryGetResource("ThemeBackgroundBrush", out object backgroundColor) && backgroundColor is ISolidColorBrush brush)
+ ThemeVariant defaultVariant = ThemeVariant.Default;
+
+ if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) && Styles.TryGetResource("ThemeBackgroundBrush", defaultVariant, out object backgroundColor) && backgroundColor is ISolidColorBrush brush)
{
// HACK: SetTitleBarColor is a method in Avalonia.Native.WindowImpl
var setTitleBarColorMethod = PlatformImpl.GetType().GetMethod("SetTitleBarColor");
setTitleBarColorMethod?.Invoke(PlatformImpl, new object[] { brush.Color });
}
- if (Styles.TryGetResource("ILAsm-Mode", out object ilasm) && ilasm is string ilmode)
+ // Styles.TryGetResource(objKey, ThemeVariant, out objValue)
+ if (Styles.TryGetResource("ILAsm-Mode", defaultVariant, out object ilasm) && ilasm is string ilmode)
{
HighlightingManager.Instance.RegisterHighlighting(
"ILAsm", new string[] { ".il" },
@@ -289,7 +294,7 @@ private void ApplyTheme()
});
}
- if (Styles.TryGetResource("CSharp-Mode", out object csharp) && csharp is string csmode)
+ if (Styles.TryGetResource("CSharp-Mode", defaultVariant, out object csharp) && csharp is string csmode)
{
HighlightingManager.Instance.RegisterHighlighting(
"C#", new string[] { ".cs" },
@@ -327,7 +332,7 @@ private void ApplyTheme()
void SetWindowBounds(Rect bounds)
{
ClientSize = bounds.Size;
- Position = PixelPoint.FromPoint(bounds.Position, PlatformImpl.DesktopScaling);
+ Position = PixelPoint.FromPoint(bounds.Position, DesktopScaling);
}
#region Toolbar extensibility
@@ -337,7 +342,7 @@ void InitToolbar()
int navigationPos = 0;
int openPos = 1;
var toolbarCommands = App.ExportProvider.GetExports("ToolbarCommand");
- var toolbarItems = toolBar.Items as IList