dotnet-installer/tools/MultiProjectValidator/ProjectAnalyzer.cs

44 lines
1.1 KiB
C#
Raw Normal View History

using System.Collections.Generic;
using Microsoft.DotNet.ProjectModel;
using MultiProjectValidator.AnalysisRules;
namespace MultiProjectValidator
{
public class ProjectAnalyzer
{
public static ProjectAnalyzer Create(List<ProjectContext> projectContexts)
{
// Any Additional rules would be added here
var rules = new List<IAnalysisRule>
{
new DependencyMismatchRule()
};
return new ProjectAnalyzer(rules, projectContexts);
}
2015-12-16 22:10:39 +00:00
private List<ProjectContext> _projectContexts;
private List<IAnalysisRule> _rules;
private ProjectAnalyzer(List<IAnalysisRule> rules, List<ProjectContext> projectContexts)
{
2015-12-16 22:10:39 +00:00
_rules = rules;
_projectContexts = projectContexts;
}
public List<AnalysisResult> DoAnalysis()
{
var results = new List<AnalysisResult>();
2015-12-16 22:10:39 +00:00
foreach(var rule in _rules)
{
2015-12-16 22:10:39 +00:00
results.Add(rule.Evaluate(_projectContexts));
}
return results;
}
}
}