FxCop 1.35 skipping Structs  
Author Message
Syed Junaid





PostPosted: Visual Studio Code Analysis and Code Metrics, FxCop 1.35 skipping Structs Top

While analyzing the NodeType the FxCop 1.35 is skipping the Struct which itself is a NodeType. I tried the following code while overriding the Check(NodeType) but still the structs are not getting trapped

public override ProblemCollection Check(TypeNode type)
{
if(type == null)
{
return null;
}

switch (type.NodeType)
{
case NodeType.Class: return Check((Class)type);

case NodeType.Interface: return Check((Interface)type);

case NodeType.EnumNode: return Check((EnumNode)type);

case NodeType.Struct: return Check((Struct)type);
}
return base.Check(type);

}

I tried one workaround for this by overriding the Check(Module) method and checking for each type. There I can trap the Structs.

But problem with this is if the user unchecks the target assembly and keep the struct checked in the window under FxCop's rules tab then this struct wont be trapped or checked.

If anybody knows the solution to it, please let me know.



Visual Studio Team System42  
 
 
David M. Kean - MSFT





PostPosted: Visual Studio Code Analysis and Code Metrics, FxCop 1.35 skipping Structs Top

Syed,

There is no known issue with checking structs. Can you first check the TargetsVisibility property of the rule to make sure that its not excluding the type

If this isn't the problem, then can you provide me with both a custom rule assembly and target assembly that reproduces the problem (send it to my email in my profile)

Regards

David



 
 
David M. Kean - MSFT





PostPosted: Visual Studio Code Analysis and Code Metrics, FxCop 1.35 skipping Structs Top

Update: Apparently, after further investigation, we do skip over structs without any members; we will be revisiting this decision for future versions.

Check to see if this is the problem.



 
 
Syed Junaid





PostPosted: Visual Studio Code Analysis and Code Metrics, FxCop 1.35 skipping Structs Top

Hi,

I tried both, struct with no member and a struct with members, but problem is still same.

Can you please suggest me where to check the TargetsVisibility property of a rule.


 
 
David M. Kean - MSFT





PostPosted: Visual Studio Code Analysis and Code Metrics, FxCop 1.35 skipping Structs Top

In your rule, override TargetsVisibility (inherited from BaseInstrospectionRule) and return TargetsVisibilities.All.