I'm trying to write a FxCop rule that matches classes that are adorned with the Serializable attribute, but it seems like the attribute is being ignored.
Eg. given this sample class
[Serializable]
[Description]
public class ClassWithSerializableMustHaveSerializableBaseClass : BaseClass
{
}
I would have thought this code from my custom rule would match successfully:
public override ProblemCollection Check(TypeNode type)
{
if (type.Attributes.Any(a => a.Type.FullName == typeof(SerializableAttribute).FullName))
{
var problem = new Problem(GetResolution(), type.SourceContext);
Problems.Add(problem);
}
return Problems;
}
But it isn't. If I change the matching type to the DescriptionAttribute, then it does work. Is there something magical about SerializableAttribute or have I missed something obvious?