The official blog of the Windows Presentation Foundation Team
The XAML toolkit, announced here and downloadable here, provides a number of FxCop rules for analyzing your XAML. This post describes how the XAML Toolkit also helps you write FxCop rules.
There are resources on the net describing how to write an FxCop rule. You can read the original MSDN article here or a newer posting on the FxCop team blog here. The difference here is that the XAML Toolkit has already sub-classed the BaseIntrospectionRule with the BaseXamlRule.
BaseXamlRule implements the Check(Resource resource) method. This method will:
1: public abstract void CheckXaml(XamlDomObject rootObjectNode,
2: XamlSchemaContext schemaContext,
3: string resourceName);
1: internal virtual bool IsRuleValidForXamlFlavor(ResourceType xamlFlavor)
2: {
3: return true;
4: }
1: internal enum ResourceType
3: SimpleXAML,
4: Workflow,
5: WPF,
6: Silverlight
7: }