Example #1
0
        private IProject ResolveTargetTestProject([NotNull] ITreeNode contextNode, [NotNull] ISolution solution, [NotNull] ReSharperHelperSettings helperSettings)
        {
            // Get project by assembly attribute (if present).
            var projectName = solution.GetPsiServices()
                              .Symbols
                              .GetModuleAttributes(contextNode.GetPsiModule())
                              .GetAttributeInstances(AssemblyMetadataAttributeName, false)
                              .Select(TryExtractProjectNameFromAssemblyMetadataAttribute)
                              .FirstNotNull();

            // Check whether we have configured global test project.
            if (string.IsNullOrEmpty(projectName))
            {
                projectName = helperSettings.TestsProjectName;
            }

            if (!string.IsNullOrEmpty(projectName))
            {
                return(solution.GetProjectByName(projectName));
            }

            // Try to guess project specific test project.
            var currentProjectName = contextNode.GetProject()?.Name;

            if (currentProjectName == null)
            {
                return(null);
            }

            var candidates = TestProjectSuffixes
                             .SelectMany(suffix => solution.GetProjectsByName(currentProjectName + suffix))
                             .WhereNotNull()
                             .ToArray();

            if (candidates.Length > 0)
            {
                if (candidates.Length == 1)
                {
                    return(candidates[0]);
                }

                return(null);
            }

            // Try to guess global test project.
            candidates = solution.GetAllProjects()
                         .Where(proj => TestProjectSuffixes.Any(suffix => proj.Name.EndsWith(suffix, StringComparison.Ordinal)))
                         .ToArray();

            if (candidates.Length == 1)
            {
                return(candidates[0]);
            }

            return(null);
        }
Example #2
0
        public IList <IProjectItem> GetProjectItemInSharedProjects(IProjectItem projectItem)
        {
            var playerProject = projectItem.GetProject().NotNull();

            if (!playerProject.Name.EndsWith(PlayerProjectSuffix)) // todo: check that define `UNITY_EDITOR` is not be present
            {
                return(EmptyList <IProjectItem> .InstanceList);
            }

            var originalProject = mySolution
                                  .GetProjectsByName(playerProject.Name.RemoveEnd(PlayerProjectSuffix))
                                  .SingleItem();

            if (originalProject == null)
            {
                return(EmptyList <IProjectItem> .InstanceList);
            }

            return(originalProject.FindProjectItemsByLocation(projectItem.Location).ToList());
        }
        private static bool TryGetEnginePluginFromSolution(ISolution solution, UnrealPluginInstallInfo installInfo)
        {
            var engineProject = solution.GetProjectsByName("UE4").FirstNotNull();

            if (engineProject?.ProjectFile == null)
            {
                return(false);
            }

            var engineProjectFile = engineProject.ProjectFile;
            var engineRootFolder  = engineProjectFile.Location.Directory.Directory.Directory;

            return(TryGetEnginePluginFromEngineRoot(installInfo, engineRootFolder));
        }