public static List <CodeLensEntryExtraActionModel> GetExtraActions(UnitySolutionTracker solutionTracker,
                                                                           BackendUnityHost backendUnityHost)
        {
            var extraActions = new List <CodeLensEntryExtraActionModel>();

            if (solutionTracker.IsUnityProject.HasTrueValue() && !backendUnityHost.IsConnectionEstablished())
            {
                extraActions.Add(new CodeLensEntryExtraActionModel("Unity is not running", null));
                extraActions.Add(new CodeLensEntryExtraActionModel("Start Unity Editor",
                                                                   AbstractUnityCodeInsightProvider.StartUnityActionId));
            }

            return(extraActions);
        }
        private async Task RefreshInternal(Lifetime lifetime, RefreshType refreshType)
        {
            myLocks.ReentrancyGuard.AssertGuarded();

            if (myBackendUnityHost.BackendUnityModel.Value == null)
            {
                return;
            }

            if (!myBackendUnityHost.IsConnectionEstablished())
            {
                return;
            }

            var lifetimeDef = Lifetime.Define(lifetime);

            try
            {
                myLogger.Verbose($"myPluginProtocolController.UnityModel.Value.Refresh.StartAsTask, force = {refreshType} Started");
                mySolution.GetComponent <RiderBackgroundTaskHost>().AddNewTask(lifetimeDef.Lifetime,
                                                                               RiderBackgroundTaskBuilder.Create().WithHeader("Refreshing solution in Unity Editor...")
                                                                               .AsIndeterminate().AsNonCancelable());

                var version = myUnityVersion.ActualVersionForSolution.Value;
                try
                {
                    if (version != null && version.Major < 2018)
                    {
                        using (mySolution.GetComponent <VfsListener>().PauseChanges())
                        {
                            try
                            {
                                await myBackendUnityHost.BackendUnityModel.Value.Refresh.Start(lifetimeDef.Lifetime, refreshType).AsTask();
                            }
                            finally
                            {
                                await myLocks.Tasks.YieldTo(myLifetime, Scheduling.MainGuard);
                            }
                        }
                    }
                    else // it is a risk to pause vfs https://github.com/JetBrains/resharper-unity/issues/1601
                    {
                        await myBackendUnityHost.BackendUnityModel.Value.Refresh.Start(lifetimeDef.Lifetime, refreshType).AsTask();
                    }
                }
                catch (Exception e)
                {
                    myLogger.Warn(e, comment: "connection usually brakes during refresh.");
                }
                finally
                {
                    await myLocks.Tasks.YieldTo(myLifetime, Scheduling.MainGuard);

                    myLogger.Verbose(
                        $"myPluginProtocolController.UnityModel.Value.Refresh.StartAsTask, force = {refreshType} Finished");
                    var solution  = mySolution.GetProtocolSolution();
                    var solFolder = mySolution.SolutionDirectory;
                    var list      = new List <string> {
                        solFolder.FullPath
                    };
                    myLogger.Verbose("RefreshPaths.StartAsTask Finished.");
                    await solution.GetFileSystemModel().RefreshPaths
                    .Start(lifetimeDef.Lifetime, new RdRefreshRequest(list, true)).AsTask();

                    await myLocks.Tasks.YieldTo(myLifetime, Scheduling.MainGuard);
                }
            }
            catch (Exception e)
            {
                myLogger.LogException(e);
            }
            finally
            {
                lifetimeDef.Terminate();
            }
        }