Microsoft.SqlServer.Dac.CodeAnalysis Namespace



The results of Code Analysis against a particular model. Will include any SqlRuleProblems found, in addition to any errors that occurred during analysis


The settings used to configure rules used during analysis.

Before analysis begins, this settings object will be applied to the rules discovered by the analysis service. If DisableRulesNotInSettings is set to true then any rules not included in these settings will be disabled and not run during analysis.

These settings are applied by calling the ApplySettingsToRules(IEnumerable<RuleConfiguration>) method on rules returned by the engine.


A service that runs code analysis against a model and provides results to the caller.

Note that this class is not thread-safe since multiple simulataneous calls to Analyze(TSqlModel) are not supported. However it is possible to call Cancel() from a thread while a separate thread is waiting on the Analyze(TSqlModel) method to complete.


Factory class that supports creation of CodeAnalysisService objects.


Defines the optional configuration settings for a CodeAnalysisService. This can determine which rules are run, how to suppress certain problems, and where to save results to.

These settings can also be set on the CodeAnalysisService after it has been created, but are included here to make construction more convenient.


Attribute defining a rule export, and the metadata about that rule. Implements ISqlAnalysisRuleMetadata, which should be used on the importer side to ensure type consistency


Represents an exception that occurred when running the rule problem suppression test.


Represents the problem suppressor used by SSDT projects. The ShouldSuppressProblem method can be passed to ShouldSuppressProblem in order to use this class.

This reads suppression information from a file with a name matching SuppressionFilename ("StaticCodeAnalysis.SuppressMessages.xml") in the root directory.

All relative paths will be resolved relative to the project folder defined in the constructor


Specifies how a rule should be configured - should this be enabled or disabled? What severity should be applied for the rule?


Describes a rule discovered by the rule engine and supports configuration of its properties. Descriptors inherit properties from RuleConfiguration, to support enabling/disabling the rule during analysis and specifying the severity for problems created by the rule.

This class is not intended to be subclasses by external users - instances of RuleDescriptor are created by the analysis service.


Represent an exception that may occur during a code analysis run


Base class for all types of analysis rule. An analysis rule analyzes a model / model element and returns a list of problems found during analysis.


Base class for SQL static code analysis rules. An analysis rule analyzes a model / model element and returns a list of problems found during analysis.

Implementing classes must have a ExportCodeAnalysisRuleAttribute defined on the class definition to be discovered and used during code analysis.


Defines the fields necessary for analysis, including the schema model and model element to analyze.


Describes a problem found by a rule during analysis. Contains relevant information such as the Rule that found the problem, the SqlObject causing the problem, the severity, and the error message to display.

Source position information (source name, start line and column) are initially inferred based on the ModelElement and Fragment passed into the constructor. Note that if a Fragment is passed in then the start line/column for that TSqlFragment will be used (if present), otherwise the TSqlObject's values will be used (if present). Note that certain models such as those generated from a dacpac may not have source position information.


The context information for suppressing a SCA problem


Information about a problem being suppressed for a particular source. This information includes the source name and the rule whose problems should be suppressed.



The metadata describing a rule - its namespace, id, scope etc.



Determines the validation performed on the model prior to code analysis.


The type of message for reporting problems


The scope examined by a static code analysis rule.