Exemple #1
0
        public bool TryGetProject(IProjectReference reference, out IProject project, bool strictVersion = true)
        {
            var operation = reference.ReferenceOperations();

            project = AllProjects.
                      SingleOrDefault(p =>
            {
                var r = _extractor.Extract(p);
                return(operation.ReferenceEqualTo(r, strictVersion));
            });
            return(project != null);
        }
Exemple #2
0
        // TODO: TEST
        internal IProjectValidationProblem ValidateReference(IProject project, IProjectReference reference, string referenceTitle)
        {
            IProjectReferenceOperations operation = reference.ReferenceOperations();

            var potencial = _context.AllAvailableProjectReferences.
                            Where(p => operation.ReferenceEqualTo(p, false)).ToArray();

            if (potencial.Length == 0)
            {
                return(new ValidationProblem(referenceTitle + "missing")                 // TODO: fixable
                {
                    ProjectReference = project,
                    Severity = ProblemSeverity.ProjectWarning,
                    Description = string.Format("uses unknown {0} {1}", referenceTitle, reference)
                });
                //error.AddFix(new AddExternalModuleFix(_externalModules, dependency));
            }

            // REVIEW: First is enougth
            // REVIEW: many exact matches is not a problem of project reference, but need to be catched differently
            var exact = potencial.FirstOrDefault(p => reference.Version == p.Version);

            if (exact != null)
            {
                return(null);
            }

            if (potencial.Length == 1)
            {
                return(new ValidationProblem(referenceTitle + "versionmissmatch")                 // TODO: fixable
                {
                    ProjectReference = project,
                    Severity = ProblemSeverity.ProjectWarning,
                    Description = string.Format("version of {0} different from {1}", referenceTitle, reference)
                });
                //		error.AddFix(new ApplyVersionFix(_projectNode.Project, dependency, potencial.Single().Version));
            }
            return(new ValidationProblem(referenceTitle + "version")             // TODO: fixable
            {
                ProjectReference = project,
                Severity = ProblemSeverity.ProjectWarning,
                Description = string.Format("version of {0} different from {1}. Found multiple potencial candidates", referenceTitle, reference)
            });
            //		foreach (var candicate in potencial)
            //		{
            //			error.AddFix(new ApplyVersionFix(_projectNode.Project, dependency, candicate.Version));
            //		}
        }
Exemple #3
0
        public bool IsExternalModule(IProjectReference projectReference)
        {
            var operation = projectReference.ReferenceOperations();

            return(_externalModules.FirstOrDefault(i => operation.ReferenceEqualTo(i, true)) != null);
        }