Esempio n. 1
0
        public void MissingRulesWithTargets()
        {
            FxCop task = new FxCop();

            task.TargetAssemblies = new TaskItem[] { new TaskItem("target.dll") };
            Assert.IsFalse((bool)typeof(FxCop).InvokeMember("ValidateParameters", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.InvokeMethod, null, task, null));
        }
Esempio n. 2
0
        public void GenerateAllParameters()
        {
            // These do not need to make sense really since we are not invoking
            // the executable.
            FxCop task = new FxCop();

            task.ToolPath = @"c:\fxcop";
            task.AnalysisReportFileName = @"report.xml";
            task.DirectOutputToConsole  = true;
            task.ConsoleXslFileName     = @"console-transform.xsl";
            task.DependencyDirectories  = new TaskItem[] { new TaskItem("depDir1"), new TaskItem("depDir2") };
            task.ApplyOutXsl            = true;
            task.OutputXslFileName      = @"transform.xsl";
            task.ProjectFile            = @"c:\project.fxcop";
            task.PlatformDirectory      = @"c:\platform";
            task.TargetAssemblies       = new TaskItem[] { new TaskItem("ABC.dll"), new TaskItem("DEF.dll") };
            task.ImportFiles            = new TaskItem[] { new TaskItem("import.xml") };
            task.RuleLibraries          = new TaskItem[] { new TaskItem("a-rules.dll"), new TaskItem("b-rules.dll") };
            task.Rules = new TaskItem[] { new TaskItem("Microsoft.Design#CA1012"), new TaskItem("-Microsoft.Design#CA2210") };
            task.IncludeSummaryReport = true;
            task.TypeList             = "TypeA,TypeB";
            task.Verbose     = true;
            task.SaveResults = true;

            Assert.AreEqual("/aXsl /c /cXsl:\"console-transform.xsl\" /d:\"depDir1\" /d:\"depDir2\" " +
                            "/f:\"ABC.dll\" /f:\"DEF.dll\" /i:\"import.xml\" /o:\"report.xml\" " +
                            "/oXsl:\"transform.xsl\" /plat:\"c:\\platform\" /p:\"c:\\project.fxcop\" " +
                            "/r:\"c:\\fxcop\\Rules\\a-rules.dll\" /r:\"c:\\fxcop\\Rules\\b-rules.dll\" " +
                            "/rid:Microsoft.Design#CA1012 /rid:-Microsoft.Design#CA2210 " +
                            "/s /t:TypeA,TypeB " +
                            "/u /v ",
                            (string)typeof(FxCop).InvokeMember("GenerateCommandLineCommands", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.InvokeMethod, null, task, null));
        }
Esempio n. 3
0
        public void SetExplicitToolPath()
        {
            FxCop task = new FxCop();

            task.ToolPath = @"c:\fxcop";
            Assert.AreEqual(@"c:\fxcop\fxcopcmd.exe", (string)typeof(FxCop).InvokeMember("GenerateFullPathToTool", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.InvokeMethod, null, task, null));
        }
Esempio n. 4
0
        public void GenerateAllParameters()
        {

            // These do not need to make sense really since we are not invoking
            // the executable.
            FxCop task = new FxCop();
            task.ToolPath = @"c:\fxcop";
            task.AnalysisReportFileName = @"report.xml";
            task.DirectOutputToConsole = true;
            task.ConsoleXslFileName = @"console-transform.xsl";
            task.DependencyDirectories = new TaskItem[] { new TaskItem("depDir1"), new TaskItem("depDir2") };
            task.ApplyOutXsl = true;
            task.OutputXslFileName = @"transform.xsl";
            task.ProjectFile = @"c:\project.fxcop";
            task.PlatformDirectory = @"c:\platform";
            task.TargetAssemblies = new TaskItem[] { new TaskItem("ABC.dll"), new TaskItem("DEF.dll") };
            task.ImportFiles = new TaskItem[] { new TaskItem("import.xml") };
            task.RuleLibraries = new TaskItem[] { new TaskItem("a-rules.dll"), new TaskItem("b-rules.dll") };
            task.Rules = new TaskItem[] { new TaskItem("Microsoft.Design#CA1012"), new TaskItem("-Microsoft.Design#CA2210") };
            task.IncludeSummaryReport = true;
            task.TypeList = "TypeA,TypeB";
            task.Verbose = true;
            task.SaveResults = true;
            task.IgnoreGeneratedCode = true;

            Assert.AreEqual("/aXsl /c /cXsl:\"console-transform.xsl\" /d:\"depDir1\" /d:\"depDir2\" " +
                                             "/f:\"ABC.dll\" /f:\"DEF.dll\" /i:\"import.xml\" /o:\"report.xml\" " +
                                             "/oXsl:\"transform.xsl\" /plat:\"c:\\platform\" /p:\"c:\\project.fxcop\" " +
                                             "/r:\"c:\\fxcop\\Rules\\a-rules.dll\" /r:\"c:\\fxcop\\Rules\\b-rules.dll\" " +
                                             "/rid:Microsoft.Design#CA1012 /rid:-Microsoft.Design#CA2210 " +
                                             "/s /t:TypeA,TypeB " +
                                             "/u /v /igc ",
                                             (string)typeof(FxCop).InvokeMember("GenerateCommandLineCommands", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.InvokeMethod, null, task, null));
        }
Esempio n. 5
0
        private static ReviewTool CreateTool(string option)
        {
            ReviewTool tool = null;

            if (option == "1")
            {
                tool = new FxCop();
            }
            else if (option == "2")
            {
                tool = new Resharper();
            }

            return(tool);
        }
Esempio n. 6
0
        public void FxCopBasicPassTest()
        {
            // Initialise Instance
            var target = new FxCop {
                FxCopPath = @"D:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\FxCopCmd.exe", OutputFile = @"d:\a\fxcoplog1.txt"
            };

            // Declare additional parameters
            var parameters = new Dictionary <string, object>
            {
                { "Files", new[] { @"D:\Projects\MSBuildExtensionPack\Releases\4.0.4.0\Main\BuildBinaries\MSBuild.ExtensionPack.StyleCop.dll" } },
            };

            // Create a WorkflowInvoker and add the IBuildDetail Extension
            // Invoke the Workflow
            WorkflowInvoker invoker = new WorkflowInvoker(target);
            var             actual  = invoker.Invoke(parameters);

            // Test the result
            Assert.AreEqual("false", actual["AnalysisFailed"].ToString());
        }
Esempio n. 7
0
        public void FxCopBasicFailTest()
        {
            // Initialise Instance
            var target = new FxCop {
                FxCopPath = @"D:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\FxCopCmd.exe", OutputFile = @"d:\a\fxcoplog1.txt"
            };

            // Declare additional parameters
            var parameters = new Dictionary <string, object>
            {
                { "Files", new[] { @"C:\Users\Michael\Documents\visual studio 2010\Projects\FxCopFailTest\FxCopFailTest\bin\Debug\FxCopFailTest.dll" } },
                { "Rules", new[] { @"+D:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\Rules\DesignRules.dll" } },
            };

            // Create a WorkflowInvoker and add the IBuildDetail Extension
            // Invoke the Workflow
            WorkflowInvoker invoker = new WorkflowInvoker(target);
            var             actual  = invoker.Invoke(parameters);

            // Test the result
            Assert.AreEqual("true", actual["AnalysisFailed"].ToString());
        }
Esempio n. 8
0
        public void MissingTargetsAndProject()
        {
            FxCop task = new FxCop();

            Assert.IsFalse((bool)typeof(FxCop).InvokeMember("ValidateParameters", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.InvokeMethod, null, task, null));
        }
Esempio n. 9
0
 public void MissingRulesWithTargets()
 {
     FxCop task = new FxCop();
     task.TargetAssemblies = new TaskItem[] { new TaskItem("target.dll") };
     Assert.IsFalse((bool)typeof(FxCop).InvokeMember("ValidateParameters", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.InvokeMethod, null, task, null));
 }
Esempio n. 10
0
 public void MissingTargetsAndProject()
 {
     FxCop task = new FxCop();
     Assert.IsFalse((bool)typeof(FxCop).InvokeMember("ValidateParameters", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.InvokeMethod, null, task, null));
 }
Esempio n. 11
0
 public void SetExplicitToolPath()
 {
     FxCop task = new FxCop();
     task.ToolPath = @"c:\fxcop";
     Assert.AreEqual(@"c:\fxcop\fxcopcmd.exe", (string)typeof(FxCop).InvokeMember("GenerateFullPathToTool", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.InvokeMethod, null, task, null));
 }