Example #1
0
 public bool IsSupported(IProject project, TargetFrameworkId targetFrameworkId)
 {
     using (ReadLockCookie.Create())
     {
         return(ReferencedAssembliesService.IsProjectReferencingAssemblyByName(project, targetFrameworkId, AssemblyReferenceName, out AssemblyNameInfo _));
     }
 }
Example #2
0
        private static bool ReferencesAssembly(IProject project, AssemblyNameInfo name)
        {
            AssemblyNameInfo info;

            return(ReferencedAssembliesService.IsProjectReferencingAssemblyByName(project,
                                                                                  project.GetCurrentTargetFrameworkId(), name, out info));
        }
        object IChangeProvider.Execute(IChangeMap changeMap)
        {
            var projectModelChange = changeMap.GetChange <ProjectModelChange>(mySolution);

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

            // ReSharper hasn't necessarily processed all references when it adds the IProject
            // to the IViewableProjectsCollection. Keep an eye on reference changes, add the
            // project settings if/when the project becomes a unity project
            var projects = new JetHashSet <IProject>();
            var changes  = ReferencedAssembliesService.TryGetAssemblyReferenceChanges(projectModelChange, ProjectExtensions.UnityReferenceNames);

            foreach (var change in changes)
            {
                projects.Add(change.GetNewProject());
            }

            foreach (var project in projects)
            {
                myChangeManager.ExecuteAfterChange(() =>
                {
                    if (project.IsUnityProject())
                    {
                        InitialiseProjectSettings(project);
                    }
                });
            }

            return(null);
        }
 public static bool IsFluentValidationProject(this IProject project)
 {
     return(ReferencedAssembliesService.IsProjectReferencingAssemblyByName(
                project,
                project.GetCurrentTargetFrameworkId(),
                AssemblyNameInfoFactory.Create2(FluentValidationAssemblyName, version: null),
                out _));
 }
        public static bool IsProjectReferencingNancy([CanBeNull] this IProjectElement projectElement)
        {
            AssemblyNameInfo referencedAssembly;

            if (!ReferencedAssembliesService.IsProjectReferencingAssemblyByName(projectElement, NancyAssemblyName, out referencedAssembly))
            {
                return(false);
            }

            return(true);
        }
Example #6
0
        object IChangeProvider.Execute(IChangeMap changeMap)
        {
            var projectModelChange = changeMap.GetChange <ProjectModelChange>(mySolution);

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

            var changes = ReferencedAssembliesService.TryGetAssemblyReferenceChanges(projectModelChange,
                                                                                     ourUnityReferenceNameInfos, myLogger);

            var newUnityProjects = new List <KeyValuePair <IProject, Lifetime> >();

            foreach (var change in changes)
            {
                if (change.IsAdded)
                {
                    var project = change.GetNewProject();
                    if (HasUnityReferenceOrFlavour(project))
                    {
                        Assertion.Assert(myAllProjectLifetimes.ContainsKey(project), "project is not added");
                        if (myAllProjectLifetimes.TryGetValue(project, out var projectLifetime))
                        {
                            newUnityProjects.Add(JetKeyValuePair.Of(project, projectLifetime));
                            if (!myUnityProjects.Contains(project))
                            {
                                myUnityProjects.Add(projectLifetime, project);
                            }
                        }
                    }
                }
            }

            if (newUnityProjects.Count > 0)
            {
                myChangeManager.ExecuteAfterChange(() =>
                {
                    NotifyHasUnityReference();
                    NotifyOnUnityProjectAdded(newUnityProjects);
                });
            }

            return(null);
        }
Example #7
0
        /// <summary>
        /// Checks if the given project is a Nuke build project.
        /// </summary>
        /// <param name="project">The project to test.</param>
        /// <returns>True if the project is a Nuke build project.</returns>
        public static bool IsNukeProject([CanBeNull] this IProject project)
        {
            if (project == null)
            {
                return(false);
            }
            var targetFrameworkId = project.GetCurrentTargetFrameworkId();

            if (!ReferencedAssembliesService.IsProjectReferencingAssemblyByName(project,
                                                                                targetFrameworkId,
                                                                                _NukeAssemblyNameInfo,
                                                                                out var _))
            {
                return(false);
            }

            var buildClass = project.GetAllProjectFiles(p => p.Name == "Build.cs").FirstOrDefault();

            return(buildClass != null);
        }
Example #8
0
        object IChangeProvider.Execute(IChangeMap changeMap)
        {
            var projectModelChange = changeMap.GetChange <ProjectModelChange>(mySolution);

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

            var changes = ReferencedAssembliesService.TryGetAssemblyReferenceChanges(projectModelChange,
                                                                                     ProjectExtensions.UnityReferenceNames, myLogger);

            var newUnityProjects = new JetHashSet <IProject>();

            foreach (var change in changes)
            {
                if (change.IsAdded)
                {
                    var project = change.GetNewProject();
                    if (project.IsUnityProject())
                    {
                        newUnityProjects.Add(project);
                    }
                }
            }

            myChangeManager.ExecuteAfterChange(() =>
            {
                foreach (var project in newUnityProjects)
                {
                    OnUnityProjectAdded(project);
                }
            });

            return(null);
        }
        public static bool IsProjectReferencingAssembly([CanBeNull] this IProjectElement projectElement, AssemblyNameInfo assemblyNameInfo)
        {
            AssemblyNameInfo referencedAssembly;

            return(ReferencedAssembliesService.IsProjectReferencingAssemblyByName(projectElement, assemblyNameInfo, out referencedAssembly));
        }
        public static bool IsProjectReferencingNancyRazorViewEngine([CanBeNull] this IProjectElement projectElement)
        {
            AssemblyNameInfo referencedAssembly;

            return(ReferencedAssembliesService.IsProjectReferencingAssemblyByName(projectElement, NancyRazorAssemblyName, out referencedAssembly));
        }
Example #11
0
 private static bool ReferencesAssembly(IProject project, TargetFrameworkId targetFrameworkId, AssemblyNameInfo name)
 {
     return(ReferencedAssembliesService.IsProjectReferencingAssemblyByName(project,
                                                                           targetFrameworkId, name, out var _));
 }
        public bool IsSupported(IProject project)
        {
            AssemblyNameInfo referencedAssembly;

            return(ReferencedAssembliesService.IsProjectReferencingAssemblyByName(project, TargetFrameworkId.Default, MSpecReferenceName, out referencedAssembly));
        }