コード例 #1
0
        public RunViaUnityEditorStrategy(ISolution solution,
                                         IUnitTestResultManager unitTestResultManager,
                                         UnityEditorProtocol editorProtocol,
                                         NUnitTestProvider unitTestProvider,
                                         IUnitTestElementIdFactory idFactory,
                                         ISolutionSaver riderSolutionSaver,
                                         UnityRefresher unityRefresher,
                                         NotificationsModel notificationsModel,
                                         UnityHost unityHost,
                                         ILogger logger,
                                         Lifetime lifetime,
                                         PackageValidator packageValidator
                                         )
        {
            mySolution = solution;
            myUnitTestResultManager = unitTestResultManager;
            myEditorProtocol        = editorProtocol;
            myUnitTestProvider      = unitTestProvider;
            myIDFactory             = idFactory;
            myRiderSolutionSaver    = riderSolutionSaver;
            myUnityRefresher        = unityRefresher;
            myNotificationsModel    = notificationsModel;
            myUnityHost             = unityHost;
            myLogger           = logger;
            myLifetime         = lifetime;
            myPackageValidator = packageValidator;
            myElements         = new WeakToWeakDictionary <UnitTestElementId, IUnitTestElement>();

            myUnityProcessId = new Property <int?>(lifetime, "RunViaUnityEditorStrategy.UnityProcessId");

            myUnityProcessId.ForEachValue_NotNull(lifetime, (lt, processId) =>
            {
                var process = myLogger.CatchIgnore(() => Process.GetProcessById(processId.NotNull()));
                if (process == null)
                {
                    myUnityProcessId.Value = null;
                    return;
                }

                process.EnableRaisingEvents = true;

                void OnProcessExited(object sender, EventArgs a) => myUnityProcessId.Value = null;
                lt.Bracket(() => process.Exited += OnProcessExited, () => process.Exited -= OnProcessExited);

                if (process.HasExited)
                {
                    myUnityProcessId.Value = null;
                }
            });

            myEditorProtocol.UnityModel.ViewNotNull(lifetime, (lt, model) =>
            {
                if (model.UnityProcessId.HasValue())
                {
                    myUnityProcessId.Value = model.UnityProcessId.Value;
                }

                model.UnityProcessId.FlowInto(lt, myUnityProcessId, id => id);
            });
        }
コード例 #2
0
        public RunViaUnityEditorStrategy(ISolution solution,
                                         IUnitTestResultManager unitTestResultManager,
                                         BackendUnityHost backendUnityHost,
                                         NUnitTestProvider unitTestProvider,
                                         IUnitTestElementIdFactory idFactory,
                                         ISolutionSaver riderSolutionSaver,
                                         UnityRefresher unityRefresher,
                                         NotificationsModel notificationsModel,
                                         FrontendBackendHost frontendBackendHost,
                                         ILogger logger,
                                         Lifetime lifetime,
                                         PackageValidator packageValidator,
                                         JetBrains.Application.ActivityTrackingNew.UsageStatistics usageStatistics)
        {
            mySolution = solution;
            myUnitTestResultManager = unitTestResultManager;
            myBackendUnityHost      = backendUnityHost;
            myUnitTestProvider      = unitTestProvider;
            myIDFactory             = idFactory;
            myRiderSolutionSaver    = riderSolutionSaver;
            myUnityRefresher        = unityRefresher;
            myNotificationsModel    = notificationsModel;
            myFrontendBackendHost   = frontendBackendHost;
            myLogger           = logger;
            myLifetime         = lifetime;
            myPackageValidator = packageValidator;
            myUsageStatistics  = usageStatistics;

            myUnityProcessId = new Property <int?>(lifetime, "RunViaUnityEditorStrategy.UnityProcessId");

            myUnityProcessId.ForEachValue_NotNull(lifetime, (lt, processId) =>
            {
                var process = myLogger.CatchIgnore(() => Process.GetProcessById(processId.NotNull()));
                if (process == null)
                {
                    myUnityProcessId.Value = null;
                    return;
                }

                process.EnableRaisingEvents = true;

                void OnProcessExited(object sender, EventArgs a) => myUnityProcessId.Value = null;
                lt.Bracket(() => process.Exited += OnProcessExited, () => process.Exited -= OnProcessExited);

                if (process.HasExited)
                {
                    myUnityProcessId.Value = null;
                }
            });

            myBackendUnityHost.BackendUnityModel.ViewNotNull(lifetime, (lt, model) =>
            {
                // This will set the current value, if it exists
                model.UnityApplicationData.FlowInto(lt, myUnityProcessId, data => data.UnityProcessId);
            });
        }
        private void OnGUI()
        {
            EditorGUILayout.BeginVertical();

            if (GUILayout.Button("Refresh"))
            {
                RefreshPackages();
            }

            if (packages.Count > 0)
            {
                if (GUILayout.Button("Update All"))
                {
                    ReinstallAllGitPackages();
                    UnityRefresher.RefreshExceptPackages();
                }

                if (GUILayout.Button("Update All (Including Non-Git)"))
                {
                    File.Delete(PackagesLockPath);
                    UnityRefresher.RefreshExceptPackages();
                }

                EditorGUILayout.HelpBox("Or select a package below to update", MessageType.Info);
            }

            scrollPosition = GUILayout.BeginScrollView(
                scrollPosition: scrollPosition,
                alwaysShowHorizontal: false,
                alwaysShowVertical: false,
                horizontalScrollbar: GUIStyle.none,
                verticalScrollbar: GUI.skin.verticalScrollbar,
                background: "Box"
                );

            scrollPosition.x = 0;

            for (var i = 0; i < packages.Count; i++)
            {
                if (GUILayout.Button(packages[i]))
                {
                    ReinstallPackage(packages[i]);
                    UnityRefresher.RefreshExceptPackages();
                }
            }

            GUILayout.EndScrollView();

            EditorGUILayout.EndVertical();
        }
コード例 #4
0
 public RunViaUnityEditorStrategy(ISolution solution,
                                  IUnitTestResultManager unitTestResultManager,
                                  UnityEditorProtocol editorProtocol,
                                  NUnitTestProvider unitTestProvider,
                                  IUnitTestElementIdFactory idFactory,
                                  ISolutionSaver riderSolutionSaver,
                                  UnityRefresher unityRefresher,
                                  NotificationsModel notificationsModel,
                                  UnityHost unityHost,
                                  ILogger logger
                                  )
 {
     mySolution = solution;
     myUnitTestResultManager = unitTestResultManager;
     myEditorProtocol        = editorProtocol;
     myUnitTestProvider      = unitTestProvider;
     myIDFactory             = idFactory;
     myRiderSolutionSaver    = riderSolutionSaver;
     myUnityRefresher        = unityRefresher;
     myNotificationsModel    = notificationsModel;
     myUnityHost             = unityHost;
     myLogger   = logger;
     myElements = new WeakToWeakDictionary <UnitTestElementId, IUnitTestElement>();
 }