コード例 #1
0
ファイル: Csc_Tests.cs プロジェクト: zhuweijia/msbuild
        public void MultipleAnalyzers_HostObject()
        {
            IBuildEngine2 mockEngine = new MockEngine();
            Csc           csc        = new Csc();

            csc.BuildEngine = mockEngine;

            MockCscAnalyzerHostObject cscHostObject = new MockCscAnalyzerHostObject();

            cscHostObject.SetDesignTime(true);

            csc.HostObject = cscHostObject;
            csc.UseHostCompilerIfAvailable = true;

            Assert.IsNull(cscHostObject.Analyzers);

            csc.Analyzers = new TaskItem[]
            {
                new TaskItem("Foo.dll"),
                new TaskItem("Bar.dll")
            };

            csc.Sources = new TaskItem[] { new TaskItem("a.cs") };

            bool cscSuccess = csc.Execute();

            Assert.IsTrue(cscSuccess, "Csc task failed.");

            Assert.AreEqual(2, cscHostObject.Analyzers.Length);
            Assert.AreEqual("Foo.dll", cscHostObject.Analyzers[0].ItemSpec);
            Assert.AreEqual("Bar.dll", cscHostObject.Analyzers[1].ItemSpec);
        }
コード例 #2
0
ファイル: Csc_Tests.cs プロジェクト: zhuweijia/msbuild
        public void AdditionalFile_HostObject()
        {
            IBuildEngine2 mockEngine = new MockEngine();
            Csc           csc        = new Csc();

            csc.BuildEngine = mockEngine;

            MockCscAnalyzerHostObject cscHostObject = new MockCscAnalyzerHostObject();

            cscHostObject.SetDesignTime(true);

            csc.HostObject = cscHostObject;
            csc.UseHostCompilerIfAvailable = true;

            Assert.IsNull(cscHostObject.AdditionalFiles);

            csc.AdditionalFiles = new TaskItem[]
            {
                new TaskItem("web.config")
            };

            csc.Sources = new TaskItem[] { new TaskItem("a.cs") };

            bool cscSuccess = csc.Execute();

            Assert.IsTrue(cscSuccess, "Csc task failed.");
            Assert.AreEqual(1, cscHostObject.AdditionalFiles.Length);
            Assert.AreEqual("web.config", cscHostObject.AdditionalFiles[0].ItemSpec);
        }
コード例 #3
0
ファイル: Csc_Tests.cs プロジェクト: zhuweijia/msbuild
        public void RuleSet_HostObject()
        {
            IBuildEngine2 mockEngine = new MockEngine();
            Csc           csc        = new Csc();

            csc.BuildEngine = mockEngine;

            MockCscAnalyzerHostObject cscHostObject = new MockCscAnalyzerHostObject();

            cscHostObject.SetDesignTime(true);

            csc.HostObject = cscHostObject;
            csc.UseHostCompilerIfAvailable = true;

            Assert.IsNull(cscHostObject.RuleSet);

            csc.CodeAnalysisRuleSet = "Bar.ruleset";

            csc.Sources = new TaskItem[] { new TaskItem("a.cs") };

            bool cscSuccess = csc.Execute();

            Assert.IsTrue(cscSuccess, "Csc task failed.");
            Assert.AreEqual("Bar.ruleset", cscHostObject.RuleSet);
        }
コード例 #4
0
ファイル: Csc_Tests.cs プロジェクト: zhuweijia/msbuild
        public void NoAnalyzer_HostObject()
        {
            IBuildEngine2 mockEngine = new MockEngine();
            Csc           csc        = new Csc();

            csc.BuildEngine = mockEngine;

            MockCscAnalyzerHostObject cscHostObject = new MockCscAnalyzerHostObject();

            cscHostObject.SetDesignTime(true);

            csc.HostObject = cscHostObject;
            csc.UseHostCompilerIfAvailable = true;

            Assert.IsNull(cscHostObject.Analyzers);

            csc.Sources = new TaskItem[] { new TaskItem("a.cs") };

            bool cscSuccess = csc.Execute();

            Assert.IsTrue(cscSuccess, "Csc task failed.");
            Assert.IsNull(cscHostObject.Analyzers);
        }
コード例 #5
0
ファイル: Csc_Tests.cs プロジェクト: JamesLinus/msbuild
        public void RuleSet_HostObject()
        {
            IBuildEngine2 mockEngine = new MockEngine();
            Csc csc = new Csc();
            csc.BuildEngine = mockEngine;

            MockCscAnalyzerHostObject cscHostObject = new MockCscAnalyzerHostObject();
            cscHostObject.SetDesignTime(true);

            csc.HostObject = cscHostObject;
            csc.UseHostCompilerIfAvailable = true;

            Assert.IsNull(cscHostObject.RuleSet);

            csc.CodeAnalysisRuleSet = "Bar.ruleset";

            csc.Sources = new TaskItem[] { new TaskItem("a.cs") };

            bool cscSuccess = csc.Execute();

            Assert.IsTrue(cscSuccess, "Csc task failed.");
            Assert.AreEqual("Bar.ruleset", cscHostObject.RuleSet);
        }
コード例 #6
0
ファイル: Csc_Tests.cs プロジェクト: JamesLinus/msbuild
        public void MultipleAnalyzers_HostObject()
        {
            IBuildEngine2 mockEngine = new MockEngine();
            Csc csc = new Csc();
            csc.BuildEngine = mockEngine;

            MockCscAnalyzerHostObject cscHostObject = new MockCscAnalyzerHostObject();
            cscHostObject.SetDesignTime(true);

            csc.HostObject = cscHostObject;
            csc.UseHostCompilerIfAvailable = true;

            Assert.IsNull(cscHostObject.Analyzers);

            csc.Analyzers = new TaskItem[]
            {
                new TaskItem("Foo.dll"),
                new TaskItem("Bar.dll")
            };

            csc.Sources = new TaskItem[] { new TaskItem("a.cs") };

            bool cscSuccess = csc.Execute();

            Assert.IsTrue(cscSuccess, "Csc task failed.");

            Assert.AreEqual(2, cscHostObject.Analyzers.Length);
            Assert.AreEqual("Foo.dll", cscHostObject.Analyzers[0].ItemSpec);
            Assert.AreEqual("Bar.dll", cscHostObject.Analyzers[1].ItemSpec);
        }
コード例 #7
0
ファイル: Csc_Tests.cs プロジェクト: JamesLinus/msbuild
        public void NoAnalyzer_HostObject()
        {
            IBuildEngine2 mockEngine = new MockEngine();
            Csc csc = new Csc();
            csc.BuildEngine = mockEngine;

            MockCscAnalyzerHostObject cscHostObject = new MockCscAnalyzerHostObject();
            cscHostObject.SetDesignTime(true);

            csc.HostObject = cscHostObject;
            csc.UseHostCompilerIfAvailable = true;

            Assert.IsNull(cscHostObject.Analyzers);

            csc.Sources = new TaskItem[] { new TaskItem("a.cs") };

            bool cscSuccess = csc.Execute();

            Assert.IsTrue(cscSuccess, "Csc task failed.");
            Assert.IsNull(cscHostObject.Analyzers);
        }
コード例 #8
0
ファイル: Csc_Tests.cs プロジェクト: JamesLinus/msbuild
        public void AdditionalFile_HostObject()
        {
            IBuildEngine2 mockEngine = new MockEngine();
            Csc csc = new Csc();
            csc.BuildEngine = mockEngine;

            MockCscAnalyzerHostObject cscHostObject = new MockCscAnalyzerHostObject();
            cscHostObject.SetDesignTime(true);

            csc.HostObject = cscHostObject;
            csc.UseHostCompilerIfAvailable = true;

            Assert.IsNull(cscHostObject.AdditionalFiles);

            csc.AdditionalFiles = new TaskItem[]
            {
                new TaskItem("web.config")
            };

            csc.Sources = new TaskItem[] { new TaskItem("a.cs") };

            bool cscSuccess = csc.Execute();

            Assert.IsTrue(cscSuccess, "Csc task failed.");
            Assert.AreEqual(1, cscHostObject.AdditionalFiles.Length);
            Assert.AreEqual("web.config", cscHostObject.AdditionalFiles[0].ItemSpec);
        }