Ejemplo n.º 1
0
        public ValidationResult Validate()
        {
            foreach (IPlugin plugin in _projectNode
                     .Project.AllPlugins.Where(
                         p => p.HasSpecificVersion &&
                         !_repository.ContainsProject(p, true) &&
                         !_externalModules.Contains(p, true)))
            {
                var error = new ValidationError(
                    _projectNode.Project, "Project plugin error",
                    ErrorLevel.Warning);

                var potencial = _repository.SelectProjectNodes(plugin, false).ToArray();
                if (potencial.Length == 0)
                {
                    error.Details = string.Format("Project {0} uses undefined plugin {1}.", _projectNode.Project, plugin);
                    error.AddFix(new AddToExternalFix(_externalModules, plugin));
                }
                else if (potencial.Length == 1)
                {
                    error.Details = string.Format("Project {0} references different plugin version {1}.", _projectNode.Project, plugin);
                    error.AddFix(new VersionFix(_projectNode.Project, plugin, potencial.Single().Version));
                }
                else
                {
                    error.Details = string.Format("Project {0} references different plugin version {1}.", _projectNode.Project, plugin);
                    foreach (var candicate in potencial)
                    {
                        error.AddFix(new VersionFix(_projectNode.Project, plugin, candicate.Version));
                    }
                }

                _validationOutput.AddError(error);
            }
            return(ValidationResult.Good);
        }
Ejemplo n.º 2
0
        public ValidationResult Validate()
        {
            Project          project = _projectNode.Project;
            IParentReference parent  = project.Parent;

            if (parent == null)
            {
                return(ValidationResult.Good);
            }

            var error = new ValidationError(_projectNode.Project, "Project parent error", ErrorLevel.Warning);

            if (_externalModules.Contains(parent, true))
            {
                return(ValidationResult.Good);
            }

            if (_repository.ContainsProject(parent, true))
            {
                var    parentProject        = _repository.SelectProjectNodes(parent, true).Single();
                string resolvedPathToParent = PathOperations.GetRelativePath(_projectNode.FullPath, parentProject.FullPath);
                resolvedPathToParent = PathOperations.Normalize(resolvedPathToParent);

                if (!string.Equals(_projectNode.ParentPath, resolvedPathToParent, StringComparison.OrdinalIgnoreCase))
                {
                    error.Details = string.Format("Parent path '{0}' does not point to {1}, should be {2}",
                                                  _projectNode.ParentPath, parentProject, resolvedPathToParent);

                    error.AddFix(new RelativePathFix(project, resolvedPathToParent));
                    _validationOutput.AddError(error);
                }

                return(ValidationResult.Good);
            }

            var potencial = _repository.SelectProjectNodes(parent, false).ToArray();

            if (potencial.Length == 0)
            {
                error.Details = string.Format("Project {0} rererences unknown parent {1}.", _projectNode, parent);
                error.AddFix(new AddToExternalFix(_externalModules, parent));

                // REVIEW: try to resolve via parent path
            }
            else if (potencial.Length == 1)
            {
                error.Details = string.Format("Project {0} references does not match actual version {1}.", _projectNode.Project, parent);                 // TODO: better message
                error.AddFix(new VersionFix(_projectNode.Project, parent, potencial.Single().Version));
            }
            else
            {
                error.Details = string.Format("Project {0} references different plugin version {1}.", _projectNode.Project, parent);
                foreach (var candicate in potencial)
                {
                    error.AddFix(new VersionFix(_projectNode.Project, parent, candicate.Version));
                }
            }

            _validationOutput.AddError(error);
            return(ValidationResult.Good);
        }
Ejemplo n.º 3
0
 bool IsDependencyIgnored(IProjectReference dependencyReference)
 {
     return(_externalModules.Contains(dependencyReference, false));
 }