Skip to content

Commit 1cfc5e7

Browse files
authored
Do not use ObservableObject when ObservableObjectBase is sufficient. (#3644)
* Do not use ObservableObject when ObservableObjectBase is sufficient.
1 parent 5317694 commit 1cfc5e7

16 files changed

+25
-23
lines changed

ILSpy.ReadyToRun/ReadyToRunOptionPage.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public ReadyToRunOptionPage()
3838

3939
[ExportOptionPage(Order = 40)]
4040
[NonShared]
41-
class ReadyToRunOptionsViewModel : ObservableObject, IOptionPage
41+
class ReadyToRunOptionsViewModel : ObservableObjectBase, IOptionPage
4242
{
4343
private ReadyToRunOptions options;
4444

ILSpy.ReadyToRun/ReadyToRunOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
namespace ICSharpCode.ILSpy.ReadyToRun
2626
{
27-
internal partial class ReadyToRunOptions : ObservableObject, ISettingsSection
27+
internal partial class ReadyToRunOptions : ObservableObjectBase, ISettingsSection
2828
{
2929
private static readonly XNamespace ns = "http://www.ilspy.net/ready-to-run";
3030

ILSpy/AssemblyTree/AssemblyTreeModel.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ public class AssemblyTreeModel : ToolPaneModel
7272
private readonly LanguageService languageService;
7373
private readonly IExportProvider exportProvider;
7474

75+
private static Dispatcher UIThreadDispatcher => Application.Current.Dispatcher;
76+
7577
public AssemblyTreeModel(SettingsService settingsService, LanguageService languageService, IExportProvider exportProvider)
7678
{
7779
this.settingsService = settingsService;
@@ -198,7 +200,7 @@ public async Task HandleSingleInstanceCommandLineArguments(string[] args)
198200
{
199201
var cmdArgs = CommandLineArguments.Create(args);
200202

201-
await Dispatcher.InvokeAsync(async () => {
203+
await UIThreadDispatcher.InvokeAsync(async () => {
202204

203205
if (!HandleCommandLineArguments(cmdArgs))
204206
return;
@@ -256,7 +258,7 @@ private async Task NavigateOnLaunch(string? navigateTo, string[]? activeTreeView
256258

257259
// Make sure we wait for assemblies being loaded...
258260
// BeginInvoke in LoadedAssembly.LookupReferencedAssemblyInternal
259-
await Dispatcher.InvokeAsync(delegate { }, DispatcherPriority.Normal);
261+
await UIThreadDispatcher.InvokeAsync(delegate { }, DispatcherPriority.Normal);
260262

261263
if (mr is { ParentModule.MetadataFile: not null })
262264
{
@@ -401,7 +403,7 @@ public void Initialize()
401403
AssemblyList.Open(sessionSettings.ActiveAutoLoadedAssembly, true);
402404
}
403405

404-
Dispatcher.BeginInvoke(DispatcherPriority.Loaded, OpenAssemblies);
406+
UIThreadDispatcher.BeginInvoke(DispatcherPriority.Loaded, OpenAssemblies);
405407
}
406408

407409
private async Task OpenAssemblies()
@@ -536,14 +538,14 @@ public void SelectNode(SharpTreeNode? node, bool inNewTabPage = false)
536538

537539
if (SelectedItem == node)
538540
{
539-
Dispatcher.BeginInvoke(RefreshDecompiledView);
541+
UIThreadDispatcher.BeginInvoke(RefreshDecompiledView);
540542
}
541543
else
542544
{
543545
activeView?.ScrollIntoView(node);
544546
SelectedItem = node;
545547

546-
Dispatcher.BeginInvoke(DispatcherPriority.Background, () => {
548+
UIThreadDispatcher.BeginInvoke(DispatcherPriority.Background, () => {
547549
activeView?.ScrollIntoView(node);
548550
});
549551
}
@@ -795,7 +797,7 @@ void ContextMenuClosed(object? sender, EventArgs e)
795797
{
796798
ContextMenuProvider.ContextMenuClosed -= ContextMenuClosed;
797799

798-
Dispatcher.BeginInvoke(DispatcherPriority.Background, () => {
800+
UIThreadDispatcher.BeginInvoke(DispatcherPriority.Background, () => {
799801
if (Mouse.RightButton != MouseButtonState.Pressed)
800802
{
801803
RefreshDecompiledView();

ILSpy/Docking/DockWorkspace.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ namespace ICSharpCode.ILSpy.Docking
4646
{
4747
[Export]
4848
[Shared]
49-
public class DockWorkspace : ObservableObject, ILayoutUpdateStrategy
49+
public class DockWorkspace : ObservableObjectBase, ILayoutUpdateStrategy
5050
{
5151
private readonly IExportProvider exportProvider;
5252

ILSpy/LanguageSettings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ namespace ICSharpCode.ILSpy
3131
/// <summary>
3232
/// Represents the filters applied to the tree view.
3333
/// </summary>
34-
public class LanguageSettings : ObservableObject, IChildSettings
34+
public class LanguageSettings : ObservableObjectBase, IChildSettings
3535
{
3636
/// <summary>
3737
/// This dictionary is necessary to remember language versions across language changes. For example,

ILSpy/MainWindowViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ namespace ICSharpCode.ILSpy
2727
{
2828
[Export]
2929
[Shared]
30-
public class MainWindowViewModel(SettingsService settingsService, LanguageService languageService, DockWorkspace dockWorkspace) : ObservableObject
30+
public class MainWindowViewModel(SettingsService settingsService, LanguageService languageService, DockWorkspace dockWorkspace) : ObservableObjectBase
3131
{
3232
public DockWorkspace Workspace { get; } = dockWorkspace;
3333

ILSpy/Options/DisplaySettings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ namespace ICSharpCode.ILSpy.Options
2828
/// <summary>
2929
/// Description of DisplaySettings.
3030
/// </summary>
31-
public class DisplaySettings : ObservableObject, ISettingsSection
31+
public class DisplaySettings : ObservableObjectBase, ISettingsSection
3232
{
3333
FontFamily selectedFont;
3434
public FontFamily SelectedFont {

ILSpy/Options/DisplaySettingsViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace ICSharpCode.ILSpy.Options
1414
{
1515
[ExportOptionPage(Order = 20)]
1616
[NonShared]
17-
public class DisplaySettingsViewModel : ObservableObject, IOptionPage
17+
public class DisplaySettingsViewModel : ObservableObjectBase, IOptionPage
1818
{
1919
private DisplaySettings settings = new();
2020
private FontFamily[] fontFamilies;

ILSpy/Options/MiscSettings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
namespace ICSharpCode.ILSpyX.Settings
2525
{
26-
public class MiscSettings : ObservableObject, ISettingsSection
26+
public class MiscSettings : ObservableObjectBase, ISettingsSection
2727
{
2828
private bool allowMultipleInstances;
2929
private bool loadPreviousAssemblies = true;

ILSpy/Options/MiscSettingsViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ namespace ICSharpCode.ILSpy.Options
3434
{
3535
[ExportOptionPage(Order = 30)]
3636
[NonShared]
37-
public class MiscSettingsViewModel : ObservableObject, IOptionPage
37+
public class MiscSettingsViewModel : ObservableObjectBase, IOptionPage
3838
{
3939
private MiscSettings settings;
4040
public MiscSettings Settings {

0 commit comments

Comments
 (0)