diff --git a/resharper/src/Application/Settings/SettingsSynchronizer.cs b/resharper/src/Application/Settings/SettingsSynchronizer.cs index f0308eb..ec4c725 100644 --- a/resharper/src/Application/Settings/SettingsSynchronizer.cs +++ b/resharper/src/Application/Settings/SettingsSynchronizer.cs @@ -13,7 +13,7 @@ namespace JetBrains.ReSharper.Plugins.Godot.Application.Settings { - [SolutionComponent(InstantiationEx.LegacyDefault)] + [SolutionComponent(Instantiation.LaterAsyncAnyThreadSafe)] public class SettingsSynchronizer { public SettingsSynchronizer(Lifetime lifetime, ISolution solution, FrontendBackendHost host, @@ -44,7 +44,8 @@ private static void BindSettingToProperty( { var name = entry.GetInstanceMemberName(); var setting = boundStore.Schema.GetScalarEntry(entry); - boundStore.GetValueProperty(lifetime, setting, null).Change.Advise_HasNew(lifetime, + var apartmentForNotifications = ApartmentForNotifications.Primary(solution.Locks); + boundStore.GetValueProperty2(lifetime, setting, null, apartmentForNotifications).Change.Advise_HasNew(lifetime, args => { solution.Locks.ExecuteOrQueueEx(lifetime, name, () => diff --git a/resharper/src/Protocol/FrontendBackendHost.cs b/resharper/src/Protocol/FrontendBackendHost.cs index 1d10fa7..87a8f12 100644 --- a/resharper/src/Protocol/FrontendBackendHost.cs +++ b/resharper/src/Protocol/FrontendBackendHost.cs @@ -1,37 +1,27 @@ using System; using JetBrains.Annotations; using JetBrains.Application.Parts; -using JetBrains.Application.Threading; -using JetBrains.Lifetimes; using JetBrains.ProjectModel; -using JetBrains.RdBackend.Common.Features; using JetBrains.ReSharper.Feature.Services.Protocol; using JetBrains.Rider.Model.Godot.FrontendBackend; namespace JetBrains.ReSharper.Plugins.Godot.Protocol { - [SolutionComponent(InstantiationEx.LegacyDefault)] + [SolutionComponent(Instantiation.DemandAnyThreadSafe)] public class FrontendBackendHost { - private readonly bool myIsInTests; - // This will only ever be null when running tests. The value does not change for the lifetime of the solution. // Prefer using this field over calling GetFrontendBackendModel(), as that method will throw in tests [CanBeNull] public readonly GodotFrontendBackendModel Model; - public FrontendBackendHost(Lifetime lifetime, ISolution solution, IShellLocks shellLocks, - bool isInTests = false) + public FrontendBackendHost(ISolution solution) { - myIsInTests = isInTests; - if (myIsInTests) - return; - // This will throw in tests, as GetProtocolSolution will return null var model = solution.GetProtocolSolution().GetGodotFrontendBackendModel(); Model = model; } - public bool IsAvailable => !myIsInTests && Model != null; + public bool IsAvailable => Model != null; // Convenience method to fire and forget an action on the model (e.g. set a value, fire a signal, etc). Fire and // forget means it's safe to use during testing, when there won't be a frontend model available, and Model will @@ -40,9 +30,6 @@ public FrontendBackendHost(Lifetime lifetime, ISolution solution, IShellLocks sh // Model directly in this case, check for null and do whatever is appropriate for the callsite. public void Do(Action action) { - if (myIsInTests) - return; - action(Model); } }