public UnityEditorProtocol(Lifetime lifetime, ILogger logger, UnityHost host, IScheduler dispatcher, IShellLocks locks, ISolution solution, PluginPathsProvider pluginPathsProvider, ISettingsStore settingsStore, JetBrains.Application.ActivityTrackingNew.UsageStatistics usageStatistics, UnitySolutionTracker unitySolutionTracker, IThreading threading) { myComponentLifetime = lifetime; myLogger = logger; myDispatcher = dispatcher; myLocks = locks; mySolution = solution; myPluginPathsProvider = pluginPathsProvider; myUsageStatistics = usageStatistics; myThreading = threading; myHost = host; myBoundSettingsStore = settingsStore.BindToContextLive(lifetime, ContextRange.Smart(solution.ToDataContext())); mySessionLifetimes = new SequentialLifetimes(lifetime); if (solution.GetData(ProjectModelExtensions.ProtocolSolutionKey) == null) { return; } unitySolutionTracker.IsUnityProject.View(lifetime, (lf, args) => { if (!args) { return; } var solFolder = mySolution.SolutionFilePath.Directory; AdviseModelData(lifetime); // todo: consider non-Unity Solution with Unity-generated projects var protocolInstancePath = solFolder.Combine("Library/ProtocolInstance.json"); protocolInstancePath.Directory.CreateDirectory(); var watcher = new FileSystemWatcher(); watcher.Path = protocolInstancePath.Directory.FullPath; watcher.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite; //Watch for changes in LastAccess and LastWrite times watcher.Filter = protocolInstancePath.Name; // Add event handlers. watcher.Changed += OnChanged; watcher.Created += OnChanged; lf.Bracket(() => { }, () => { watcher.Dispose(); }); watcher.EnableRaisingEvents = true; // Begin watching. // connect on start of Rider CreateProtocols(protocolInstancePath); }); }
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); }); }
public UnityEditorProtocol(Lifetime lifetime, ILogger logger, UnityHost host, IScheduler dispatcher, IShellLocks locks, ISolution solution, ISettingsStore settingsStore, JetBrains.Application.ActivityTrackingNew.UsageStatistics usageStatistics, UnitySolutionTracker unitySolutionTracker, IThreading threading, UnityVersion unityVersion, NotificationsModel notificationsModel, IHostProductInfo hostProductInfo, IFileSystemTracker fileSystemTracker) { myPluginInstallations = new JetHashSet <FileSystemPath>(); myComponentLifetime = lifetime; myLogger = logger; myDispatcher = dispatcher; myLocks = locks; mySolution = solution; myUsageStatistics = usageStatistics; myThreading = threading; myUnityVersion = unityVersion; myNotificationsModel = notificationsModel; myHostProductInfo = hostProductInfo; myHost = host; myBoundSettingsStore = settingsStore.BindToContextLive(lifetime, ContextRange.Smart(solution.ToDataContext())); mySessionLifetimes = new SequentialLifetimes(lifetime); if (solution.GetData(ProjectModelExtensions.ProtocolSolutionKey) == null) { return; } unitySolutionTracker.IsUnityProject.View(lifetime, (lf, args) => { if (!args) { return; } var solFolder = mySolution.SolutionDirectory; AdviseModelData(lifetime); // todo: consider non-Unity Solution with Unity-generated projects var protocolInstancePath = solFolder.Combine("Library/ProtocolInstance.json"); fileSystemTracker.AdviseFileChanges(lf, protocolInstancePath, OnChangeAction); // connect on start of Rider CreateProtocols(protocolInstancePath); }); }
// TODO: Remove FrontendBackendHost. It's too easy to get circular dependencies public BackendUnityHost(Lifetime lifetime, ILogger logger, FrontendBackendHost frontendBackendHost, IThreading threading, IIsApplicationActiveState isApplicationActiveState, PackageManager packageManager, JetBrains.Application.ActivityTrackingNew.UsageStatistics usageStatistics) { myUsageStatistics = usageStatistics; myEditorState = UnityEditorState.Disconnected; BackendUnityModel.ViewNotNull(lifetime, (modelLifetime, backendUnityModel) => { InitialiseModel(backendUnityModel); AdviseModel(backendUnityModel, modelLifetime, packageManager); StartPollingUnityEditorState(backendUnityModel, modelLifetime, frontendBackendHost, threading, isApplicationActiveState, logger); }); BackendUnityModel.ViewNull(lifetime, _ => { myEditorState = UnityEditorState.Disconnected; if (frontendBackendHost.IsAvailable) { UpdateFrontendEditorState(frontendBackendHost, logger); } }); // Are we testing? if (frontendBackendHost.IsAvailable) { // Tell the frontend if the backend/Unity connection is available // (not actually passthrough) var frontendBackendModel = frontendBackendHost.Model.NotNull("frontendBackendHost.Model != null"); BackendUnityModel.FlowIntoRdSafe(lifetime, backendUnityModel => backendUnityModel != null, frontendBackendModel.UnityEditorConnected); } }
public T4InternalGenerator([NotNull] UsageStatisticsNew statistics, [NotNull] ILogger logger) { Statistics = statistics; Logger = logger; }