Custom rule. Add a new problem within the AfterAnalysis() method.  
Author Message
Anton Papst





PostPosted: Visual Studio Code Analysis and Code Metrics, Custom rule. Add a new problem within the AfterAnalysis() method. Top

Hello,

I,m writing a custom rule, where a have to collect some information from different assemblies befor being able to check if there is an error or not. (To collect the information the Check(AssemblyNode) method will be called for each assembly node).

I wont do the error analysis in the AfterAnalysis() function. The one problem is, that if I add a new Problem to the ProblemCollection within the AfterAnalysis() method, this problem will not be showed in the FxCop output pane. Is there a way to make it work, or is the Check() method the only place where new Problems can be added Thank You.

Best regards,

Anton Papst



Visual Studio Team System12  
 
 
David M. Kean - MSFT





PostPosted: Visual Studio Code Analysis and Code Metrics, Custom rule. Add a new problem within the AfterAnalysis() method. Top

Only the Check overloads allow you to return problems. Although you can still add problems to the Problems property in other methods, FxCop is not aware of this property, and only looks at ProblemCollection returned from the Check methods.

You can actually get access to all the assemblies in analysis by looking at the RuleUtilities.AnalysisAssemblies property. So simply iterate over that in the assembly check to determine any problems.