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); }
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); }
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); }
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); }