Browse Source

Do not use ObservableObject when ObservableObjectBase is sufficient. (#3644)

* Do not use ObservableObject when ObservableObjectBase is sufficient.
pull/3648/head
tom-englert 1 week ago committed by GitHub
parent
commit
1cfc5e740b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      ILSpy.ReadyToRun/ReadyToRunOptionPage.xaml.cs
  2. 2
      ILSpy.ReadyToRun/ReadyToRunOptions.cs
  3. 14
      ILSpy/AssemblyTree/AssemblyTreeModel.cs
  4. 2
      ILSpy/Docking/DockWorkspace.cs
  5. 2
      ILSpy/LanguageSettings.cs
  6. 2
      ILSpy/MainWindowViewModel.cs
  7. 2
      ILSpy/Options/DisplaySettings.cs
  8. 2
      ILSpy/Options/DisplaySettingsViewModel.cs
  9. 2
      ILSpy/Options/MiscSettings.cs
  10. 2
      ILSpy/Options/MiscSettingsViewModel.cs
  11. 4
      ILSpy/Options/OptionsDialogViewModel.cs
  12. 2
      ILSpy/ViewModels/CompareViewModel.cs
  13. 2
      ILSpy/ViewModels/ManageAssemblyListsViewModel.cs
  14. 2
      ILSpy/ViewModels/PaneModel.cs
  15. 2
      ILSpy/ViewModels/UpdatePanelViewModel.cs
  16. 4
      TestPlugin/CustomOptionPage.xaml.cs

2
ILSpy.ReadyToRun/ReadyToRunOptionPage.xaml.cs

@ -38,7 +38,7 @@ namespace ICSharpCode.ILSpy.ReadyToRun
[ExportOptionPage(Order = 40)] [ExportOptionPage(Order = 40)]
[NonShared] [NonShared]
class ReadyToRunOptionsViewModel : ObservableObject, IOptionPage class ReadyToRunOptionsViewModel : ObservableObjectBase, IOptionPage
{ {
private ReadyToRunOptions options; private ReadyToRunOptions options;

2
ILSpy.ReadyToRun/ReadyToRunOptions.cs

@ -24,7 +24,7 @@ using TomsToolbox.Wpf;
namespace ICSharpCode.ILSpy.ReadyToRun namespace ICSharpCode.ILSpy.ReadyToRun
{ {
internal partial class ReadyToRunOptions : ObservableObject, ISettingsSection internal partial class ReadyToRunOptions : ObservableObjectBase, ISettingsSection
{ {
private static readonly XNamespace ns = "http://www.ilspy.net/ready-to-run"; private static readonly XNamespace ns = "http://www.ilspy.net/ready-to-run";

14
ILSpy/AssemblyTree/AssemblyTreeModel.cs

@ -72,6 +72,8 @@ namespace ICSharpCode.ILSpy.AssemblyTree
private readonly LanguageService languageService; private readonly LanguageService languageService;
private readonly IExportProvider exportProvider; private readonly IExportProvider exportProvider;
private static Dispatcher UIThreadDispatcher => Application.Current.Dispatcher;
public AssemblyTreeModel(SettingsService settingsService, LanguageService languageService, IExportProvider exportProvider) public AssemblyTreeModel(SettingsService settingsService, LanguageService languageService, IExportProvider exportProvider)
{ {
this.settingsService = settingsService; this.settingsService = settingsService;
@ -198,7 +200,7 @@ namespace ICSharpCode.ILSpy.AssemblyTree
{ {
var cmdArgs = CommandLineArguments.Create(args); var cmdArgs = CommandLineArguments.Create(args);
await Dispatcher.InvokeAsync(async () => { await UIThreadDispatcher.InvokeAsync(async () => {
if (!HandleCommandLineArguments(cmdArgs)) if (!HandleCommandLineArguments(cmdArgs))
return; return;
@ -256,7 +258,7 @@ namespace ICSharpCode.ILSpy.AssemblyTree
// Make sure we wait for assemblies being loaded... // Make sure we wait for assemblies being loaded...
// BeginInvoke in LoadedAssembly.LookupReferencedAssemblyInternal // BeginInvoke in LoadedAssembly.LookupReferencedAssemblyInternal
await Dispatcher.InvokeAsync(delegate { }, DispatcherPriority.Normal); await UIThreadDispatcher.InvokeAsync(delegate { }, DispatcherPriority.Normal);
if (mr is { ParentModule.MetadataFile: not null }) if (mr is { ParentModule.MetadataFile: not null })
{ {
@ -401,7 +403,7 @@ namespace ICSharpCode.ILSpy.AssemblyTree
AssemblyList.Open(sessionSettings.ActiveAutoLoadedAssembly, true); AssemblyList.Open(sessionSettings.ActiveAutoLoadedAssembly, true);
} }
Dispatcher.BeginInvoke(DispatcherPriority.Loaded, OpenAssemblies); UIThreadDispatcher.BeginInvoke(DispatcherPriority.Loaded, OpenAssemblies);
} }
private async Task OpenAssemblies() private async Task OpenAssemblies()
@ -536,14 +538,14 @@ namespace ICSharpCode.ILSpy.AssemblyTree
if (SelectedItem == node) if (SelectedItem == node)
{ {
Dispatcher.BeginInvoke(RefreshDecompiledView); UIThreadDispatcher.BeginInvoke(RefreshDecompiledView);
} }
else else
{ {
activeView?.ScrollIntoView(node); activeView?.ScrollIntoView(node);
SelectedItem = node; SelectedItem = node;
Dispatcher.BeginInvoke(DispatcherPriority.Background, () => { UIThreadDispatcher.BeginInvoke(DispatcherPriority.Background, () => {
activeView?.ScrollIntoView(node); activeView?.ScrollIntoView(node);
}); });
} }
@ -795,7 +797,7 @@ namespace ICSharpCode.ILSpy.AssemblyTree
{ {
ContextMenuProvider.ContextMenuClosed -= ContextMenuClosed; ContextMenuProvider.ContextMenuClosed -= ContextMenuClosed;
Dispatcher.BeginInvoke(DispatcherPriority.Background, () => { UIThreadDispatcher.BeginInvoke(DispatcherPriority.Background, () => {
if (Mouse.RightButton != MouseButtonState.Pressed) if (Mouse.RightButton != MouseButtonState.Pressed)
{ {
RefreshDecompiledView(); RefreshDecompiledView();

2
ILSpy/Docking/DockWorkspace.cs

@ -46,7 +46,7 @@ namespace ICSharpCode.ILSpy.Docking
{ {
[Export] [Export]
[Shared] [Shared]
public class DockWorkspace : ObservableObject, ILayoutUpdateStrategy public class DockWorkspace : ObservableObjectBase, ILayoutUpdateStrategy
{ {
private readonly IExportProvider exportProvider; private readonly IExportProvider exportProvider;

2
ILSpy/LanguageSettings.cs

@ -31,7 +31,7 @@ namespace ICSharpCode.ILSpy
/// <summary> /// <summary>
/// Represents the filters applied to the tree view. /// Represents the filters applied to the tree view.
/// </summary> /// </summary>
public class LanguageSettings : ObservableObject, IChildSettings public class LanguageSettings : ObservableObjectBase, IChildSettings
{ {
/// <summary> /// <summary>
/// This dictionary is necessary to remember language versions across language changes. For example, /// This dictionary is necessary to remember language versions across language changes. For example,

2
ILSpy/MainWindowViewModel.cs

@ -27,7 +27,7 @@ namespace ICSharpCode.ILSpy
{ {
[Export] [Export]
[Shared] [Shared]
public class MainWindowViewModel(SettingsService settingsService, LanguageService languageService, DockWorkspace dockWorkspace) : ObservableObject public class MainWindowViewModel(SettingsService settingsService, LanguageService languageService, DockWorkspace dockWorkspace) : ObservableObjectBase
{ {
public DockWorkspace Workspace { get; } = dockWorkspace; public DockWorkspace Workspace { get; } = dockWorkspace;

2
ILSpy/Options/DisplaySettings.cs

@ -28,7 +28,7 @@ namespace ICSharpCode.ILSpy.Options
/// <summary> /// <summary>
/// Description of DisplaySettings. /// Description of DisplaySettings.
/// </summary> /// </summary>
public class DisplaySettings : ObservableObject, ISettingsSection public class DisplaySettings : ObservableObjectBase, ISettingsSection
{ {
FontFamily selectedFont; FontFamily selectedFont;
public FontFamily SelectedFont { public FontFamily SelectedFont {

2
ILSpy/Options/DisplaySettingsViewModel.cs

@ -14,7 +14,7 @@ namespace ICSharpCode.ILSpy.Options
{ {
[ExportOptionPage(Order = 20)] [ExportOptionPage(Order = 20)]
[NonShared] [NonShared]
public class DisplaySettingsViewModel : ObservableObject, IOptionPage public class DisplaySettingsViewModel : ObservableObjectBase, IOptionPage
{ {
private DisplaySettings settings = new(); private DisplaySettings settings = new();
private FontFamily[] fontFamilies; private FontFamily[] fontFamilies;

2
ILSpy/Options/MiscSettings.cs

@ -23,7 +23,7 @@ using TomsToolbox.Wpf;
namespace ICSharpCode.ILSpyX.Settings namespace ICSharpCode.ILSpyX.Settings
{ {
public class MiscSettings : ObservableObject, ISettingsSection public class MiscSettings : ObservableObjectBase, ISettingsSection
{ {
private bool allowMultipleInstances; private bool allowMultipleInstances;
private bool loadPreviousAssemblies = true; private bool loadPreviousAssemblies = true;

2
ILSpy/Options/MiscSettingsViewModel.cs

@ -34,7 +34,7 @@ namespace ICSharpCode.ILSpy.Options
{ {
[ExportOptionPage(Order = 30)] [ExportOptionPage(Order = 30)]
[NonShared] [NonShared]
public class MiscSettingsViewModel : ObservableObject, IOptionPage public class MiscSettingsViewModel : ObservableObjectBase, IOptionPage
{ {
private MiscSettings settings; private MiscSettings settings;
public MiscSettings Settings { public MiscSettings Settings {

4
ILSpy/Options/OptionsDialogViewModel.cs

@ -27,14 +27,14 @@ using TomsToolbox.Wpf;
namespace ICSharpCode.ILSpy.Options namespace ICSharpCode.ILSpy.Options
{ {
public class OptionsItemViewModel(IOptionPage content) : ObservableObject public class OptionsItemViewModel(IOptionPage content) : ObservableObjectBase
{ {
public string Title { get; } = content.Title; public string Title { get; } = content.Title;
public IOptionPage Content { get; } = content; public IOptionPage Content { get; } = content;
} }
public class OptionsDialogViewModel : ObservableObject public class OptionsDialogViewModel : ObservableObjectBase
{ {
private IOptionPage? selectedPage; private IOptionPage? selectedPage;

2
ILSpy/ViewModels/CompareViewModel.cs

@ -46,7 +46,7 @@ namespace ICSharpCode.ILSpy.ViewModels
using TomsToolbox.Wpf; using TomsToolbox.Wpf;
class CompareViewModel : ObservableObject class CompareViewModel : ObservableObjectBase
{ {
private readonly TabPageModel tabPage; private readonly TabPageModel tabPage;
private readonly AssemblyTreeModel assemblyTreeModel; private readonly AssemblyTreeModel assemblyTreeModel;

2
ILSpy/ViewModels/ManageAssemblyListsViewModel.cs

@ -34,7 +34,7 @@ using DelegateCommand = ICSharpCode.ILSpy.Commands.DelegateCommand;
namespace ICSharpCode.ILSpy.ViewModels namespace ICSharpCode.ILSpy.ViewModels
{ {
public class ManageAssemblyListsViewModel : ObservableObject public class ManageAssemblyListsViewModel : ObservableObjectBase
{ {
private readonly AssemblyListManager manager; private readonly AssemblyListManager manager;
private readonly Window parent; private readonly Window parent;

2
ILSpy/ViewModels/PaneModel.cs

@ -27,7 +27,7 @@ using TomsToolbox.Wpf;
namespace ICSharpCode.ILSpy.ViewModels namespace ICSharpCode.ILSpy.ViewModels
{ {
public abstract class PaneModel : ObservableObject public abstract class PaneModel : ObservableObjectBase
{ {
private readonly Throttle titleChangeThrottle; private readonly Throttle titleChangeThrottle;

2
ILSpy/ViewModels/UpdatePanelViewModel.cs

@ -28,7 +28,7 @@ namespace ICSharpCode.ILSpy.ViewModels;
[Export] [Export]
[NonShared] [NonShared]
public class UpdatePanelViewModel : ObservableObject public class UpdatePanelViewModel : ObservableObjectBase
{ {
bool isPanelVisible; bool isPanelVisible;
string updateAvailableDownloadUrl; string updateAvailableDownloadUrl;

4
TestPlugin/CustomOptionPage.xaml.cs

@ -25,7 +25,7 @@ namespace TestPlugin
[ExportOptionPage(Order = 0)] [ExportOptionPage(Order = 0)]
[NonShared] [NonShared]
class CustomOptionsViewModel : ObservableObject, IOptionPage class CustomOptionsViewModel : ObservableObjectBase, IOptionPage
{ {
private Options options; private Options options;
@ -47,7 +47,7 @@ namespace TestPlugin
} }
} }
class Options : ObservableObject, ISettingsSection class Options : ObservableObjectBase, ISettingsSection
{ {
static readonly XNamespace ns = "http://www.ilspy.net/testplugin"; static readonly XNamespace ns = "http://www.ilspy.net/testplugin";

Loading…
Cancel
Save