Overview of Extensibility for Database Code Analysis Rules
Visual Studio Team System Database Edition includes code analysis rules to report on Transact-SQL (T-SQL) design, naming, and performance warnings in your database code. For more information, see Improving Database Code with Static Analysis.
If the built-in code analysis rules do not include coverage for a specific Transact-SQL issue that you want included, you can create custom database code analysis rules. For example, you might want to create a custom rule that avoids using the WAITFOR DELAY statement, as demonstrated in Walkthrough: Authoring a Custom Static Code Analysis Rule Assembly for SQL. To create custom database code analysis rules, you use the classes in the Microsoft.Data.Schema.StaticCodeAnalysis namespace.
Before you create custom code analysis rules for Database Edition, you should understand the basic architecture among the various components of database code analysis rules.
Database Code Analysis Rules Components
The following diagram illustrates how database code analysis rules components interact.
Architecture of Database Edition Static Code Analysis Extensibility
When you use the database code analysis rules feature in your current session of Database Edition, either by running static code analysis directly (for more information, see How to: Analyze Transact-SQL Code to Find Defects) or by performing a build, all the rules are loaded and used according to how you have configured them in your project. For more information, see How to: Enable and Disable Specific Rules for Static Analysis of Database Code. The Extension Manager will also load any custom rule assemblies that you have created and registered. For more information, see How to: Register and Manage Feature Extensions.
A custom code analysis rule class inherits from the Rule class. The custom rule class uses the DataSchemaModel to manage IModelElement and their Microsoft.Data.Schema.ScriptDom, which are passed to the Static Code Analysis Engine. In addition, the Data Schema Model provides query information about the model elements, relationships, and annotations to the code analysis rules, and this information is passed to the Error Manager.
See Also
Tasks
Walkthrough: Authoring a Custom Static Code Analysis Rule Assembly for SQL
How to: Register and Manage Feature Extensions
How to: Distribute Custom Feature Extensions to Team Members
Concepts
Extending the Features of Database Edition
Improving Database Code with Static Analysis