private void DeletePlugin()

in src/dotnet/RiderPlugin.UnrealLink/PluginInstaller/UnrealPluginInstaller.cs [603:681]


        private void DeletePlugin()
        {
            var installInfo = myPluginDetector.InstallInfoProperty.Value;
            myLogger.Info($"[UnrealLink]: Deleting RiderLink plugins");
            
            var cppUe4SolutionDetector = mySolution.GetComponent<ICppUE4SolutionDetector>();
            var isSln = cppUe4SolutionDetector.SupportRiderProjectModel != CppUE4ProjectModelSupportMode.UprojectOpened;

            UnrealPluginInstallInfo.InstallDescription description = installInfo.EnginePlugin;
            bool result = true;
            result &= DeletePluginUsingDescription(description);
            foreach (var installInfoProjectPlugin in installInfo.ProjectPlugins)
            {
                description = installInfoProjectPlugin;
                result &= DeletePluginUsingDescription(installInfoProjectPlugin);
            }

            if (result)
            {
                myLogger.Info($"[UnrealLink]: RiderLink is deleted");
                
                var title = Strings.DeletingRiderLinkPlugin_Text;
                var text = Strings.RiderLinkIsDeleted_Text;

                myUnrealHost.myModel.RiderLinkInstallMessage(new InstallMessage(title, ContentType.Normal));
                myUnrealHost.myModel.RiderLinkInstallMessage(new InstallMessage(text, ContentType.Normal));

                var notification = new NotificationModel(mySolution.GetRdProjectId(), title, text, true,
                    RdNotificationEntryType.INFO, new List<NotificationHyperlink>());

                mySolution.Locks.ExecuteOrQueue(Lifetime, "UnrealLink.InstallPlugin",
                    () => { myNotificationsModel.Notification(notification); });
            }
            else
            {
                myLogger.Warn($"[UnrealLink]: Failed to delete RiderLink");
                
                var title = Strings.DeletingRiderLinkPlugin_Text;
                var text = Strings.FailedToDeleteRiderLink_Text;

                myUnrealHost.myModel.RiderLinkInstallMessage(new InstallMessage(title, ContentType.Normal));
                myUnrealHost.myModel.RiderLinkInstallMessage(new InstallMessage(text, ContentType.Normal));

                var notification = new NotificationModel(mySolution.GetRdProjectId(), title, text, true,
                    RdNotificationEntryType.ERROR, new List<NotificationHyperlink>());

                mySolution.Locks.ExecuteOrQueue(Lifetime, "UnrealLink.InstallPlugin",
                    () => { myNotificationsModel.Notification(notification); });
            }

            if (isSln)
            {
                RefreshSlnProjectFiles(description, installInfo.EngineRoot);
            }
            return;

            bool DeletePluginUsingDescription(UnrealPluginInstallInfo.InstallDescription description)
            {
                if (description.IsPluginAvailable)
                {
                    try
                    {
                        description.UnrealPluginRootFolder.Delete();
                    }
                    catch (Exception)
                    {
                        myLogger.Warn($"[UnrealLink]: Failed to delete RiderLink from {description.UnrealPluginRootFolder}");
                        return false;
                    }
                    description.IsPluginAvailable = false;
                    if (!isSln)
                    {
                        RefreshUprojectProjectFiles(Lifetime, description.UnrealPluginRootFolder);
                    }
                }

                return true;
            }
        }