[FxCop] Files vs. Project

Aug 16, 2010 at 1:58 PM

Hi all,

I've been plying with the FxCop task, and I find it quite nice. However, there is one issue that I don't understant.

The task allows to use only one of attribute: Files or Project; there is such code in the task: 

    if (this.Files != null)
    {
        foreach (ITaskItem item4 in this.Files)
        {
            str = str + " /file:\"" + item4.ItemSpec + "\"";
        }
    }
    else if (!string.IsNullOrEmpty(this.Project))
    {
        str = str + " /project:\"" + this.Project + "\"";
    }

However, the FxCopCmd.exe itself can take them both.

Why is that so? Why can't use the both?

Thanks,

Coordinator
Aug 16, 2010 at 2:09 PM

I'm surprised that FxCop allows both. I'd expect people to use one or the other, not both. I guess it's a bug in the task, strictly speaking. A workaround at the moment would be to use the task twice, once for your proj and once for your other files.

Do you use both? Why?

Mike

Aug 16, 2010 at 2:22 PM

Yes, I wanted to use both.

I have to goals in it:

1) remove the need to modify MSBuild scripts when new DLL is to be added for analyse

When I have a ItemGroup defined like this:

    <ItemGroup>
        <FxCopDlls
            Include="$(SolutionRoot)\path_to_dlls\*.dll" />
    </ItemGroup>

than I run something like this:

        <MSBuild.ExtensionPack.CodeQuality.FxCop
            TaskAction="Analyse"
            Files="@(FxCopDLLs)"            
            Project="$(SolutionRoot)\Source\WLAN.FxCop" />

I don't need to modyfy anything to include new DLL into to FxCop analyse.

2) remove the need to modify the MSBuild scripts when changing the rules set.

When I have the rules defined in the native FxCop project file I can edit the file in the FxCop nice editor and the MSBuild script is not touched when the rules set is changed.

 

When you pass the two parameters to the FxCopCmd.exe it will do exactly what I want: aply the rules from the FxCop project file (/project) to the DLLs (/files).

Coordinator
Aug 16, 2010 at 3:08 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Coordinator
Aug 17, 2010 at 1:22 PM

Can you give the latest code in 3.5.7.0 or 4.0.1.0 a go. It now supports supplying both properties.

Mike

Aug 23, 2010 at 10:13 AM
mikefourie wrote:

Can you give the latest code in 3.5.7.0 or 4.0.1.0 a go. It now supports supplying both properties.

Mike

 Could you provide me with a DLL? I don't have a VS with me at the moment.

Thanks,

 

Coordinator
Aug 23, 2010 at 10:21 AM

If you email me on the feedback address I'll send them.

Mike

Aug 23, 2010 at 2:31 PM
Edited Aug 23, 2010 at 2:32 PM

Works like a charm. Thank you!

Looking forward for the release.