I am trying to write a custom rule in FxCop to validate if my namespace starts with a particular word. I have tried something like below:
public override ProblemCollection Check(string namespaceName, TypeNodeCollection types)
{
if (namespaceName == null)
{
return this.Problems;
}
if (!namespaceName.StartsWith("FujiXerox.ApeosWare.", StringComparison.Ordinal))
{
this.Problems.Add(new Problem(this.GetNamedResolution("NamespaceResolution", namespaceName)));
}
return this.Problems;
}
But it is not working. Can anyone please suggest how to write this custom rule correctly.
I don't know with FxCop, but with NDepend (a .NET tool integrated in VS, that let's write custom code rules as C# LINQ queries) you just have to write:
The rule can be:
Disclaimer: I work at NDepend