Skip to content
Stan B edited this page Apr 30, 2014 · 13 revisions

Architecture and main moving parts

Picture

SqlCop.Engine

The engine is a wrapper around Microsoft Microsoft.Data.Schema.ScriptDom.SqlTSql100Parser which parses TSQL into graph of objects. Engine knows how to get available rules and can run one or many rules against given TSQL

SqlCop.Rules

This is where the rules are defined. Two main group of classes: Visitors These are custom subclasses of Visitor which are being called during parsing Rules Custom rules that hooked up to the visitors. All rules are derived from Rule class;

public abstract class Rule
{
  protected Visitor Visitor { get; set; }
  protected List<RuleProblem> Problems {get; set;}

  public Rule()
  {
    Problems = new List<RuleProblem>();
  }

  public abstract IList<RuleProblem> Analyze(RuleContext context);

  protected void AddProblem(string problemDescription)
  {
    Problems.Add(new RuleProblem(this, problemDescription, Visitor.SqlFragment));
  }
}

SqlCop.Service, ServiceInterface, ServiceModel

This is ServiceStack facade. The idea behind it is that any client Web Forms, SSMS Add-in or other can call the service and ask what rules are available and check syntax of a given TSQL

Other

There are unit and integration testing projects and also some common classes