private static void AdvisePackages(Lifetime lifetime, FrontendBackendModel frontendBackendModel, PackageManager packageManager) { // Called in the Guarded reentrancy context packageManager.Packages.AddRemove.Advise(lifetime, args => { switch (args.Action) { case AddRemove.Add: var packageData = args.Value.Value; var packageDetails = packageData.PackageDetails; var source = ToProtocolPackageSource(packageData.Source); var dependencies = (from d in packageDetails.Dependencies select new UnityPackageDependency(d.Key, d.Value)).ToArray(); var gitDetails = packageData.GitDetails != null ? new UnityGitDetails(packageData.GitDetails.Url, packageData.GitDetails.Hash, packageData.GitDetails.Revision) : null; var package = new UnityPackage(args.Value.Key, packageDetails.Version, packageData.PackageFolder?.FullPath, source, packageDetails.DisplayName, packageDetails.Description, dependencies, packageData.TarballLocation?.FullPath, gitDetails); frontendBackendModel.Packages.Add(args.Value.Key, package); break; case AddRemove.Remove: frontendBackendModel.Packages.Remove(args.Value.Key); break; } }); }
public UnityNUnitServiceProvider(ISolution solution, IPsiModules psiModules, ISymbolCache symbolCache, IUnitTestElementIdFactory idFactory, IUnitTestElementManager elementManager, NUnitTestProvider provider, IUnitTestingSettings settings, ISettingsStore settingsStore, ISettingsOptimization settingsOptimization, ISettingsCache settingsCache, UnitTestingCachingService cachingService, INUnitTestParametersProvider testParametersProvider, FrontendBackendHost frontendBackendHost, BackendUnityHost backendUnityHost, RunViaUnityEditorStrategy runViaUnityEditorStrategy, UnitySolutionTracker unitySolutionTracker) : base(solution, psiModules, symbolCache, idFactory, elementManager, provider, settings, settingsStore, settingsOptimization, settingsCache, cachingService, testParametersProvider) { // Only in tests if (!frontendBackendHost.IsAvailable) { return; } myFrontendBackendModel = frontendBackendHost.Model.NotNull("frontendBackendHost.Model != null"); myBackendUnityHost = backendUnityHost; myUnityEditorStrategy = runViaUnityEditorStrategy; myUnitySolutionTracker = unitySolutionTracker; }
private static void AdviseModel(Lifetime lifetime, FrontendBackendModel frontendBackendModel, PackageManager packageManager, DeferredCacheController deferredCacheController, IThreading shellLocks) { AdvisePackages(lifetime, frontendBackendModel, packageManager); AdviseIntegrationTestHelpers(lifetime, frontendBackendModel, deferredCacheController, shellLocks); }
private static void AdviseModel(Lifetime lifetime, FrontendBackendModel frontendBackendModel, DeferredCacheController deferredCacheController, IThreading shellLocks) { deferredCacheController.CompletedOnce.Advise(lifetime, v => { if (v) { shellLocks.Tasks.StartNew(lifetime, Scheduling.MainDispatcher, () => { frontendBackendModel.IsDeferredCachesCompletedOnce.Value = true; }); } }); }
public static bool IsUnityUnitTestStrategy(UnitySolutionTracker unitySolutionTracker, FrontendBackendModel frontendBackendModel, BackendUnityHost backendUnityHost) { if (!unitySolutionTracker.IsUnityProjectFolder.HasTrueValue()) { return(false); } // first run from gutter mark should try to run in Unity by default. https://github.com/JetBrains/resharper-unity/issues/605 return(!frontendBackendModel.UnitTestPreference.HasValue() && backendUnityHost.BackendUnityModel.Value != null || (frontendBackendModel.UnitTestPreference.HasValue() && frontendBackendModel.UnitTestPreference.Value != UnitTestLaunchPreference.NUnit)); }
public FrontendBackendHost(Lifetime lifetime, ISolution solution, IShellLocks shellLocks, DeferredCacheController deferredCacheController, bool isInTests = false) { myIsInTests = isInTests; if (myIsInTests) { return; } // This will throw in tests, as GetProtocolSolution will return null var model = solution.GetProtocolSolution().GetFrontendBackendModel(); AdviseModel(lifetime, model, deferredCacheController, shellLocks); Model = model; }
public UnityController(Lifetime lifetime, ISolution solution, BackendUnityHost backendUnityHost, UnityVersion unityVersion) { if (solution.GetData(ProjectModelExtensions.ProtocolSolutionKey) == null) { return; } myBackendUnityHost = backendUnityHost; myUnityVersion = unityVersion; mySolution = solution; myLifetime = lifetime; myFrontendBackendModel = solution.GetProtocolSolution().GetFrontendBackendModel(); }
private void AdviseFrontendToUnityModel(Lifetime lifetime, FrontendBackendModel frontendBackendModel) { // BackendUnityModel is recreated frequently (e.g. on each AppDomain reload when changing play/edit mode). // So subscribe to the frontendBackendModel once and flow in changes only if backendUnityModel is available. // Note that we only flow changes, not the current value. Even though these properties are stateful, // frontendBackendModel is not the source of truth - values need to flow from backendUnityModel. Also, due // to model reload, we go through a few values before we stabilise. E.g.: // * User clicks play, fb.Play is true, flows into bu.Play which switches to play mode and causes an // AppDomain reload. // * bu.Play becomes false due to AppDomain teardown, flows into fb.Play // * BackendUnityModel is torn down and recreated (<- WARNING!) // * bu.Play becomes true as Unity enters play mode, flows into fb.Play // If we flowed the current value of fb.Play into backendUnityModel when it is recreated, we'd set it to // false, triggering play mode to end. // Step is simply since it's a non-stateful ISource<T> var backendUnityModelProperty = myBackendUnityHost.BackendUnityModel; frontendBackendModel.PlayControls.Play.FlowChangesIntoRdDeferred(lifetime, () => backendUnityModelProperty.Maybe.ValueOrDefault?.PlayControls.Play); frontendBackendModel.PlayControls.Pause.FlowChangesIntoRdDeferred(lifetime, () => backendUnityModelProperty.Maybe.ValueOrDefault?.PlayControls.Pause); frontendBackendModel.PlayControls.Step.Advise(lifetime, () => backendUnityModelProperty.Maybe.ValueOrDefault?.PlayControls.Step.Fire()); // Called from frontend to generate the UIElements schema files frontendBackendModel.GenerateUIElementsSchema.Set((l, u) => backendUnityModelProperty.Maybe.ValueOrDefault?.GenerateUIElementsSchema.Start(l, u).ToRdTask(l)); // Signalled from frontend to select and ping the object in the Project view frontendBackendModel.ShowFileInUnity.Advise(lifetime, file => backendUnityModelProperty.Maybe.ValueOrDefault?.ShowFileInUnity.Fire(file)); // Signalled from fronted to open the preferences window frontendBackendModel.ShowPreferences.Advise(lifetime, _ => backendUnityModelProperty.Maybe.ValueOrDefault?.ShowPreferences.Fire()); // Called from frontend to run a method in unity frontendBackendModel.RunMethodInUnity.Set((l, data) => { var backendUnityModel = backendUnityModelProperty.Maybe.ValueOrDefault; return(backendUnityModel == null ? RdTask <RunMethodResult> .Cancelled() : backendUnityModel.RunMethodInUnity.Start(l, data).ToRdTask(l)); }); frontendBackendModel.HasUnsavedScenes.Set((l, u) => backendUnityModelProperty.Maybe.ValueOrDefault?.HasUnsavedScenes.Start(l, u).ToRdTask(l)); }